149545b38SMike Barcroft /*- 249545b38SMike Barcroft * Copyright (c) 2001, 2002 Mike Barcroft <mike@FreeBSD.org> 349545b38SMike Barcroft * Copyright (c) 2001 The NetBSD Foundation, Inc. 449545b38SMike Barcroft * All rights reserved. 549545b38SMike Barcroft * 649545b38SMike Barcroft * This code is derived from software contributed to The NetBSD Foundation 749545b38SMike Barcroft * by Klaus Klein. 849545b38SMike Barcroft * 949545b38SMike Barcroft * Redistribution and use in source and binary forms, with or without 1049545b38SMike Barcroft * modification, are permitted provided that the following conditions 1149545b38SMike Barcroft * are met: 1249545b38SMike Barcroft * 1. Redistributions of source code must retain the above copyright 1349545b38SMike Barcroft * notice, this list of conditions and the following disclaimer. 1449545b38SMike Barcroft * 2. Redistributions in binary form must reproduce the above copyright 1549545b38SMike Barcroft * notice, this list of conditions and the following disclaimer in the 1649545b38SMike Barcroft * documentation and/or other materials provided with the distribution. 1749545b38SMike Barcroft * 3. All advertising materials mentioning features or use of this software 1849545b38SMike Barcroft * must display the following acknowledgement: 1949545b38SMike Barcroft * This product includes software developed by the NetBSD 2049545b38SMike Barcroft * Foundation, Inc. and its contributors. 2149545b38SMike Barcroft * 4. Neither the name of The NetBSD Foundation nor the names of its 2249545b38SMike Barcroft * contributors may be used to endorse or promote products derived 2349545b38SMike Barcroft * from this software without specific prior written permission. 2449545b38SMike Barcroft * 2549545b38SMike Barcroft * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 2649545b38SMike Barcroft * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2749545b38SMike Barcroft * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2849545b38SMike Barcroft * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2949545b38SMike Barcroft * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 3049545b38SMike Barcroft * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 3149545b38SMike Barcroft * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 3249545b38SMike Barcroft * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 3349545b38SMike Barcroft * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 3449545b38SMike Barcroft * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3549545b38SMike Barcroft * POSSIBILITY OF SUCH DAMAGE. 3649545b38SMike Barcroft * 3749545b38SMike Barcroft * $FreeBSD$ 3849545b38SMike Barcroft */ 3949545b38SMike Barcroft 4049545b38SMike Barcroft #ifndef _MACHINE__STDINT_H_ 4149545b38SMike Barcroft #define _MACHINE__STDINT_H_ 4249545b38SMike Barcroft 4349545b38SMike Barcroft #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) 4449545b38SMike Barcroft 4549545b38SMike Barcroft #define INT8_C(c) (c) 4649545b38SMike Barcroft #define INT16_C(c) (c) 4749545b38SMike Barcroft #define INT32_C(c) (c) 4849545b38SMike Barcroft 4949545b38SMike Barcroft #define UINT8_C(c) (c) 5049545b38SMike Barcroft #define UINT16_C(c) (c) 5149545b38SMike Barcroft #define UINT32_C(c) (c ## U) 5249545b38SMike Barcroft 53*a56e818fSTijl Coosemans #ifdef __LP64__ 54c3e289e1SNathan Whitehorn #define INT64_C(c) (c ## L) 55c3e289e1SNathan Whitehorn #define UINT64_C(c) (c ## UL) 56c3e289e1SNathan Whitehorn #else 57c3e289e1SNathan Whitehorn #define INT64_C(c) (c ## LL) 58c3e289e1SNathan Whitehorn #define UINT64_C(c) (c ## ULL) 59c3e289e1SNathan Whitehorn #endif 6049545b38SMike Barcroft 61*a56e818fSTijl Coosemans #define INTMAX_C(c) INT64_C(c) 62*a56e818fSTijl Coosemans #define UINTMAX_C(c) UINT64_C(c) 63*a56e818fSTijl Coosemans 6449545b38SMike Barcroft #endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */ 6549545b38SMike Barcroft 6649545b38SMike Barcroft #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) 6749545b38SMike Barcroft 6849545b38SMike Barcroft /* 6949545b38SMike Barcroft * ISO/IEC 9899:1999 7049545b38SMike Barcroft * 7.18.2.1 Limits of exact-width integer types 7149545b38SMike Barcroft */ 7249545b38SMike Barcroft /* Minimum values of exact-width signed integer types. */ 7349545b38SMike Barcroft #define INT8_MIN (-0x7f-1) 7449545b38SMike Barcroft #define INT16_MIN (-0x7fff-1) 7549545b38SMike Barcroft #define INT32_MIN (-0x7fffffff-1) 76*a56e818fSTijl Coosemans #define INT64_MIN (-INT64_C(0x7fffffffffffffff)-1) 7749545b38SMike Barcroft 7849545b38SMike Barcroft /* Maximum values of exact-width signed integer types. */ 7949545b38SMike Barcroft #define INT8_MAX 0x7f 8049545b38SMike Barcroft #define INT16_MAX 0x7fff 8149545b38SMike Barcroft #define INT32_MAX 0x7fffffff 82*a56e818fSTijl Coosemans #define INT64_MAX INT64_C(0x7fffffffffffffff) 8349545b38SMike Barcroft 8449545b38SMike Barcroft /* Maximum values of exact-width unsigned integer types. */ 8549545b38SMike Barcroft #define UINT8_MAX 0xff 8649545b38SMike Barcroft #define UINT16_MAX 0xffff 87*a56e818fSTijl Coosemans #define UINT32_MAX 0xffffffff 88*a56e818fSTijl Coosemans #define UINT64_MAX UINT64_C(0xffffffffffffffff) 8949545b38SMike Barcroft 9049545b38SMike Barcroft /* 9149545b38SMike Barcroft * ISO/IEC 9899:1999 9249545b38SMike Barcroft * 7.18.2.2 Limits of minimum-width integer types 9349545b38SMike Barcroft */ 9449545b38SMike Barcroft /* Minimum values of minimum-width signed integer types. */ 9549545b38SMike Barcroft #define INT_LEAST8_MIN INT8_MIN 9649545b38SMike Barcroft #define INT_LEAST16_MIN INT16_MIN 9749545b38SMike Barcroft #define INT_LEAST32_MIN INT32_MIN 9849545b38SMike Barcroft #define INT_LEAST64_MIN INT64_MIN 9949545b38SMike Barcroft 10049545b38SMike Barcroft /* Maximum values of minimum-width signed integer types. */ 10149545b38SMike Barcroft #define INT_LEAST8_MAX INT8_MAX 10249545b38SMike Barcroft #define INT_LEAST16_MAX INT16_MAX 10349545b38SMike Barcroft #define INT_LEAST32_MAX INT32_MAX 10449545b38SMike Barcroft #define INT_LEAST64_MAX INT64_MAX 10549545b38SMike Barcroft 10649545b38SMike Barcroft /* Maximum values of minimum-width unsigned integer types. */ 10749545b38SMike Barcroft #define UINT_LEAST8_MAX UINT8_MAX 10849545b38SMike Barcroft #define UINT_LEAST16_MAX UINT16_MAX 10949545b38SMike Barcroft #define UINT_LEAST32_MAX UINT32_MAX 11049545b38SMike Barcroft #define UINT_LEAST64_MAX UINT64_MAX 11149545b38SMike Barcroft 11249545b38SMike Barcroft /* 11349545b38SMike Barcroft * ISO/IEC 9899:1999 11449545b38SMike Barcroft * 7.18.2.3 Limits of fastest minimum-width integer types 11549545b38SMike Barcroft */ 11649545b38SMike Barcroft /* Minimum values of fastest minimum-width signed integer types. */ 11749545b38SMike Barcroft #define INT_FAST8_MIN INT32_MIN 11849545b38SMike Barcroft #define INT_FAST16_MIN INT32_MIN 11949545b38SMike Barcroft #define INT_FAST32_MIN INT32_MIN 12049545b38SMike Barcroft #define INT_FAST64_MIN INT64_MIN 12149545b38SMike Barcroft 12249545b38SMike Barcroft /* Maximum values of fastest minimum-width signed integer types. */ 12349545b38SMike Barcroft #define INT_FAST8_MAX INT32_MAX 12449545b38SMike Barcroft #define INT_FAST16_MAX INT32_MAX 12549545b38SMike Barcroft #define INT_FAST32_MAX INT32_MAX 12649545b38SMike Barcroft #define INT_FAST64_MAX INT64_MAX 12749545b38SMike Barcroft 12849545b38SMike Barcroft /* Maximum values of fastest minimum-width unsigned integer types. */ 12949545b38SMike Barcroft #define UINT_FAST8_MAX UINT32_MAX 13049545b38SMike Barcroft #define UINT_FAST16_MAX UINT32_MAX 13149545b38SMike Barcroft #define UINT_FAST32_MAX UINT32_MAX 13249545b38SMike Barcroft #define UINT_FAST64_MAX UINT64_MAX 13349545b38SMike Barcroft 13449545b38SMike Barcroft /* 13549545b38SMike Barcroft * ISO/IEC 9899:1999 13649545b38SMike Barcroft * 7.18.2.4 Limits of integer types capable of holding object pointers 13749545b38SMike Barcroft */ 138*a56e818fSTijl Coosemans #ifdef __LP64__ 139c3e289e1SNathan Whitehorn #define INTPTR_MIN INT64_MIN 140c3e289e1SNathan Whitehorn #define INTPTR_MAX INT64_MAX 141c3e289e1SNathan Whitehorn #define UINTPTR_MAX UINT64_MAX 142c3e289e1SNathan Whitehorn #else 14349545b38SMike Barcroft #define INTPTR_MIN INT32_MIN 14449545b38SMike Barcroft #define INTPTR_MAX INT32_MAX 14549545b38SMike Barcroft #define UINTPTR_MAX UINT32_MAX 146c3e289e1SNathan Whitehorn #endif 14749545b38SMike Barcroft 14849545b38SMike Barcroft /* 14949545b38SMike Barcroft * ISO/IEC 9899:1999 15049545b38SMike Barcroft * 7.18.2.5 Limits of greatest-width integer types 15149545b38SMike Barcroft */ 15249545b38SMike Barcroft #define INTMAX_MIN INT64_MIN 15349545b38SMike Barcroft #define INTMAX_MAX INT64_MAX 15449545b38SMike Barcroft #define UINTMAX_MAX UINT64_MAX 15549545b38SMike Barcroft 15649545b38SMike Barcroft /* 15749545b38SMike Barcroft * ISO/IEC 9899:1999 15849545b38SMike Barcroft * 7.18.3 Limits of other integer types 15949545b38SMike Barcroft */ 160*a56e818fSTijl Coosemans #ifdef __LP64__ 161c3e289e1SNathan Whitehorn /* Limits of ptrdiff_t. */ 162c3e289e1SNathan Whitehorn #define PTRDIFF_MIN INT64_MIN 163c3e289e1SNathan Whitehorn #define PTRDIFF_MAX INT64_MAX 164c3e289e1SNathan Whitehorn 165c3e289e1SNathan Whitehorn /* Limits of sig_atomic_t. */ 166c3e289e1SNathan Whitehorn #define SIG_ATOMIC_MIN INT64_MIN 167c3e289e1SNathan Whitehorn #define SIG_ATOMIC_MAX INT64_MAX 168c3e289e1SNathan Whitehorn 169c3e289e1SNathan Whitehorn /* Limit of size_t. */ 170c3e289e1SNathan Whitehorn #define SIZE_MAX UINT64_MAX 171c3e289e1SNathan Whitehorn #else 17249545b38SMike Barcroft /* Limits of ptrdiff_t. */ 17349545b38SMike Barcroft #define PTRDIFF_MIN INT32_MIN 17449545b38SMike Barcroft #define PTRDIFF_MAX INT32_MAX 17549545b38SMike Barcroft 17649545b38SMike Barcroft /* Limits of sig_atomic_t. */ 17749545b38SMike Barcroft #define SIG_ATOMIC_MIN INT32_MIN 17849545b38SMike Barcroft #define SIG_ATOMIC_MAX INT32_MAX 17949545b38SMike Barcroft 18049545b38SMike Barcroft /* Limit of size_t. */ 18149545b38SMike Barcroft #define SIZE_MAX UINT32_MAX 182c3e289e1SNathan Whitehorn #endif 18349545b38SMike Barcroft 18449545b38SMike Barcroft #ifndef WCHAR_MIN /* Also possibly defined in <wchar.h> */ 18549545b38SMike Barcroft /* Limits of wchar_t. */ 18649545b38SMike Barcroft #define WCHAR_MIN INT32_MIN 18749545b38SMike Barcroft #define WCHAR_MAX INT32_MAX 188b1aa0ba5SStefan Farfeleder #endif 18949545b38SMike Barcroft 19049545b38SMike Barcroft /* Limits of wint_t. */ 19149545b38SMike Barcroft #define WINT_MIN INT32_MIN 19249545b38SMike Barcroft #define WINT_MAX INT32_MAX 19349545b38SMike Barcroft 19449545b38SMike Barcroft #endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */ 19549545b38SMike Barcroft 19649545b38SMike Barcroft #endif /* !_MACHINE__STDINT_H_ */ 197