xref: /minix3/external/bsd/llvm/dist/clang/lib/Headers/stdint.h (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc /*===---- stdint.h - Standard header for sized integer types --------------===*\
2f4a2713aSLionel Sambuc  *
3f4a2713aSLionel Sambuc  * Copyright (c) 2009 Chris Lattner
4f4a2713aSLionel Sambuc  *
5f4a2713aSLionel Sambuc  * Permission is hereby granted, free of charge, to any person obtaining a copy
6f4a2713aSLionel Sambuc  * of this software and associated documentation files (the "Software"), to deal
7f4a2713aSLionel Sambuc  * in the Software without restriction, including without limitation the rights
8f4a2713aSLionel Sambuc  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9f4a2713aSLionel Sambuc  * copies of the Software, and to permit persons to whom the Software is
10f4a2713aSLionel Sambuc  * furnished to do so, subject to the following conditions:
11f4a2713aSLionel Sambuc  *
12f4a2713aSLionel Sambuc  * The above copyright notice and this permission notice shall be included in
13f4a2713aSLionel Sambuc  * all copies or substantial portions of the Software.
14f4a2713aSLionel Sambuc  *
15f4a2713aSLionel Sambuc  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16f4a2713aSLionel Sambuc  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17f4a2713aSLionel Sambuc  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18f4a2713aSLionel Sambuc  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19f4a2713aSLionel Sambuc  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20f4a2713aSLionel Sambuc  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21f4a2713aSLionel Sambuc  * THE SOFTWARE.
22f4a2713aSLionel Sambuc  *
23f4a2713aSLionel Sambuc \*===----------------------------------------------------------------------===*/
24f4a2713aSLionel Sambuc 
25f4a2713aSLionel Sambuc #ifndef __CLANG_STDINT_H
26f4a2713aSLionel Sambuc #define __CLANG_STDINT_H
27f4a2713aSLionel Sambuc 
28f4a2713aSLionel Sambuc /* If we're hosted, fall back to the system's stdint.h, which might have
29f4a2713aSLionel Sambuc  * additional definitions.
30f4a2713aSLionel Sambuc  */
31*0a6a1f1dSLionel Sambuc #if __STDC_HOSTED__ && __has_include_next(<stdint.h>)
32f4a2713aSLionel Sambuc 
33f4a2713aSLionel Sambuc // C99 7.18.3 Limits of other integer types
34f4a2713aSLionel Sambuc //
35f4a2713aSLionel Sambuc //  Footnote 219, 220: C++ implementations should define these macros only when
36f4a2713aSLionel Sambuc //  __STDC_LIMIT_MACROS is defined before <stdint.h> is included.
37f4a2713aSLionel Sambuc //
38f4a2713aSLionel Sambuc //  Footnote 222: C++ implementations should define these macros only when
39f4a2713aSLionel Sambuc //  __STDC_CONSTANT_MACROS is defined before <stdint.h> is included.
40f4a2713aSLionel Sambuc //
41f4a2713aSLionel Sambuc // C++11 [cstdint.syn]p2:
42f4a2713aSLionel Sambuc //
43f4a2713aSLionel Sambuc //  The macros defined by <cstdint> are provided unconditionally. In particular,
44f4a2713aSLionel Sambuc //  the symbols __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS (mentioned in
45f4a2713aSLionel Sambuc //  footnotes 219, 220, and 222 in the C standard) play no role in C++.
46f4a2713aSLionel Sambuc //
47f4a2713aSLionel Sambuc // C11 removed the problematic footnotes.
48f4a2713aSLionel Sambuc //
49f4a2713aSLionel Sambuc // Work around this inconsistency by always defining those macros in C++ mode,
50f4a2713aSLionel Sambuc // so that a C library implementation which follows the C99 standard can be
51f4a2713aSLionel Sambuc // used in C++.
52f4a2713aSLionel Sambuc # ifdef __cplusplus
53f4a2713aSLionel Sambuc #  if !defined(__STDC_LIMIT_MACROS)
54f4a2713aSLionel Sambuc #   define __STDC_LIMIT_MACROS
55f4a2713aSLionel Sambuc #   define __STDC_LIMIT_MACROS_DEFINED_BY_CLANG
56f4a2713aSLionel Sambuc #  endif
57f4a2713aSLionel Sambuc #  if !defined(__STDC_CONSTANT_MACROS)
58f4a2713aSLionel Sambuc #   define __STDC_CONSTANT_MACROS
59f4a2713aSLionel Sambuc #   define __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG
60f4a2713aSLionel Sambuc #  endif
61f4a2713aSLionel Sambuc # endif
62f4a2713aSLionel Sambuc 
63f4a2713aSLionel Sambuc # include_next <stdint.h>
64f4a2713aSLionel Sambuc 
65f4a2713aSLionel Sambuc # ifdef __STDC_LIMIT_MACROS_DEFINED_BY_CLANG
66f4a2713aSLionel Sambuc #  undef __STDC_LIMIT_MACROS
67f4a2713aSLionel Sambuc #  undef __STDC_LIMIT_MACROS_DEFINED_BY_CLANG
68f4a2713aSLionel Sambuc # endif
69f4a2713aSLionel Sambuc # ifdef __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG
70f4a2713aSLionel Sambuc #  undef __STDC_CONSTANT_MACROS
71f4a2713aSLionel Sambuc #  undef __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG
72f4a2713aSLionel Sambuc # endif
73f4a2713aSLionel Sambuc 
74f4a2713aSLionel Sambuc #else
75f4a2713aSLionel Sambuc 
76f4a2713aSLionel Sambuc /* C99 7.18.1.1 Exact-width integer types.
77f4a2713aSLionel Sambuc  * C99 7.18.1.2 Minimum-width integer types.
78f4a2713aSLionel Sambuc  * C99 7.18.1.3 Fastest minimum-width integer types.
79f4a2713aSLionel Sambuc  *
80f4a2713aSLionel Sambuc  * The standard requires that exact-width type be defined for 8-, 16-, 32-, and
81f4a2713aSLionel Sambuc  * 64-bit types if they are implemented. Other exact width types are optional.
82f4a2713aSLionel Sambuc  * This implementation defines an exact-width types for every integer width
83f4a2713aSLionel Sambuc  * that is represented in the standard integer types.
84f4a2713aSLionel Sambuc  *
85f4a2713aSLionel Sambuc  * The standard also requires minimum-width types be defined for 8-, 16-, 32-,
86f4a2713aSLionel Sambuc  * and 64-bit widths regardless of whether there are corresponding exact-width
87f4a2713aSLionel Sambuc  * types.
88f4a2713aSLionel Sambuc  *
89f4a2713aSLionel Sambuc  * To accommodate targets that are missing types that are exactly 8, 16, 32, or
90f4a2713aSLionel Sambuc  * 64 bits wide, this implementation takes an approach of cascading
91f4a2713aSLionel Sambuc  * redefintions, redefining __int_leastN_t to successively smaller exact-width
92f4a2713aSLionel Sambuc  * types. It is therefore important that the types are defined in order of
93f4a2713aSLionel Sambuc  * descending widths.
94f4a2713aSLionel Sambuc  *
95f4a2713aSLionel Sambuc  * We currently assume that the minimum-width types and the fastest
96f4a2713aSLionel Sambuc  * minimum-width types are the same. This is allowed by the standard, but is
97f4a2713aSLionel Sambuc  * suboptimal.
98f4a2713aSLionel Sambuc  *
99f4a2713aSLionel Sambuc  * In violation of the standard, some targets do not implement a type that is
100f4a2713aSLionel Sambuc  * wide enough to represent all of the required widths (8-, 16-, 32-, 64-bit).
101f4a2713aSLionel Sambuc  * To accommodate these targets, a required minimum-width type is only
102f4a2713aSLionel Sambuc  * defined if there exists an exact-width type of equal or greater width.
103f4a2713aSLionel Sambuc  */
104f4a2713aSLionel Sambuc 
105f4a2713aSLionel Sambuc #ifdef __INT64_TYPE__
106f4a2713aSLionel Sambuc # ifndef __int8_t_defined /* glibc sys/types.h also defines int64_t*/
107*0a6a1f1dSLionel Sambuc typedef __INT64_TYPE__ int64_t;
108f4a2713aSLionel Sambuc # endif /* __int8_t_defined */
109*0a6a1f1dSLionel Sambuc typedef __UINT64_TYPE__ uint64_t;
110f4a2713aSLionel Sambuc # define __int_least64_t int64_t
111f4a2713aSLionel Sambuc # define __uint_least64_t uint64_t
112f4a2713aSLionel Sambuc # define __int_least32_t int64_t
113f4a2713aSLionel Sambuc # define __uint_least32_t uint64_t
114f4a2713aSLionel Sambuc # define __int_least16_t int64_t
115f4a2713aSLionel Sambuc # define __uint_least16_t uint64_t
116f4a2713aSLionel Sambuc # define __int_least8_t int64_t
117f4a2713aSLionel Sambuc # define __uint_least8_t uint64_t
118f4a2713aSLionel Sambuc #endif /* __INT64_TYPE__ */
119f4a2713aSLionel Sambuc 
120f4a2713aSLionel Sambuc #ifdef __int_least64_t
121f4a2713aSLionel Sambuc typedef __int_least64_t int_least64_t;
122f4a2713aSLionel Sambuc typedef __uint_least64_t uint_least64_t;
123f4a2713aSLionel Sambuc typedef __int_least64_t int_fast64_t;
124f4a2713aSLionel Sambuc typedef __uint_least64_t uint_fast64_t;
125f4a2713aSLionel Sambuc #endif /* __int_least64_t */
126f4a2713aSLionel Sambuc 
127f4a2713aSLionel Sambuc #ifdef __INT56_TYPE__
128*0a6a1f1dSLionel Sambuc typedef __INT56_TYPE__ int56_t;
129*0a6a1f1dSLionel Sambuc typedef __UINT56_TYPE__ uint56_t;
130f4a2713aSLionel Sambuc typedef int56_t int_least56_t;
131f4a2713aSLionel Sambuc typedef uint56_t uint_least56_t;
132f4a2713aSLionel Sambuc typedef int56_t int_fast56_t;
133f4a2713aSLionel Sambuc typedef uint56_t uint_fast56_t;
134f4a2713aSLionel Sambuc # define __int_least32_t int56_t
135f4a2713aSLionel Sambuc # define __uint_least32_t uint56_t
136f4a2713aSLionel Sambuc # define __int_least16_t int56_t
137f4a2713aSLionel Sambuc # define __uint_least16_t uint56_t
138f4a2713aSLionel Sambuc # define __int_least8_t int56_t
139f4a2713aSLionel Sambuc # define __uint_least8_t uint56_t
140f4a2713aSLionel Sambuc #endif /* __INT56_TYPE__ */
141f4a2713aSLionel Sambuc 
142f4a2713aSLionel Sambuc 
143f4a2713aSLionel Sambuc #ifdef __INT48_TYPE__
144*0a6a1f1dSLionel Sambuc typedef __INT48_TYPE__ int48_t;
145*0a6a1f1dSLionel Sambuc typedef __UINT48_TYPE__ uint48_t;
146f4a2713aSLionel Sambuc typedef int48_t int_least48_t;
147f4a2713aSLionel Sambuc typedef uint48_t uint_least48_t;
148f4a2713aSLionel Sambuc typedef int48_t int_fast48_t;
149f4a2713aSLionel Sambuc typedef uint48_t uint_fast48_t;
150f4a2713aSLionel Sambuc # define __int_least32_t int48_t
151f4a2713aSLionel Sambuc # define __uint_least32_t uint48_t
152f4a2713aSLionel Sambuc # define __int_least16_t int48_t
153f4a2713aSLionel Sambuc # define __uint_least16_t uint48_t
154f4a2713aSLionel Sambuc # define __int_least8_t int48_t
155f4a2713aSLionel Sambuc # define __uint_least8_t uint48_t
156f4a2713aSLionel Sambuc #endif /* __INT48_TYPE__ */
157f4a2713aSLionel Sambuc 
158f4a2713aSLionel Sambuc 
159f4a2713aSLionel Sambuc #ifdef __INT40_TYPE__
160*0a6a1f1dSLionel Sambuc typedef __INT40_TYPE__ int40_t;
161*0a6a1f1dSLionel Sambuc typedef __UINT40_TYPE__ uint40_t;
162f4a2713aSLionel Sambuc typedef int40_t int_least40_t;
163f4a2713aSLionel Sambuc typedef uint40_t uint_least40_t;
164f4a2713aSLionel Sambuc typedef int40_t int_fast40_t;
165f4a2713aSLionel Sambuc typedef uint40_t uint_fast40_t;
166f4a2713aSLionel Sambuc # define __int_least32_t int40_t
167f4a2713aSLionel Sambuc # define __uint_least32_t uint40_t
168f4a2713aSLionel Sambuc # define __int_least16_t int40_t
169f4a2713aSLionel Sambuc # define __uint_least16_t uint40_t
170f4a2713aSLionel Sambuc # define __int_least8_t int40_t
171f4a2713aSLionel Sambuc # define __uint_least8_t uint40_t
172f4a2713aSLionel Sambuc #endif /* __INT40_TYPE__ */
173f4a2713aSLionel Sambuc 
174f4a2713aSLionel Sambuc 
175f4a2713aSLionel Sambuc #ifdef __INT32_TYPE__
176f4a2713aSLionel Sambuc 
177f4a2713aSLionel Sambuc # ifndef __int8_t_defined /* glibc sys/types.h also defines int32_t*/
178*0a6a1f1dSLionel Sambuc typedef __INT32_TYPE__ int32_t;
179f4a2713aSLionel Sambuc # endif /* __int8_t_defined */
180f4a2713aSLionel Sambuc 
181f4a2713aSLionel Sambuc # ifndef __uint32_t_defined  /* more glibc compatibility */
182f4a2713aSLionel Sambuc # define __uint32_t_defined
183*0a6a1f1dSLionel Sambuc typedef __UINT32_TYPE__ uint32_t;
184f4a2713aSLionel Sambuc # endif /* __uint32_t_defined */
185f4a2713aSLionel Sambuc 
186f4a2713aSLionel Sambuc # define __int_least32_t int32_t
187f4a2713aSLionel Sambuc # define __uint_least32_t uint32_t
188f4a2713aSLionel Sambuc # define __int_least16_t int32_t
189f4a2713aSLionel Sambuc # define __uint_least16_t uint32_t
190f4a2713aSLionel Sambuc # define __int_least8_t int32_t
191f4a2713aSLionel Sambuc # define __uint_least8_t uint32_t
192f4a2713aSLionel Sambuc #endif /* __INT32_TYPE__ */
193f4a2713aSLionel Sambuc 
194f4a2713aSLionel Sambuc #ifdef __int_least32_t
195f4a2713aSLionel Sambuc typedef __int_least32_t int_least32_t;
196f4a2713aSLionel Sambuc typedef __uint_least32_t uint_least32_t;
197f4a2713aSLionel Sambuc typedef __int_least32_t int_fast32_t;
198f4a2713aSLionel Sambuc typedef __uint_least32_t uint_fast32_t;
199f4a2713aSLionel Sambuc #endif /* __int_least32_t */
200f4a2713aSLionel Sambuc 
201f4a2713aSLionel Sambuc #ifdef __INT24_TYPE__
202*0a6a1f1dSLionel Sambuc typedef __INT24_TYPE__ int24_t;
203*0a6a1f1dSLionel Sambuc typedef __UINT24_TYPE__ uint24_t;
204f4a2713aSLionel Sambuc typedef int24_t int_least24_t;
205f4a2713aSLionel Sambuc typedef uint24_t uint_least24_t;
206f4a2713aSLionel Sambuc typedef int24_t int_fast24_t;
207f4a2713aSLionel Sambuc typedef uint24_t uint_fast24_t;
208f4a2713aSLionel Sambuc # define __int_least16_t int24_t
209f4a2713aSLionel Sambuc # define __uint_least16_t uint24_t
210f4a2713aSLionel Sambuc # define __int_least8_t int24_t
211f4a2713aSLionel Sambuc # define __uint_least8_t uint24_t
212f4a2713aSLionel Sambuc #endif /* __INT24_TYPE__ */
213f4a2713aSLionel Sambuc 
214f4a2713aSLionel Sambuc #ifdef __INT16_TYPE__
215f4a2713aSLionel Sambuc #ifndef __int8_t_defined /* glibc sys/types.h also defines int16_t*/
216*0a6a1f1dSLionel Sambuc typedef __INT16_TYPE__ int16_t;
217f4a2713aSLionel Sambuc #endif /* __int8_t_defined */
218*0a6a1f1dSLionel Sambuc typedef __UINT16_TYPE__ uint16_t;
219f4a2713aSLionel Sambuc # define __int_least16_t int16_t
220f4a2713aSLionel Sambuc # define __uint_least16_t uint16_t
221f4a2713aSLionel Sambuc # define __int_least8_t int16_t
222f4a2713aSLionel Sambuc # define __uint_least8_t uint16_t
223f4a2713aSLionel Sambuc #endif /* __INT16_TYPE__ */
224f4a2713aSLionel Sambuc 
225f4a2713aSLionel Sambuc #ifdef __int_least16_t
226f4a2713aSLionel Sambuc typedef __int_least16_t int_least16_t;
227f4a2713aSLionel Sambuc typedef __uint_least16_t uint_least16_t;
228f4a2713aSLionel Sambuc typedef __int_least16_t int_fast16_t;
229f4a2713aSLionel Sambuc typedef __uint_least16_t uint_fast16_t;
230f4a2713aSLionel Sambuc #endif /* __int_least16_t */
231f4a2713aSLionel Sambuc 
232f4a2713aSLionel Sambuc 
233f4a2713aSLionel Sambuc #ifdef __INT8_TYPE__
234f4a2713aSLionel Sambuc #ifndef __int8_t_defined  /* glibc sys/types.h also defines int8_t*/
235*0a6a1f1dSLionel Sambuc typedef __INT8_TYPE__ int8_t;
236f4a2713aSLionel Sambuc #endif /* __int8_t_defined */
237*0a6a1f1dSLionel Sambuc typedef __UINT8_TYPE__ uint8_t;
238f4a2713aSLionel Sambuc # define __int_least8_t int8_t
239f4a2713aSLionel Sambuc # define __uint_least8_t uint8_t
240f4a2713aSLionel Sambuc #endif /* __INT8_TYPE__ */
241f4a2713aSLionel Sambuc 
242f4a2713aSLionel Sambuc #ifdef __int_least8_t
243f4a2713aSLionel Sambuc typedef __int_least8_t int_least8_t;
244f4a2713aSLionel Sambuc typedef __uint_least8_t uint_least8_t;
245f4a2713aSLionel Sambuc typedef __int_least8_t int_fast8_t;
246f4a2713aSLionel Sambuc typedef __uint_least8_t uint_fast8_t;
247f4a2713aSLionel Sambuc #endif /* __int_least8_t */
248f4a2713aSLionel Sambuc 
249f4a2713aSLionel Sambuc /* prevent glibc sys/types.h from defining conflicting types */
250f4a2713aSLionel Sambuc #ifndef __int8_t_defined
251f4a2713aSLionel Sambuc # define __int8_t_defined
252f4a2713aSLionel Sambuc #endif /* __int8_t_defined */
253f4a2713aSLionel Sambuc 
254f4a2713aSLionel Sambuc /* C99 7.18.1.4 Integer types capable of holding object pointers.
255f4a2713aSLionel Sambuc  */
256f4a2713aSLionel Sambuc #define __stdint_join3(a,b,c) a ## b ## c
257f4a2713aSLionel Sambuc 
258f4a2713aSLionel Sambuc #define  __intn_t(n) __stdint_join3( int, n, _t)
259f4a2713aSLionel Sambuc #define __uintn_t(n) __stdint_join3(uint, n, _t)
260f4a2713aSLionel Sambuc 
261f4a2713aSLionel Sambuc #ifndef _INTPTR_T
262f4a2713aSLionel Sambuc #ifndef __intptr_t_defined
263f4a2713aSLionel Sambuc typedef  __intn_t(__INTPTR_WIDTH__)  intptr_t;
264f4a2713aSLionel Sambuc #define __intptr_t_defined
265f4a2713aSLionel Sambuc #define _INTPTR_T
266f4a2713aSLionel Sambuc #endif
267f4a2713aSLionel Sambuc #endif
268f4a2713aSLionel Sambuc 
269f4a2713aSLionel Sambuc #ifndef _UINTPTR_T
270f4a2713aSLionel Sambuc typedef __uintn_t(__INTPTR_WIDTH__) uintptr_t;
271f4a2713aSLionel Sambuc #define _UINTPTR_T
272f4a2713aSLionel Sambuc #endif
273f4a2713aSLionel Sambuc 
274f4a2713aSLionel Sambuc /* C99 7.18.1.5 Greatest-width integer types.
275f4a2713aSLionel Sambuc  */
276f4a2713aSLionel Sambuc typedef __INTMAX_TYPE__  intmax_t;
277f4a2713aSLionel Sambuc typedef __UINTMAX_TYPE__ uintmax_t;
278f4a2713aSLionel Sambuc 
279f4a2713aSLionel Sambuc /* C99 7.18.4 Macros for minimum-width integer constants.
280f4a2713aSLionel Sambuc  *
281f4a2713aSLionel Sambuc  * The standard requires that integer constant macros be defined for all the
282f4a2713aSLionel Sambuc  * minimum-width types defined above. As 8-, 16-, 32-, and 64-bit minimum-width
283f4a2713aSLionel Sambuc  * types are required, the corresponding integer constant macros are defined
284f4a2713aSLionel Sambuc  * here. This implementation also defines minimum-width types for every other
285f4a2713aSLionel Sambuc  * integer width that the target implements, so corresponding macros are
286f4a2713aSLionel Sambuc  * defined below, too.
287f4a2713aSLionel Sambuc  *
288f4a2713aSLionel Sambuc  * These macros are defined using the same successive-shrinking approach as
289f4a2713aSLionel Sambuc  * the type definitions above. It is likewise important that macros are defined
290f4a2713aSLionel Sambuc  * in order of decending width.
291f4a2713aSLionel Sambuc  *
292f4a2713aSLionel Sambuc  * Note that C++ should not check __STDC_CONSTANT_MACROS here, contrary to the
293f4a2713aSLionel Sambuc  * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]).
294f4a2713aSLionel Sambuc  */
295f4a2713aSLionel Sambuc 
296f4a2713aSLionel Sambuc #define __int_c_join(a, b) a ## b
297f4a2713aSLionel Sambuc #define __int_c(v, suffix) __int_c_join(v, suffix)
298f4a2713aSLionel Sambuc #define __uint_c(v, suffix) __int_c_join(v##U, suffix)
299f4a2713aSLionel Sambuc 
300f4a2713aSLionel Sambuc 
301f4a2713aSLionel Sambuc #ifdef __INT64_TYPE__
302f4a2713aSLionel Sambuc # ifdef __INT64_C_SUFFIX__
303f4a2713aSLionel Sambuc #  define __int64_c_suffix __INT64_C_SUFFIX__
304f4a2713aSLionel Sambuc #  define __int32_c_suffix __INT64_C_SUFFIX__
305f4a2713aSLionel Sambuc #  define __int16_c_suffix __INT64_C_SUFFIX__
306f4a2713aSLionel Sambuc #  define  __int8_c_suffix __INT64_C_SUFFIX__
307f4a2713aSLionel Sambuc # else
308f4a2713aSLionel Sambuc #  undef __int64_c_suffix
309f4a2713aSLionel Sambuc #  undef __int32_c_suffix
310f4a2713aSLionel Sambuc #  undef __int16_c_suffix
311f4a2713aSLionel Sambuc #  undef  __int8_c_suffix
312f4a2713aSLionel Sambuc # endif /* __INT64_C_SUFFIX__ */
313f4a2713aSLionel Sambuc #endif /* __INT64_TYPE__ */
314f4a2713aSLionel Sambuc 
315f4a2713aSLionel Sambuc #ifdef __int_least64_t
316f4a2713aSLionel Sambuc # ifdef __int64_c_suffix
317f4a2713aSLionel Sambuc #  define INT64_C(v) __int_c(v, __int64_c_suffix)
318f4a2713aSLionel Sambuc #  define UINT64_C(v) __uint_c(v, __int64_c_suffix)
319f4a2713aSLionel Sambuc # else
320f4a2713aSLionel Sambuc #  define INT64_C(v) v
321f4a2713aSLionel Sambuc #  define UINT64_C(v) v ## U
322f4a2713aSLionel Sambuc # endif /* __int64_c_suffix */
323f4a2713aSLionel Sambuc #endif /* __int_least64_t */
324f4a2713aSLionel Sambuc 
325f4a2713aSLionel Sambuc 
326f4a2713aSLionel Sambuc #ifdef __INT56_TYPE__
327f4a2713aSLionel Sambuc # ifdef __INT56_C_SUFFIX__
328f4a2713aSLionel Sambuc #  define INT56_C(v) __int_c(v, __INT56_C_SUFFIX__)
329f4a2713aSLionel Sambuc #  define UINT56_C(v) __uint_c(v, __INT56_C_SUFFIX__)
330f4a2713aSLionel Sambuc #  define __int32_c_suffix __INT56_C_SUFFIX__
331f4a2713aSLionel Sambuc #  define __int16_c_suffix __INT56_C_SUFFIX__
332f4a2713aSLionel Sambuc #  define __int8_c_suffix  __INT56_C_SUFFIX__
333f4a2713aSLionel Sambuc # else
334f4a2713aSLionel Sambuc #  define INT56_C(v) v
335f4a2713aSLionel Sambuc #  define UINT56_C(v) v ## U
336f4a2713aSLionel Sambuc #  undef __int32_c_suffix
337f4a2713aSLionel Sambuc #  undef __int16_c_suffix
338f4a2713aSLionel Sambuc #  undef  __int8_c_suffix
339f4a2713aSLionel Sambuc # endif /* __INT56_C_SUFFIX__ */
340f4a2713aSLionel Sambuc #endif /* __INT56_TYPE__ */
341f4a2713aSLionel Sambuc 
342f4a2713aSLionel Sambuc 
343f4a2713aSLionel Sambuc #ifdef __INT48_TYPE__
344f4a2713aSLionel Sambuc # ifdef __INT48_C_SUFFIX__
345f4a2713aSLionel Sambuc #  define INT48_C(v) __int_c(v, __INT48_C_SUFFIX__)
346f4a2713aSLionel Sambuc #  define UINT48_C(v) __uint_c(v, __INT48_C_SUFFIX__)
347f4a2713aSLionel Sambuc #  define __int32_c_suffix __INT48_C_SUFFIX__
348f4a2713aSLionel Sambuc #  define __int16_c_suffix __INT48_C_SUFFIX__
349f4a2713aSLionel Sambuc #  define __int8_c_suffix  __INT48_C_SUFFIX__
350f4a2713aSLionel Sambuc # else
351f4a2713aSLionel Sambuc #  define INT48_C(v) v
352f4a2713aSLionel Sambuc #  define UINT48_C(v) v ## U
353f4a2713aSLionel Sambuc #  undef __int32_c_suffix
354f4a2713aSLionel Sambuc #  undef __int16_c_suffix
355f4a2713aSLionel Sambuc #  undef  __int8_c_suffix
356f4a2713aSLionel Sambuc # endif /* __INT48_C_SUFFIX__ */
357f4a2713aSLionel Sambuc #endif /* __INT48_TYPE__ */
358f4a2713aSLionel Sambuc 
359f4a2713aSLionel Sambuc 
360f4a2713aSLionel Sambuc #ifdef __INT40_TYPE__
361f4a2713aSLionel Sambuc # ifdef __INT40_C_SUFFIX__
362f4a2713aSLionel Sambuc #  define INT40_C(v) __int_c(v, __INT40_C_SUFFIX__)
363f4a2713aSLionel Sambuc #  define UINT40_C(v) __uint_c(v, __INT40_C_SUFFIX__)
364f4a2713aSLionel Sambuc #  define __int32_c_suffix __INT40_C_SUFFIX__
365f4a2713aSLionel Sambuc #  define __int16_c_suffix __INT40_C_SUFFIX__
366f4a2713aSLionel Sambuc #  define __int8_c_suffix  __INT40_C_SUFFIX__
367f4a2713aSLionel Sambuc # else
368f4a2713aSLionel Sambuc #  define INT40_C(v) v
369f4a2713aSLionel Sambuc #  define UINT40_C(v) v ## U
370f4a2713aSLionel Sambuc #  undef __int32_c_suffix
371f4a2713aSLionel Sambuc #  undef __int16_c_suffix
372f4a2713aSLionel Sambuc #  undef  __int8_c_suffix
373f4a2713aSLionel Sambuc # endif /* __INT40_C_SUFFIX__ */
374f4a2713aSLionel Sambuc #endif /* __INT40_TYPE__ */
375f4a2713aSLionel Sambuc 
376f4a2713aSLionel Sambuc 
377f4a2713aSLionel Sambuc #ifdef __INT32_TYPE__
378f4a2713aSLionel Sambuc # ifdef __INT32_C_SUFFIX__
379f4a2713aSLionel Sambuc #  define __int32_c_suffix __INT32_C_SUFFIX__
380f4a2713aSLionel Sambuc #  define __int16_c_suffix __INT32_C_SUFFIX__
381f4a2713aSLionel Sambuc #  define __int8_c_suffix  __INT32_C_SUFFIX__
382f4a2713aSLionel Sambuc #else
383f4a2713aSLionel Sambuc #  undef __int32_c_suffix
384f4a2713aSLionel Sambuc #  undef __int16_c_suffix
385f4a2713aSLionel Sambuc #  undef  __int8_c_suffix
386f4a2713aSLionel Sambuc # endif /* __INT32_C_SUFFIX__ */
387f4a2713aSLionel Sambuc #endif /* __INT32_TYPE__ */
388f4a2713aSLionel Sambuc 
389f4a2713aSLionel Sambuc #ifdef __int_least32_t
390f4a2713aSLionel Sambuc # ifdef __int32_c_suffix
391f4a2713aSLionel Sambuc #  define INT32_C(v) __int_c(v, __int32_c_suffix)
392f4a2713aSLionel Sambuc #  define UINT32_C(v) __uint_c(v, __int32_c_suffix)
393f4a2713aSLionel Sambuc # else
394f4a2713aSLionel Sambuc #  define INT32_C(v) v
395f4a2713aSLionel Sambuc #  define UINT32_C(v) v ## U
396f4a2713aSLionel Sambuc # endif /* __int32_c_suffix */
397f4a2713aSLionel Sambuc #endif /* __int_least32_t */
398f4a2713aSLionel Sambuc 
399f4a2713aSLionel Sambuc 
400f4a2713aSLionel Sambuc #ifdef __INT24_TYPE__
401f4a2713aSLionel Sambuc # ifdef __INT24_C_SUFFIX__
402f4a2713aSLionel Sambuc #  define INT24_C(v) __int_c(v, __INT24_C_SUFFIX__)
403f4a2713aSLionel Sambuc #  define UINT24_C(v) __uint_c(v, __INT24_C_SUFFIX__)
404f4a2713aSLionel Sambuc #  define __int16_c_suffix __INT24_C_SUFFIX__
405f4a2713aSLionel Sambuc #  define __int8_c_suffix  __INT24_C_SUFFIX__
406f4a2713aSLionel Sambuc # else
407f4a2713aSLionel Sambuc #  define INT24_C(v) v
408f4a2713aSLionel Sambuc #  define UINT24_C(v) v ## U
409f4a2713aSLionel Sambuc #  undef __int16_c_suffix
410f4a2713aSLionel Sambuc #  undef  __int8_c_suffix
411f4a2713aSLionel Sambuc # endif /* __INT24_C_SUFFIX__ */
412f4a2713aSLionel Sambuc #endif /* __INT24_TYPE__ */
413f4a2713aSLionel Sambuc 
414f4a2713aSLionel Sambuc 
415f4a2713aSLionel Sambuc #ifdef __INT16_TYPE__
416f4a2713aSLionel Sambuc # ifdef __INT16_C_SUFFIX__
417f4a2713aSLionel Sambuc #  define __int16_c_suffix __INT16_C_SUFFIX__
418f4a2713aSLionel Sambuc #  define __int8_c_suffix  __INT16_C_SUFFIX__
419f4a2713aSLionel Sambuc #else
420f4a2713aSLionel Sambuc #  undef __int16_c_suffix
421f4a2713aSLionel Sambuc #  undef  __int8_c_suffix
422f4a2713aSLionel Sambuc # endif /* __INT16_C_SUFFIX__ */
423f4a2713aSLionel Sambuc #endif /* __INT16_TYPE__ */
424f4a2713aSLionel Sambuc 
425f4a2713aSLionel Sambuc #ifdef __int_least16_t
426f4a2713aSLionel Sambuc # ifdef __int16_c_suffix
427f4a2713aSLionel Sambuc #  define INT16_C(v) __int_c(v, __int16_c_suffix)
428f4a2713aSLionel Sambuc #  define UINT16_C(v) __uint_c(v, __int16_c_suffix)
429f4a2713aSLionel Sambuc # else
430f4a2713aSLionel Sambuc #  define INT16_C(v) v
431f4a2713aSLionel Sambuc #  define UINT16_C(v) v ## U
432f4a2713aSLionel Sambuc # endif /* __int16_c_suffix */
433f4a2713aSLionel Sambuc #endif /* __int_least16_t */
434f4a2713aSLionel Sambuc 
435f4a2713aSLionel Sambuc 
436f4a2713aSLionel Sambuc #ifdef __INT8_TYPE__
437f4a2713aSLionel Sambuc # ifdef __INT8_C_SUFFIX__
438f4a2713aSLionel Sambuc #  define __int8_c_suffix __INT8_C_SUFFIX__
439f4a2713aSLionel Sambuc #else
440f4a2713aSLionel Sambuc #  undef  __int8_c_suffix
441f4a2713aSLionel Sambuc # endif /* __INT8_C_SUFFIX__ */
442f4a2713aSLionel Sambuc #endif /* __INT8_TYPE__ */
443f4a2713aSLionel Sambuc 
444f4a2713aSLionel Sambuc #ifdef __int_least8_t
445f4a2713aSLionel Sambuc # ifdef __int8_c_suffix
446f4a2713aSLionel Sambuc #  define INT8_C(v) __int_c(v, __int8_c_suffix)
447f4a2713aSLionel Sambuc #  define UINT8_C(v) __uint_c(v, __int8_c_suffix)
448f4a2713aSLionel Sambuc # else
449f4a2713aSLionel Sambuc #  define INT8_C(v) v
450f4a2713aSLionel Sambuc #  define UINT8_C(v) v ## U
451f4a2713aSLionel Sambuc # endif /* __int8_c_suffix */
452f4a2713aSLionel Sambuc #endif /* __int_least8_t */
453f4a2713aSLionel Sambuc 
454f4a2713aSLionel Sambuc 
455f4a2713aSLionel Sambuc /* C99 7.18.2.1 Limits of exact-width integer types.
456f4a2713aSLionel Sambuc  * C99 7.18.2.2 Limits of minimum-width integer types.
457f4a2713aSLionel Sambuc  * C99 7.18.2.3 Limits of fastest minimum-width integer types.
458f4a2713aSLionel Sambuc  *
459f4a2713aSLionel Sambuc  * The presence of limit macros are completely optional in C99.  This
460f4a2713aSLionel Sambuc  * implementation defines limits for all of the types (exact- and
461f4a2713aSLionel Sambuc  * minimum-width) that it defines above, using the limits of the minimum-width
462f4a2713aSLionel Sambuc  * type for any types that do not have exact-width representations.
463f4a2713aSLionel Sambuc  *
464f4a2713aSLionel Sambuc  * As in the type definitions, this section takes an approach of
465f4a2713aSLionel Sambuc  * successive-shrinking to determine which limits to use for the standard (8,
466f4a2713aSLionel Sambuc  * 16, 32, 64) bit widths when they don't have exact representations. It is
467f4a2713aSLionel Sambuc  * therefore important that the defintions be kept in order of decending
468f4a2713aSLionel Sambuc  * widths.
469f4a2713aSLionel Sambuc  *
470f4a2713aSLionel Sambuc  * Note that C++ should not check __STDC_LIMIT_MACROS here, contrary to the
471f4a2713aSLionel Sambuc  * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]).
472f4a2713aSLionel Sambuc  */
473f4a2713aSLionel Sambuc 
474f4a2713aSLionel Sambuc #ifdef __INT64_TYPE__
475f4a2713aSLionel Sambuc # define INT64_MAX           INT64_C( 9223372036854775807)
476f4a2713aSLionel Sambuc # define INT64_MIN         (-INT64_C( 9223372036854775807)-1)
477f4a2713aSLionel Sambuc # define UINT64_MAX         UINT64_C(18446744073709551615)
478f4a2713aSLionel Sambuc # define __INT_LEAST64_MIN   INT64_MIN
479f4a2713aSLionel Sambuc # define __INT_LEAST64_MAX   INT64_MAX
480f4a2713aSLionel Sambuc # define __UINT_LEAST64_MAX UINT64_MAX
481f4a2713aSLionel Sambuc # define __INT_LEAST32_MIN   INT64_MIN
482f4a2713aSLionel Sambuc # define __INT_LEAST32_MAX   INT64_MAX
483f4a2713aSLionel Sambuc # define __UINT_LEAST32_MAX UINT64_MAX
484f4a2713aSLionel Sambuc # define __INT_LEAST16_MIN   INT64_MIN
485f4a2713aSLionel Sambuc # define __INT_LEAST16_MAX   INT64_MAX
486f4a2713aSLionel Sambuc # define __UINT_LEAST16_MAX UINT64_MAX
487f4a2713aSLionel Sambuc # define __INT_LEAST8_MIN    INT64_MIN
488f4a2713aSLionel Sambuc # define __INT_LEAST8_MAX    INT64_MAX
489f4a2713aSLionel Sambuc # define __UINT_LEAST8_MAX  UINT64_MAX
490f4a2713aSLionel Sambuc #endif /* __INT64_TYPE__ */
491f4a2713aSLionel Sambuc 
492f4a2713aSLionel Sambuc #ifdef __INT_LEAST64_MIN
493f4a2713aSLionel Sambuc # define INT_LEAST64_MIN   __INT_LEAST64_MIN
494f4a2713aSLionel Sambuc # define INT_LEAST64_MAX   __INT_LEAST64_MAX
495f4a2713aSLionel Sambuc # define UINT_LEAST64_MAX __UINT_LEAST64_MAX
496f4a2713aSLionel Sambuc # define INT_FAST64_MIN    __INT_LEAST64_MIN
497f4a2713aSLionel Sambuc # define INT_FAST64_MAX    __INT_LEAST64_MAX
498f4a2713aSLionel Sambuc # define UINT_FAST64_MAX  __UINT_LEAST64_MAX
499f4a2713aSLionel Sambuc #endif /* __INT_LEAST64_MIN */
500f4a2713aSLionel Sambuc 
501f4a2713aSLionel Sambuc 
502f4a2713aSLionel Sambuc #ifdef __INT56_TYPE__
503f4a2713aSLionel Sambuc # define INT56_MAX           INT56_C(36028797018963967)
504f4a2713aSLionel Sambuc # define INT56_MIN         (-INT56_C(36028797018963967)-1)
505f4a2713aSLionel Sambuc # define UINT56_MAX         UINT56_C(72057594037927935)
506f4a2713aSLionel Sambuc # define INT_LEAST56_MIN     INT56_MIN
507f4a2713aSLionel Sambuc # define INT_LEAST56_MAX     INT56_MAX
508f4a2713aSLionel Sambuc # define UINT_LEAST56_MAX   UINT56_MAX
509f4a2713aSLionel Sambuc # define INT_FAST56_MIN      INT56_MIN
510f4a2713aSLionel Sambuc # define INT_FAST56_MAX      INT56_MAX
511f4a2713aSLionel Sambuc # define UINT_FAST56_MAX    UINT56_MAX
512f4a2713aSLionel Sambuc # define __INT_LEAST32_MIN   INT56_MIN
513f4a2713aSLionel Sambuc # define __INT_LEAST32_MAX   INT56_MAX
514f4a2713aSLionel Sambuc # define __UINT_LEAST32_MAX UINT56_MAX
515f4a2713aSLionel Sambuc # define __INT_LEAST16_MIN   INT56_MIN
516f4a2713aSLionel Sambuc # define __INT_LEAST16_MAX   INT56_MAX
517f4a2713aSLionel Sambuc # define __UINT_LEAST16_MAX UINT56_MAX
518f4a2713aSLionel Sambuc # define __INT_LEAST8_MIN    INT56_MIN
519f4a2713aSLionel Sambuc # define __INT_LEAST8_MAX    INT56_MAX
520f4a2713aSLionel Sambuc # define __UINT_LEAST8_MAX  UINT56_MAX
521f4a2713aSLionel Sambuc #endif /* __INT56_TYPE__ */
522f4a2713aSLionel Sambuc 
523f4a2713aSLionel Sambuc 
524f4a2713aSLionel Sambuc #ifdef __INT48_TYPE__
525f4a2713aSLionel Sambuc # define INT48_MAX           INT48_C(140737488355327)
526f4a2713aSLionel Sambuc # define INT48_MIN         (-INT48_C(140737488355327)-1)
527f4a2713aSLionel Sambuc # define UINT48_MAX         UINT48_C(281474976710655)
528f4a2713aSLionel Sambuc # define INT_LEAST48_MIN     INT48_MIN
529f4a2713aSLionel Sambuc # define INT_LEAST48_MAX     INT48_MAX
530f4a2713aSLionel Sambuc # define UINT_LEAST48_MAX   UINT48_MAX
531f4a2713aSLionel Sambuc # define INT_FAST48_MIN      INT48_MIN
532f4a2713aSLionel Sambuc # define INT_FAST48_MAX      INT48_MAX
533f4a2713aSLionel Sambuc # define UINT_FAST48_MAX    UINT48_MAX
534f4a2713aSLionel Sambuc # define __INT_LEAST32_MIN   INT48_MIN
535f4a2713aSLionel Sambuc # define __INT_LEAST32_MAX   INT48_MAX
536f4a2713aSLionel Sambuc # define __UINT_LEAST32_MAX UINT48_MAX
537f4a2713aSLionel Sambuc # define __INT_LEAST16_MIN   INT48_MIN
538f4a2713aSLionel Sambuc # define __INT_LEAST16_MAX   INT48_MAX
539f4a2713aSLionel Sambuc # define __UINT_LEAST16_MAX UINT48_MAX
540f4a2713aSLionel Sambuc # define __INT_LEAST8_MIN    INT48_MIN
541f4a2713aSLionel Sambuc # define __INT_LEAST8_MAX    INT48_MAX
542f4a2713aSLionel Sambuc # define __UINT_LEAST8_MAX  UINT48_MAX
543f4a2713aSLionel Sambuc #endif /* __INT48_TYPE__ */
544f4a2713aSLionel Sambuc 
545f4a2713aSLionel Sambuc 
546f4a2713aSLionel Sambuc #ifdef __INT40_TYPE__
547f4a2713aSLionel Sambuc # define INT40_MAX           INT40_C(549755813887)
548f4a2713aSLionel Sambuc # define INT40_MIN         (-INT40_C(549755813887)-1)
549f4a2713aSLionel Sambuc # define UINT40_MAX         UINT40_C(1099511627775)
550f4a2713aSLionel Sambuc # define INT_LEAST40_MIN     INT40_MIN
551f4a2713aSLionel Sambuc # define INT_LEAST40_MAX     INT40_MAX
552f4a2713aSLionel Sambuc # define UINT_LEAST40_MAX   UINT40_MAX
553f4a2713aSLionel Sambuc # define INT_FAST40_MIN      INT40_MIN
554f4a2713aSLionel Sambuc # define INT_FAST40_MAX      INT40_MAX
555f4a2713aSLionel Sambuc # define UINT_FAST40_MAX    UINT40_MAX
556f4a2713aSLionel Sambuc # define __INT_LEAST32_MIN   INT40_MIN
557f4a2713aSLionel Sambuc # define __INT_LEAST32_MAX   INT40_MAX
558f4a2713aSLionel Sambuc # define __UINT_LEAST32_MAX UINT40_MAX
559f4a2713aSLionel Sambuc # define __INT_LEAST16_MIN   INT40_MIN
560f4a2713aSLionel Sambuc # define __INT_LEAST16_MAX   INT40_MAX
561f4a2713aSLionel Sambuc # define __UINT_LEAST16_MAX UINT40_MAX
562f4a2713aSLionel Sambuc # define __INT_LEAST8_MIN    INT40_MIN
563f4a2713aSLionel Sambuc # define __INT_LEAST8_MAX    INT40_MAX
564f4a2713aSLionel Sambuc # define __UINT_LEAST8_MAX  UINT40_MAX
565f4a2713aSLionel Sambuc #endif /* __INT40_TYPE__ */
566f4a2713aSLionel Sambuc 
567f4a2713aSLionel Sambuc 
568f4a2713aSLionel Sambuc #ifdef __INT32_TYPE__
569f4a2713aSLionel Sambuc # define INT32_MAX           INT32_C(2147483647)
570f4a2713aSLionel Sambuc # define INT32_MIN         (-INT32_C(2147483647)-1)
571f4a2713aSLionel Sambuc # define UINT32_MAX         UINT32_C(4294967295)
572f4a2713aSLionel Sambuc # define __INT_LEAST32_MIN   INT32_MIN
573f4a2713aSLionel Sambuc # define __INT_LEAST32_MAX   INT32_MAX
574f4a2713aSLionel Sambuc # define __UINT_LEAST32_MAX UINT32_MAX
575f4a2713aSLionel Sambuc # define __INT_LEAST16_MIN   INT32_MIN
576f4a2713aSLionel Sambuc # define __INT_LEAST16_MAX   INT32_MAX
577f4a2713aSLionel Sambuc # define __UINT_LEAST16_MAX UINT32_MAX
578f4a2713aSLionel Sambuc # define __INT_LEAST8_MIN    INT32_MIN
579f4a2713aSLionel Sambuc # define __INT_LEAST8_MAX    INT32_MAX
580f4a2713aSLionel Sambuc # define __UINT_LEAST8_MAX  UINT32_MAX
581f4a2713aSLionel Sambuc #endif /* __INT32_TYPE__ */
582f4a2713aSLionel Sambuc 
583f4a2713aSLionel Sambuc #ifdef __INT_LEAST32_MIN
584f4a2713aSLionel Sambuc # define INT_LEAST32_MIN   __INT_LEAST32_MIN
585f4a2713aSLionel Sambuc # define INT_LEAST32_MAX   __INT_LEAST32_MAX
586f4a2713aSLionel Sambuc # define UINT_LEAST32_MAX __UINT_LEAST32_MAX
587f4a2713aSLionel Sambuc # define INT_FAST32_MIN    __INT_LEAST32_MIN
588f4a2713aSLionel Sambuc # define INT_FAST32_MAX    __INT_LEAST32_MAX
589f4a2713aSLionel Sambuc # define UINT_FAST32_MAX  __UINT_LEAST32_MAX
590f4a2713aSLionel Sambuc #endif /* __INT_LEAST32_MIN */
591f4a2713aSLionel Sambuc 
592f4a2713aSLionel Sambuc 
593f4a2713aSLionel Sambuc #ifdef __INT24_TYPE__
594f4a2713aSLionel Sambuc # define INT24_MAX           INT24_C(8388607)
595f4a2713aSLionel Sambuc # define INT24_MIN         (-INT24_C(8388607)-1)
596f4a2713aSLionel Sambuc # define UINT24_MAX         UINT24_C(16777215)
597f4a2713aSLionel Sambuc # define INT_LEAST24_MIN     INT24_MIN
598f4a2713aSLionel Sambuc # define INT_LEAST24_MAX     INT24_MAX
599f4a2713aSLionel Sambuc # define UINT_LEAST24_MAX   UINT24_MAX
600f4a2713aSLionel Sambuc # define INT_FAST24_MIN      INT24_MIN
601f4a2713aSLionel Sambuc # define INT_FAST24_MAX      INT24_MAX
602f4a2713aSLionel Sambuc # define UINT_FAST24_MAX    UINT24_MAX
603f4a2713aSLionel Sambuc # define __INT_LEAST16_MIN   INT24_MIN
604f4a2713aSLionel Sambuc # define __INT_LEAST16_MAX   INT24_MAX
605f4a2713aSLionel Sambuc # define __UINT_LEAST16_MAX UINT24_MAX
606f4a2713aSLionel Sambuc # define __INT_LEAST8_MIN    INT24_MIN
607f4a2713aSLionel Sambuc # define __INT_LEAST8_MAX    INT24_MAX
608f4a2713aSLionel Sambuc # define __UINT_LEAST8_MAX  UINT24_MAX
609f4a2713aSLionel Sambuc #endif /* __INT24_TYPE__ */
610f4a2713aSLionel Sambuc 
611f4a2713aSLionel Sambuc 
612f4a2713aSLionel Sambuc #ifdef __INT16_TYPE__
613f4a2713aSLionel Sambuc #define INT16_MAX            INT16_C(32767)
614f4a2713aSLionel Sambuc #define INT16_MIN          (-INT16_C(32767)-1)
615f4a2713aSLionel Sambuc #define UINT16_MAX          UINT16_C(65535)
616f4a2713aSLionel Sambuc # define __INT_LEAST16_MIN   INT16_MIN
617f4a2713aSLionel Sambuc # define __INT_LEAST16_MAX   INT16_MAX
618f4a2713aSLionel Sambuc # define __UINT_LEAST16_MAX UINT16_MAX
619f4a2713aSLionel Sambuc # define __INT_LEAST8_MIN    INT16_MIN
620f4a2713aSLionel Sambuc # define __INT_LEAST8_MAX    INT16_MAX
621f4a2713aSLionel Sambuc # define __UINT_LEAST8_MAX  UINT16_MAX
622f4a2713aSLionel Sambuc #endif /* __INT16_TYPE__ */
623f4a2713aSLionel Sambuc 
624f4a2713aSLionel Sambuc #ifdef __INT_LEAST16_MIN
625f4a2713aSLionel Sambuc # define INT_LEAST16_MIN   __INT_LEAST16_MIN
626f4a2713aSLionel Sambuc # define INT_LEAST16_MAX   __INT_LEAST16_MAX
627f4a2713aSLionel Sambuc # define UINT_LEAST16_MAX __UINT_LEAST16_MAX
628f4a2713aSLionel Sambuc # define INT_FAST16_MIN    __INT_LEAST16_MIN
629f4a2713aSLionel Sambuc # define INT_FAST16_MAX    __INT_LEAST16_MAX
630f4a2713aSLionel Sambuc # define UINT_FAST16_MAX  __UINT_LEAST16_MAX
631f4a2713aSLionel Sambuc #endif /* __INT_LEAST16_MIN */
632f4a2713aSLionel Sambuc 
633f4a2713aSLionel Sambuc 
634f4a2713aSLionel Sambuc #ifdef __INT8_TYPE__
635f4a2713aSLionel Sambuc # define INT8_MAX            INT8_C(127)
636f4a2713aSLionel Sambuc # define INT8_MIN          (-INT8_C(127)-1)
637f4a2713aSLionel Sambuc # define UINT8_MAX          UINT8_C(255)
638f4a2713aSLionel Sambuc # define __INT_LEAST8_MIN    INT8_MIN
639f4a2713aSLionel Sambuc # define __INT_LEAST8_MAX    INT8_MAX
640f4a2713aSLionel Sambuc # define __UINT_LEAST8_MAX  UINT8_MAX
641f4a2713aSLionel Sambuc #endif /* __INT8_TYPE__ */
642f4a2713aSLionel Sambuc 
643f4a2713aSLionel Sambuc #ifdef __INT_LEAST8_MIN
644f4a2713aSLionel Sambuc # define INT_LEAST8_MIN   __INT_LEAST8_MIN
645f4a2713aSLionel Sambuc # define INT_LEAST8_MAX   __INT_LEAST8_MAX
646f4a2713aSLionel Sambuc # define UINT_LEAST8_MAX __UINT_LEAST8_MAX
647f4a2713aSLionel Sambuc # define INT_FAST8_MIN    __INT_LEAST8_MIN
648f4a2713aSLionel Sambuc # define INT_FAST8_MAX    __INT_LEAST8_MAX
649f4a2713aSLionel Sambuc # define UINT_FAST8_MAX  __UINT_LEAST8_MAX
650f4a2713aSLionel Sambuc #endif /* __INT_LEAST8_MIN */
651f4a2713aSLionel Sambuc 
652f4a2713aSLionel Sambuc /* Some utility macros */
653f4a2713aSLionel Sambuc #define  __INTN_MIN(n)  __stdint_join3( INT, n, _MIN)
654f4a2713aSLionel Sambuc #define  __INTN_MAX(n)  __stdint_join3( INT, n, _MAX)
655f4a2713aSLionel Sambuc #define __UINTN_MAX(n)  __stdint_join3(UINT, n, _MAX)
656f4a2713aSLionel Sambuc #define  __INTN_C(n, v) __stdint_join3( INT, n, _C(v))
657f4a2713aSLionel Sambuc #define __UINTN_C(n, v) __stdint_join3(UINT, n, _C(v))
658f4a2713aSLionel Sambuc 
659f4a2713aSLionel Sambuc /* C99 7.18.2.4 Limits of integer types capable of holding object pointers. */
660f4a2713aSLionel Sambuc /* C99 7.18.3 Limits of other integer types. */
661f4a2713aSLionel Sambuc 
662f4a2713aSLionel Sambuc #define  INTPTR_MIN  __INTN_MIN(__INTPTR_WIDTH__)
663f4a2713aSLionel Sambuc #define  INTPTR_MAX  __INTN_MAX(__INTPTR_WIDTH__)
664f4a2713aSLionel Sambuc #define UINTPTR_MAX __UINTN_MAX(__INTPTR_WIDTH__)
665f4a2713aSLionel Sambuc #define PTRDIFF_MIN  __INTN_MIN(__PTRDIFF_WIDTH__)
666f4a2713aSLionel Sambuc #define PTRDIFF_MAX  __INTN_MAX(__PTRDIFF_WIDTH__)
667f4a2713aSLionel Sambuc #define    SIZE_MAX __UINTN_MAX(__SIZE_WIDTH__)
668f4a2713aSLionel Sambuc 
669f4a2713aSLionel Sambuc /* ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__
670f4a2713aSLionel Sambuc  * is enabled. */
671f4a2713aSLionel Sambuc #if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1
672f4a2713aSLionel Sambuc #define   RSIZE_MAX            (SIZE_MAX >> 1)
673f4a2713aSLionel Sambuc #endif
674f4a2713aSLionel Sambuc 
675f4a2713aSLionel Sambuc /* C99 7.18.2.5 Limits of greatest-width integer types. */
676f4a2713aSLionel Sambuc #define INTMAX_MIN   __INTN_MIN(__INTMAX_WIDTH__)
677f4a2713aSLionel Sambuc #define INTMAX_MAX   __INTN_MAX(__INTMAX_WIDTH__)
678f4a2713aSLionel Sambuc #define UINTMAX_MAX __UINTN_MAX(__INTMAX_WIDTH__)
679f4a2713aSLionel Sambuc 
680f4a2713aSLionel Sambuc /* C99 7.18.3 Limits of other integer types. */
681f4a2713aSLionel Sambuc #define SIG_ATOMIC_MIN __INTN_MIN(__SIG_ATOMIC_WIDTH__)
682f4a2713aSLionel Sambuc #define SIG_ATOMIC_MAX __INTN_MAX(__SIG_ATOMIC_WIDTH__)
683f4a2713aSLionel Sambuc #ifdef __WINT_UNSIGNED__
684f4a2713aSLionel Sambuc # define WINT_MIN       __UINTN_C(__WINT_WIDTH__, 0)
685f4a2713aSLionel Sambuc # define WINT_MAX       __UINTN_MAX(__WINT_WIDTH__)
686f4a2713aSLionel Sambuc #else
687f4a2713aSLionel Sambuc # define WINT_MIN       __INTN_MIN(__WINT_WIDTH__)
688f4a2713aSLionel Sambuc # define WINT_MAX       __INTN_MAX(__WINT_WIDTH__)
689f4a2713aSLionel Sambuc #endif
690f4a2713aSLionel Sambuc 
691f4a2713aSLionel Sambuc #ifndef WCHAR_MAX
692f4a2713aSLionel Sambuc # define WCHAR_MAX __WCHAR_MAX__
693f4a2713aSLionel Sambuc #endif
694f4a2713aSLionel Sambuc #ifndef WCHAR_MIN
695f4a2713aSLionel Sambuc # if __WCHAR_MAX__ == __INTN_MAX(__WCHAR_WIDTH__)
696f4a2713aSLionel Sambuc #  define WCHAR_MIN __INTN_MIN(__WCHAR_WIDTH__)
697f4a2713aSLionel Sambuc # else
698f4a2713aSLionel Sambuc #  define WCHAR_MIN __UINTN_C(__WCHAR_WIDTH__, 0)
699f4a2713aSLionel Sambuc # endif
700f4a2713aSLionel Sambuc #endif
701f4a2713aSLionel Sambuc 
702f4a2713aSLionel Sambuc /* 7.18.4.2 Macros for greatest-width integer constants. */
703f4a2713aSLionel Sambuc #define INTMAX_C(v)   __INTN_C(__INTMAX_WIDTH__, v)
704f4a2713aSLionel Sambuc #define UINTMAX_C(v) __UINTN_C(__INTMAX_WIDTH__, v)
705f4a2713aSLionel Sambuc 
706f4a2713aSLionel Sambuc #endif /* __STDC_HOSTED__ */
707f4a2713aSLionel Sambuc #endif /* __CLANG_STDINT_H */
708