blob: 9498ed5f52d97b61d1ea1283814f6c9dc065812d [file] [log] [blame]
Chris Lattner2a67f7b2009-02-06 22:59:47 +00001/*===---- stdint.h - Standard header for sized integer types --------------===*\
2 *
3 * Copyright (c) 2009 Chris Lattner
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 * THE SOFTWARE.
22 *
23\*===----------------------------------------------------------------------===*/
24
Eli Friedman6fdca0e2009-05-03 23:00:48 +000025#ifndef __CLANG_STDINT_H
26#define __CLANG_STDINT_H
27
28/* If we're hosted, fall back to the system's stdint.h, which might have
29 * additional definitions.
30 */
John Thompson92bd8c72009-11-02 22:28:12 +000031#if __STDC_HOSTED__ && \
32 defined(__has_include_next) && __has_include_next(<stdint.h>)
Eli Friedman6fdca0e2009-05-03 23:00:48 +000033# include_next <stdint.h>
34#else
Chris Lattner2a67f7b2009-02-06 22:59:47 +000035
Chris Lattner2a67f7b2009-02-06 22:59:47 +000036/* C99 7.18.1.1 Exact-width integer types.
37 * C99 7.18.1.2 Minimum-width integer types.
38 * C99 7.18.1.3 Fastest minimum-width integer types.
Chris Lattnerdcdd2a02009-11-12 08:08:27 +000039 *
40 * The standard requires that exact-width type be defined for 8-, 16-, 32-, and
41 * 64-bit types if they are implemented. Other exact width types are optional.
42 * This implementation defines an exact-width types for every integer width
43 * that is represented in the standard integer types.
44 *
45 * The standard also requires minimum-width types be defined for 8-, 16-, 32-,
46 * and 64-bit widths regardless of whether there are corresponding exact-width
47 * types.
48 *
49 * To accomodate targets that are missing types that are exactly 8, 16, 32, or
50 * 64 bits wide, this implementation takes an approach of cascading
51 * redefintions, redefining __int_leastN_t to successively smaller exact-width
52 * types. It is therefore important that the types are defined in order of
53 * descending widths.
54 *
55 * We currently assume that the minimum-width types and the fastest
56 * minimum-width types are the same. This is allowed by the standard, but is
57 * suboptimal.
58 *
59 * In violation of the standard, some targets do not implement a type that is
60 * wide enough to represent all of the required widths (8-, 16-, 32-, 64-bit).
61 * To accomodate these targets, a required minimum-width type is only
62 * defined if there exists an exact-width type of equal or greater width.
Chris Lattner2a67f7b2009-02-06 22:59:47 +000063 */
64
Chris Lattnerca931952009-04-18 19:11:11 +000065#ifdef __INT64_TYPE__
Chris Lattnerdcdd2a02009-11-12 08:08:27 +000066# ifndef __int8_t_defined /* glibc sys/types.h also defines int64_t*/
67typedef signed __INT64_TYPE__ int64_t;
68# endif /* __int8_t_defined */
Chris Lattner06dcf6b2009-11-04 23:03:18 +000069typedef unsigned __INT64_TYPE__ uint64_t;
Chris Lattnerdcdd2a02009-11-12 08:08:27 +000070# define __int_least64_t int64_t
71# define __uint_least64_t uint64_t
72# define __int_least32_t int64_t
73# define __uint_least32_t uint64_t
74# define __int_least16_t int64_t
75# define __uint_least16_t uint64_t
76# define __int_least8_t int64_t
77# define __uint_least8_t uint64_t
78#endif /* __INT64_TYPE__ */
Chris Lattnerca931952009-04-18 19:11:11 +000079
Chris Lattnerdcdd2a02009-11-12 08:08:27 +000080#ifdef __int_least64_t
81typedef __int_least64_t int_least64_t;
82typedef __uint_least64_t uint_least64_t;
83typedef __int_least64_t int_fast64_t;
84typedef __uint_least64_t uint_fast64_t;
85#endif /* __int_least64_t */
86
87#ifdef __INT56_TYPE__
88typedef signed __INT56_TYPE__ int56_t;
89typedef unsigned __INT56_TYPE__ uint56_t;
90typedef int56_t int_least56_t;
91typedef uint56_t uint_least56_t;
92typedef int56_t int_fast56_t;
93typedef uint56_t uint_fast56_t;
94# define __int_least32_t int56_t
95# define __uint_least32_t uint56_t
96# define __int_least16_t int56_t
97# define __uint_least16_t uint56_t
98# define __int_least8_t int56_t
99# define __uint_least8_t uint56_t
100#endif /* __INT56_TYPE__ */
101
102
103#ifdef __INT48_TYPE__
104typedef signed __INT48_TYPE__ int48_t;
105typedef unsigned __INT48_TYPE__ uint48_t;
106typedef int48_t int_least48_t;
107typedef uint48_t uint_least48_t;
108typedef int48_t int_fast48_t;
109typedef uint48_t uint_fast48_t;
110# define __int_least32_t int48_t
111# define __uint_least32_t uint48_t
112# define __int_least16_t int48_t
113# define __uint_least16_t uint48_t
114# define __int_least8_t int48_t
115# define __uint_least8_t uint48_t
116#endif /* __INT48_TYPE__ */
117
118
119#ifdef __INT40_TYPE__
120typedef signed __INT40_TYPE__ int40_t;
121typedef unsigned __INT40_TYPE__ uint40_t;
122typedef int40_t int_least40_t;
123typedef uint40_t uint_least40_t;
124typedef int40_t int_fast40_t;
125typedef uint40_t uint_fast40_t;
126# define __int_least32_t int40_t
127# define __uint_least32_t uint40_t
128# define __int_least16_t int40_t
129# define __uint_least16_t uint40_t
130# define __int_least8_t int40_t
131# define __uint_least8_t uint40_t
132#endif /* __INT40_TYPE__ */
133
134
135#ifdef __INT32_TYPE__
136
137# ifndef __int8_t_defined /* glibc sys/types.h also defines int32_t*/
138typedef signed __INT32_TYPE__ int32_t;
139# endif /* __int8_t_defined */
140
141# ifndef __uint32_t_defined /* more glibc compatibility */
142# define __uint32_t_defined
Chris Lattner2a67f7b2009-02-06 22:59:47 +0000143typedef unsigned __INT32_TYPE__ uint32_t;
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000144# endif /* __uint32_t_defined */
Chris Lattner2a67f7b2009-02-06 22:59:47 +0000145
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000146# define __int_least32_t int32_t
147# define __uint_least32_t uint32_t
148# define __int_least16_t int32_t
149# define __uint_least16_t uint32_t
150# define __int_least8_t int32_t
151# define __uint_least8_t uint32_t
152#endif /* __INT32_TYPE__ */
Chris Lattner2a67f7b2009-02-06 22:59:47 +0000153
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000154#ifdef __int_least32_t
155typedef __int_least32_t int_least32_t;
156typedef __uint_least32_t uint_least32_t;
157typedef __int_least32_t int_fast32_t;
158typedef __uint_least32_t uint_fast32_t;
159#endif /* __int_least32_t */
160
161#ifdef __INT24_TYPE__
162typedef signed __INT24_TYPE__ int24_t;
163typedef unsigned __INT24_TYPE__ uint24_t;
164typedef int24_t int_least24_t;
165typedef uint24_t uint_least24_t;
166typedef int24_t int_fast24_t;
167typedef uint24_t uint_fast24_t;
168# define __int_least16_t int24_t
169# define __uint_least16_t uint24_t
170# define __int_least8_t int24_t
171# define __uint_least8_t uint24_t
172#endif /* __INT24_TYPE__ */
173
174#ifdef __INT16_TYPE__
175#ifndef __int8_t_defined /* glibc sys/types.h also defines int16_t*/
176typedef signed __INT16_TYPE__ int16_t;
177#endif /* __int8_t_defined */
Chris Lattner06dcf6b2009-11-04 23:03:18 +0000178typedef unsigned __INT16_TYPE__ uint16_t;
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000179# define __int_least16_t int16_t
180# define __uint_least16_t uint16_t
181# define __int_least8_t int16_t
182# define __uint_least8_t uint16_t
183#endif /* __INT16_TYPE__ */
184
185#ifdef __int_least16_t
186typedef __int_least16_t int_least16_t;
187typedef __uint_least16_t uint_least16_t;
188typedef __int_least16_t int_fast16_t;
189typedef __uint_least16_t uint_fast16_t;
190#endif /* __int_least16_t */
Chris Lattner06dcf6b2009-11-04 23:03:18 +0000191
192
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000193#ifdef __INT8_TYPE__
194#ifndef __int8_t_defined /* glibc sys/types.h also defines int8_t*/
Chris Lattner06dcf6b2009-11-04 23:03:18 +0000195typedef signed __INT8_TYPE__ int8_t;
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000196#endif /* __int8_t_defined */
Chris Lattner06dcf6b2009-11-04 23:03:18 +0000197typedef unsigned __INT8_TYPE__ uint8_t;
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000198# define __int_least8_t int8_t
199# define __uint_least8_t uint8_t
200#endif /* __INT8_TYPE__ */
201
202#ifdef __int_least8_t
203typedef __int_least8_t int_least8_t;
204typedef __uint_least8_t uint_least8_t;
205typedef __int_least8_t int_fast8_t;
206typedef __uint_least8_t uint_fast8_t;
207#endif /* __int_least8_t */
Chris Lattner06dcf6b2009-11-04 23:03:18 +0000208
209/* prevent glibc sys/types.h from defining conflicting types */
210#ifndef __int8_t_defined
211# define __int8_t_defined
212#endif /* __int8_t_defined */
Chris Lattner2a67f7b2009-02-06 22:59:47 +0000213
214/* C99 7.18.1.4 Integer types capable of holding object pointers.
215 */
Ken Dyck08321b42009-11-18 20:24:13 +0000216#define __stdint_join3(a,b,c) a ## b ## c
Ken Dyck08321b42009-11-18 20:24:13 +0000217
Ken Dyckaface1b2009-11-20 16:37:35 +0000218#define __intn_t(n) __stdint_join3( int, n, _t)
219#define __uintn_t(n) __stdint_join3(uint, n, _t)
220
Daniel Dunbar564618f2010-04-24 20:32:12 +0000221#ifndef _INTPTR_T
Chris Lattner40e60c22009-02-13 22:43:13 +0000222#ifndef __intptr_t_defined
Ken Dyckaface1b2009-11-20 16:37:35 +0000223typedef __intn_t(__INTPTR_WIDTH__) intptr_t;
Chris Lattner40e60c22009-02-13 22:43:13 +0000224#define __intptr_t_defined
Daniel Dunbar564618f2010-04-24 20:32:12 +0000225#define _INTPTR_T
Chris Lattner40e60c22009-02-13 22:43:13 +0000226#endif
Daniel Dunbar564618f2010-04-24 20:32:12 +0000227#endif
228
229#ifndef _UINTPTR_T
Ken Dyckaface1b2009-11-20 16:37:35 +0000230typedef __uintn_t(__INTPTR_WIDTH__) uintptr_t;
Daniel Dunbar564618f2010-04-24 20:32:12 +0000231#define _UINTPTR_T
232#endif
Chris Lattner2a67f7b2009-02-06 22:59:47 +0000233
234/* C99 7.18.1.5 Greatest-width integer types.
235 */
Daniel Dunbar96d38c12010-06-30 06:30:50 +0000236typedef __INTMAX_TYPE__ intmax_t;
237typedef __UINTMAX_TYPE__ uintmax_t;
Chris Lattner2a67f7b2009-02-06 22:59:47 +0000238
Chris Lattner06dcf6b2009-11-04 23:03:18 +0000239/* C99 7.18.4 Macros for minimum-width integer constants.
240 *
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000241 * The standard requires that integer constant macros be defined for all the
242 * minimum-width types defined above. As 8-, 16-, 32-, and 64-bit minimum-width
243 * types are required, the corresponding integer constant macros are defined
244 * here. This implementation also defines minimum-width types for every other
245 * integer width that the target implements, so corresponding macros are
246 * defined below, too.
247 *
248 * These macros are defined using the same successive-shrinking approach as
249 * the type definitions above. It is likewise important that macros are defined
250 * in order of decending width.
251 *
Chris Lattner06dcf6b2009-11-04 23:03:18 +0000252 * Note that C++ should not check __STDC_CONSTANT_MACROS here, contrary to the
253 * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]).
254 */
255
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000256#define __int_c_join(a, b) a ## b
Ken Dyck6ab25f42009-11-17 13:54:02 +0000257#define __int_c(v, suffix) __int_c_join(v, suffix)
258#define __uint_c(v, suffix) __int_c_join(v##U, suffix)
Chris Lattner06dcf6b2009-11-04 23:03:18 +0000259
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000260
261#ifdef __INT64_TYPE__
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000262# ifdef __INT64_C_SUFFIX__
263# define __int64_c_suffix __INT64_C_SUFFIX__
264# define __int32_c_suffix __INT64_C_SUFFIX__
265# define __int16_c_suffix __INT64_C_SUFFIX__
266# define __int8_c_suffix __INT64_C_SUFFIX__
267# else
268# undef __int64_c_suffix
269# undef __int32_c_suffix
270# undef __int16_c_suffix
271# undef __int8_c_suffix
272# endif /* __INT64_C_SUFFIX__ */
273#endif /* __INT64_TYPE__ */
274
275#ifdef __int_least64_t
276# ifdef __int64_c_suffix
277# define INT64_C(v) __int_c(v, __int64_c_suffix)
278# define UINT64_C(v) __uint_c(v, __int64_c_suffix)
279# else
Ken Dyck6ab25f42009-11-17 13:54:02 +0000280# define INT64_C(v) v
281# define UINT64_C(v) v ## U
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000282# endif /* __int64_c_suffix */
283#endif /* __int_least64_t */
284
285
286#ifdef __INT56_TYPE__
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000287# ifdef __INT56_C_SUFFIX__
288# define INT56_C(v) __int_c(v, __INT56_C_SUFFIX__)
289# define UINT56_C(v) __uint_c(v, __INT56_C_SUFFIX__)
290# define __int32_c_suffix __INT56_C_SUFFIX__
291# define __int16_c_suffix __INT56_C_SUFFIX__
292# define __int8_c_suffix __INT56_C_SUFFIX__
293# else
Ken Dyck6ab25f42009-11-17 13:54:02 +0000294# define INT56_C(v) v
295# define UINT56_C(v) v ## U
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000296# undef __int32_c_suffix
297# undef __int16_c_suffix
298# undef __int8_c_suffix
299# endif /* __INT56_C_SUFFIX__ */
300#endif /* __INT56_TYPE__ */
301
302
303#ifdef __INT48_TYPE__
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000304# ifdef __INT48_C_SUFFIX__
305# define INT48_C(v) __int_c(v, __INT48_C_SUFFIX__)
306# define UINT48_C(v) __uint_c(v, __INT48_C_SUFFIX__)
307# define __int32_c_suffix __INT48_C_SUFFIX__
308# define __int16_c_suffix __INT48_C_SUFFIX__
309# define __int8_c_suffix __INT48_C_SUFFIX__
310# else
Ken Dyck6ab25f42009-11-17 13:54:02 +0000311# define INT48_C(v) v
312# define UINT48_C(v) v ## U
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000313# undef __int32_c_suffix
314# undef __int16_c_suffix
315# undef __int8_c_suffix
316# endif /* __INT48_C_SUFFIX__ */
317#endif /* __INT48_TYPE__ */
318
319
320#ifdef __INT40_TYPE__
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000321# ifdef __INT40_C_SUFFIX__
322# define INT40_C(v) __int_c(v, __INT40_C_SUFFIX__)
323# define UINT40_C(v) __uint_c(v, __INT40_C_SUFFIX__)
324# define __int32_c_suffix __INT40_C_SUFFIX__
325# define __int16_c_suffix __INT40_C_SUFFIX__
326# define __int8_c_suffix __INT40_C_SUFFIX__
327# else
Ken Dyck6ab25f42009-11-17 13:54:02 +0000328# define INT40_C(v) v
329# define UINT40_C(v) v ## U
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000330# undef __int32_c_suffix
331# undef __int16_c_suffix
332# undef __int8_c_suffix
333# endif /* __INT40_C_SUFFIX__ */
334#endif /* __INT40_TYPE__ */
335
336
337#ifdef __INT32_TYPE__
338# ifdef __INT32_C_SUFFIX__
339# define __int32_c_suffix __INT32_C_SUFFIX__
340# define __int16_c_suffix __INT32_C_SUFFIX__
341# define __int8_c_suffix __INT32_C_SUFFIX__
342#else
343# undef __int32_c_suffix
344# undef __int16_c_suffix
345# undef __int8_c_suffix
346# endif /* __INT32_C_SUFFIX__ */
347#endif /* __INT32_TYPE__ */
348
349#ifdef __int_least32_t
350# ifdef __int32_c_suffix
351# define INT32_C(v) __int_c(v, __int32_c_suffix)
352# define UINT32_C(v) __uint_c(v, __int32_c_suffix)
353# else
Ken Dyck6ab25f42009-11-17 13:54:02 +0000354# define INT32_C(v) v
355# define UINT32_C(v) v ## U
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000356# endif /* __int32_c_suffix */
357#endif /* __int_least32_t */
358
359
360#ifdef __INT24_TYPE__
361# ifdef __INT24_C_SUFFIX__
362# define INT24_C(v) __int_c(v, __INT24_C_SUFFIX__)
363# define UINT24_C(v) __uint_c(v, __INT24_C_SUFFIX__)
364# define __int16_c_suffix __INT24_C_SUFFIX__
365# define __int8_c_suffix __INT24_C_SUFFIX__
366# else
Ken Dyck6ab25f42009-11-17 13:54:02 +0000367# define INT24_C(v) v
368# define UINT24_C(v) v ## U
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000369# undef __int16_c_suffix
370# undef __int8_c_suffix
371# endif /* __INT24_C_SUFFIX__ */
372#endif /* __INT24_TYPE__ */
373
374
375#ifdef __INT16_TYPE__
376# ifdef __INT16_C_SUFFIX__
377# define __int16_c_suffix __INT16_C_SUFFIX__
378# define __int8_c_suffix __INT16_C_SUFFIX__
379#else
380# undef __int16_c_suffix
381# undef __int8_c_suffix
382# endif /* __INT16_C_SUFFIX__ */
383#endif /* __INT16_TYPE__ */
384
385#ifdef __int_least16_t
386# ifdef __int16_c_suffix
387# define INT16_C(v) __int_c(v, __int16_c_suffix)
388# define UINT16_C(v) __uint_c(v, __int16_c_suffix)
389# else
Ken Dyck6ab25f42009-11-17 13:54:02 +0000390# define INT16_C(v) v
391# define UINT16_C(v) v ## U
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000392# endif /* __int16_c_suffix */
393#endif /* __int_least16_t */
394
395
396#ifdef __INT8_TYPE__
397# ifdef __INT8_C_SUFFIX__
398# define __int8_c_suffix __INT8_C_SUFFIX__
399#else
400# undef __int8_c_suffix
401# endif /* __INT8_C_SUFFIX__ */
402#endif /* __INT8_TYPE__ */
403
404#ifdef __int_least8_t
405# ifdef __int8_c_suffix
406# define INT8_C(v) __int_c(v, __int8_c_suffix)
407# define UINT8_C(v) __uint_c(v, __int8_c_suffix)
408# else
Ken Dyck6ab25f42009-11-17 13:54:02 +0000409# define INT8_C(v) v
410# define UINT8_C(v) v ## U
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000411# endif /* __int8_c_suffix */
412#endif /* __int_least8_t */
413
Chris Lattner06dcf6b2009-11-04 23:03:18 +0000414
Chris Lattner2a67f7b2009-02-06 22:59:47 +0000415/* C99 7.18.2.1 Limits of exact-width integer types.
Chris Lattner2a67f7b2009-02-06 22:59:47 +0000416 * C99 7.18.2.2 Limits of minimum-width integer types.
Chris Lattner2a67f7b2009-02-06 22:59:47 +0000417 * C99 7.18.2.3 Limits of fastest minimum-width integer types.
Chris Lattner61484282009-02-07 22:21:31 +0000418 *
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000419 * The presence of limit macros are completely optional in C99. This
420 * implementation defines limits for all of the types (exact- and
421 * minimum-width) that it defines above, using the limits of the minimum-width
422 * type for any types that do not have exact-width representations.
423 *
424 * As in the type definitions, this section takes an approach of
425 * successive-shrinking to determine which limits to use for the standard (8,
426 * 16, 32, 64) bit widths when they don't have exact representations. It is
427 * therefore important that the defintions be kept in order of decending
428 * widths.
429 *
Chris Lattner61484282009-02-07 22:21:31 +0000430 * Note that C++ should not check __STDC_LIMIT_MACROS here, contrary to the
431 * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]).
Chris Lattner2a67f7b2009-02-06 22:59:47 +0000432 */
433
Chris Lattnerab775f62009-02-28 18:53:33 +0000434#ifdef __INT64_TYPE__
Ken Dyck81638412009-11-17 16:26:27 +0000435# define INT64_MAX INT64_C( 9223372036854775807)
436# define INT64_MIN (-INT64_C( 9223372036854775807)-1)
437# define UINT64_MAX UINT64_C(18446744073709551615)
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000438# define __INT_LEAST64_MIN INT64_MIN
439# define __INT_LEAST64_MAX INT64_MAX
440# define __UINT_LEAST64_MAX UINT64_MAX
441# define __INT_LEAST32_MIN INT64_MIN
442# define __INT_LEAST32_MAX INT64_MAX
443# define __UINT_LEAST32_MAX UINT64_MAX
444# define __INT_LEAST16_MIN INT64_MIN
445# define __INT_LEAST16_MAX INT64_MAX
446# define __UINT_LEAST16_MAX UINT64_MAX
447# define __INT_LEAST8_MIN INT64_MIN
448# define __INT_LEAST8_MAX INT64_MAX
449# define __UINT_LEAST8_MAX UINT64_MAX
450#endif /* __INT64_TYPE__ */
Chris Lattner2a67f7b2009-02-06 22:59:47 +0000451
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000452#ifdef __INT_LEAST64_MIN
453# define INT_LEAST64_MIN __INT_LEAST64_MIN
454# define INT_LEAST64_MAX __INT_LEAST64_MAX
455# define UINT_LEAST64_MAX __UINT_LEAST64_MAX
456# define INT_FAST64_MIN __INT_LEAST64_MIN
457# define INT_FAST64_MAX __INT_LEAST64_MAX
458# define UINT_FAST64_MAX __UINT_LEAST64_MAX
459#endif /* __INT_LEAST64_MIN */
Chris Lattner06dcf6b2009-11-04 23:03:18 +0000460
Chris Lattner06dcf6b2009-11-04 23:03:18 +0000461
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000462#ifdef __INT56_TYPE__
Ken Dyck81638412009-11-17 16:26:27 +0000463# define INT56_MAX INT56_C(36028797018963967)
464# define INT56_MIN (-INT56_C(36028797018963967)-1)
465# define UINT56_MAX UINT56_C(72057594037927935)
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000466# define INT_LEAST56_MIN INT56_MIN
467# define INT_LEAST56_MAX INT56_MAX
468# define UINT_LEAST56_MAX UINT56_MAX
469# define INT_FAST56_MIN INT56_MIN
470# define INT_FAST56_MAX INT56_MAX
471# define UINT_FAST56_MAX UINT56_MAX
472# define __INT_LEAST32_MIN INT56_MIN
473# define __INT_LEAST32_MAX INT56_MAX
474# define __UINT_LEAST32_MAX UINT56_MAX
475# define __INT_LEAST16_MIN INT56_MIN
476# define __INT_LEAST16_MAX INT56_MAX
477# define __UINT_LEAST16_MAX UINT56_MAX
478# define __INT_LEAST8_MIN INT56_MIN
479# define __INT_LEAST8_MAX INT56_MAX
480# define __UINT_LEAST8_MAX UINT56_MAX
481#endif /* __INT56_TYPE__ */
482
483
484#ifdef __INT48_TYPE__
Ken Dyck81638412009-11-17 16:26:27 +0000485# define INT48_MAX INT48_C(140737488355327)
486# define INT48_MIN (-INT48_C(140737488355327)-1)
487# define UINT48_MAX UINT48_C(281474976710655)
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000488# define INT_LEAST48_MIN INT48_MIN
489# define INT_LEAST48_MAX INT48_MAX
490# define UINT_LEAST48_MAX UINT48_MAX
491# define INT_FAST48_MIN INT48_MIN
492# define INT_FAST48_MAX INT48_MAX
493# define UINT_FAST48_MAX UINT48_MAX
494# define __INT_LEAST32_MIN INT48_MIN
495# define __INT_LEAST32_MAX INT48_MAX
496# define __UINT_LEAST32_MAX UINT48_MAX
497# define __INT_LEAST16_MIN INT48_MIN
498# define __INT_LEAST16_MAX INT48_MAX
499# define __UINT_LEAST16_MAX UINT48_MAX
500# define __INT_LEAST8_MIN INT48_MIN
501# define __INT_LEAST8_MAX INT48_MAX
502# define __UINT_LEAST8_MAX UINT48_MAX
503#endif /* __INT48_TYPE__ */
504
505
506#ifdef __INT40_TYPE__
Ken Dyck81638412009-11-17 16:26:27 +0000507# define INT40_MAX INT40_C(549755813887)
508# define INT40_MIN (-INT40_C(549755813887)-1)
509# define UINT40_MAX UINT40_C(1099511627775)
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000510# define INT_LEAST40_MIN INT40_MIN
511# define INT_LEAST40_MAX INT40_MAX
512# define UINT_LEAST40_MAX UINT40_MAX
513# define INT_FAST40_MIN INT40_MIN
514# define INT_FAST40_MAX INT40_MAX
515# define UINT_FAST40_MAX UINT40_MAX
516# define __INT_LEAST32_MIN INT40_MIN
517# define __INT_LEAST32_MAX INT40_MAX
518# define __UINT_LEAST32_MAX UINT40_MAX
519# define __INT_LEAST16_MIN INT40_MIN
520# define __INT_LEAST16_MAX INT40_MAX
521# define __UINT_LEAST16_MAX UINT40_MAX
522# define __INT_LEAST8_MIN INT40_MIN
523# define __INT_LEAST8_MAX INT40_MAX
524# define __UINT_LEAST8_MAX UINT40_MAX
525#endif /* __INT40_TYPE__ */
526
527
528#ifdef __INT32_TYPE__
Ken Dyck81638412009-11-17 16:26:27 +0000529# define INT32_MAX INT32_C(2147483647)
530# define INT32_MIN (-INT32_C(2147483647)-1)
531# define UINT32_MAX UINT32_C(4294967295)
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000532# define __INT_LEAST32_MIN INT32_MIN
533# define __INT_LEAST32_MAX INT32_MAX
534# define __UINT_LEAST32_MAX UINT32_MAX
535# define __INT_LEAST16_MIN INT32_MIN
536# define __INT_LEAST16_MAX INT32_MAX
537# define __UINT_LEAST16_MAX UINT32_MAX
538# define __INT_LEAST8_MIN INT32_MIN
539# define __INT_LEAST8_MAX INT32_MAX
540# define __UINT_LEAST8_MAX UINT32_MAX
541#endif /* __INT32_TYPE__ */
542
543#ifdef __INT_LEAST32_MIN
544# define INT_LEAST32_MIN __INT_LEAST32_MIN
545# define INT_LEAST32_MAX __INT_LEAST32_MAX
546# define UINT_LEAST32_MAX __UINT_LEAST32_MAX
547# define INT_FAST32_MIN __INT_LEAST32_MIN
548# define INT_FAST32_MAX __INT_LEAST32_MAX
549# define UINT_FAST32_MAX __UINT_LEAST32_MAX
550#endif /* __INT_LEAST32_MIN */
551
552
553#ifdef __INT24_TYPE__
Ken Dyck81638412009-11-17 16:26:27 +0000554# define INT24_MAX INT24_C(8388607)
Ken Dyckb0887562009-11-17 18:29:12 +0000555# define INT24_MIN (-INT24_C(8388607)-1)
Ken Dyck81638412009-11-17 16:26:27 +0000556# define UINT24_MAX UINT24_C(16777215)
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000557# define INT_LEAST24_MIN INT24_MIN
558# define INT_LEAST24_MAX INT24_MAX
559# define UINT_LEAST24_MAX UINT24_MAX
560# define INT_FAST24_MIN INT24_MIN
561# define INT_FAST24_MAX INT24_MAX
562# define UINT_FAST24_MAX UINT24_MAX
563# define __INT_LEAST16_MIN INT24_MIN
564# define __INT_LEAST16_MAX INT24_MAX
565# define __UINT_LEAST16_MAX UINT24_MAX
566# define __INT_LEAST8_MIN INT24_MIN
567# define __INT_LEAST8_MAX INT24_MAX
568# define __UINT_LEAST8_MAX UINT24_MAX
569#endif /* __INT24_TYPE__ */
570
571
572#ifdef __INT16_TYPE__
Ken Dyck81638412009-11-17 16:26:27 +0000573#define INT16_MAX INT16_C(32767)
Ken Dyckb0887562009-11-17 18:29:12 +0000574#define INT16_MIN (-INT16_C(32767)-1)
Ken Dyck81638412009-11-17 16:26:27 +0000575#define UINT16_MAX UINT16_C(65535)
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000576# define __INT_LEAST16_MIN INT16_MIN
577# define __INT_LEAST16_MAX INT16_MAX
578# define __UINT_LEAST16_MAX UINT16_MAX
579# define __INT_LEAST8_MIN INT16_MIN
580# define __INT_LEAST8_MAX INT16_MAX
581# define __UINT_LEAST8_MAX UINT16_MAX
582#endif /* __INT16_TYPE__ */
583
584#ifdef __INT_LEAST16_MIN
585# define INT_LEAST16_MIN __INT_LEAST16_MIN
586# define INT_LEAST16_MAX __INT_LEAST16_MAX
587# define UINT_LEAST16_MAX __UINT_LEAST16_MAX
588# define INT_FAST16_MIN __INT_LEAST16_MIN
589# define INT_FAST16_MAX __INT_LEAST16_MAX
590# define UINT_FAST16_MAX __UINT_LEAST16_MAX
591#endif /* __INT_LEAST16_MIN */
592
593
594#ifdef __INT8_TYPE__
Ken Dyck81638412009-11-17 16:26:27 +0000595# define INT8_MAX INT8_C(127)
Ken Dyckb0887562009-11-17 18:29:12 +0000596# define INT8_MIN (-INT8_C(127)-1)
Ken Dyck81638412009-11-17 16:26:27 +0000597# define UINT8_MAX UINT8_C(255)
Chris Lattnerdcdd2a02009-11-12 08:08:27 +0000598# define __INT_LEAST8_MIN INT8_MIN
599# define __INT_LEAST8_MAX INT8_MAX
600# define __UINT_LEAST8_MAX UINT8_MAX
601#endif /* __INT8_TYPE__ */
602
603#ifdef __INT_LEAST8_MIN
604# define INT_LEAST8_MIN __INT_LEAST8_MIN
605# define INT_LEAST8_MAX __INT_LEAST8_MAX
606# define UINT_LEAST8_MAX __UINT_LEAST8_MAX
607# define INT_FAST8_MIN __INT_LEAST8_MIN
608# define INT_FAST8_MAX __INT_LEAST8_MAX
609# define UINT_FAST8_MAX __UINT_LEAST8_MAX
610#endif /* __INT_LEAST8_MIN */
Chris Lattner06dcf6b2009-11-04 23:03:18 +0000611
Chris Lattner2a67f7b2009-02-06 22:59:47 +0000612/* C99 7.18.2.4 Limits of integer types capable of holding object pointers. */
613/* C99 7.18.3 Limits of other integer types. */
Ken Dycka2e92842009-11-20 16:44:38 +0000614#define __INTN_MIN(n) __stdint_join3( INT, n, _MIN)
615#define __INTN_MAX(n) __stdint_join3( INT, n, _MAX)
616#define __UINTN_MAX(n) __stdint_join3(UINT, n, _MAX)
Chris Lattner2a67f7b2009-02-06 22:59:47 +0000617
Ken Dycka2e92842009-11-20 16:44:38 +0000618#define INTPTR_MIN __INTN_MIN(__INTPTR_WIDTH__)
619#define INTPTR_MAX __INTN_MAX(__INTPTR_WIDTH__)
620#define UINTPTR_MAX __UINTN_MAX(__INTPTR_WIDTH__)
621#define PTRDIFF_MIN __INTN_MIN(__PTRDIFF_WIDTH__)
622#define PTRDIFF_MAX __INTN_MAX(__PTRDIFF_WIDTH__)
623#define SIZE_MAX __UINTN_MAX(__SIZE_WIDTH__)
Chris Lattner2a67f7b2009-02-06 22:59:47 +0000624
625/* C99 7.18.2.5 Limits of greatest-width integer types. */
Ken Dycka2e92842009-11-20 16:44:38 +0000626#define INTMAX_MIN __INTN_MIN(__INTMAX_WIDTH__)
627#define INTMAX_MAX __INTN_MAX(__INTMAX_WIDTH__)
628#define UINTMAX_MAX __UINTN_MAX(__INTMAX_WIDTH__)
Chris Lattner2a67f7b2009-02-06 22:59:47 +0000629
630/* C99 7.18.3 Limits of other integer types. */
Ken Dyckfc07d912009-11-22 15:47:12 +0000631#define SIG_ATOMIC_MIN __INTN_MIN(__SIG_ATOMIC_WIDTH__)
632#define SIG_ATOMIC_MAX __INTN_MAX(__SIG_ATOMIC_WIDTH__)
Ken Dycka2e92842009-11-20 16:44:38 +0000633#define WINT_MIN __INTN_MIN(__WINT_WIDTH__)
634#define WINT_MAX __INTN_MAX(__WINT_WIDTH__)
Chris Lattner2a67f7b2009-02-06 22:59:47 +0000635
636/* FIXME: if we ever support a target with unsigned wchar_t, this should be
637 * 0 .. Max.
638 */
639#ifndef WCHAR_MAX
Ken Dycka2e92842009-11-20 16:44:38 +0000640#define WCHAR_MAX __INTN_MAX(__WCHAR_WIDTH__)
Chris Lattner2a67f7b2009-02-06 22:59:47 +0000641#endif
642#ifndef WCHAR_MIN
Ken Dycka2e92842009-11-20 16:44:38 +0000643#define WCHAR_MIN __INTN_MIN(__WCHAR_WIDTH__)
Chris Lattner2a67f7b2009-02-06 22:59:47 +0000644#endif
645
Chris Lattner2a67f7b2009-02-06 22:59:47 +0000646/* 7.18.4.2 Macros for greatest-width integer constants. */
Ken Dyckfdb43242009-11-20 16:49:10 +0000647#define __INTN_C(n, v) __stdint_join3( INT, n, _C(v))
648#define __UINTN_C(n, v) __stdint_join3(UINT, n, _C(v))
649
650#define INTMAX_C(v) __INTN_C(__INTMAX_WIDTH__, v)
651#define UINTMAX_C(v) __UINTN_C(__INTMAX_WIDTH__, v)
Chris Lattner2a67f7b2009-02-06 22:59:47 +0000652
Eli Friedman6fdca0e2009-05-03 23:00:48 +0000653#endif /* __STDC_HOSTED__ */
654#endif /* __CLANG_STDINT_H */