]>
git.saurik.com Git - apple/xnu.git/blob - EXTERNAL_HEADERS/stdint.h
2 * Copyright (c) 2000-2010 Apple Inc.
6 #ifndef _KERNEL_STDINT_H_
7 #define _KERNEL_STDINT_H_
10 /* For user-space code that may include this header */
11 #include_next <stdint.h>
14 #include <machine/types.h>
22 /* from ISO/IEC 988:1999 spec */
24 /* 7.18.1.1 Exact-width integer types */
25 /* int8_t is defined in <machine/types.h> */
26 /* int16_t is defined in <machine/types.h> */
27 /* int32_t is defined in <machine/types.h> */
28 /* int64_t is defined in <machine/types.h> */
29 typedef u_int8_t
uint8_t; /* u_int8_t is defined in <machine/types.h> */
30 typedef u_int16_t
uint16_t; /* u_int16_t is defined in <machine/types.h> */
31 typedef u_int32_t
uint32_t; /* u_int32_t is defined in <machine/types.h> */
32 typedef u_int64_t
uint64_t; /* u_int64_t is defined in <machine/types.h> */
35 /* 7.18.1.2 Minimum-width integer types */
36 typedef int8_t int_least8_t;
37 typedef int16_t int_least16_t;
38 typedef int32_t int_least32_t;
39 typedef int64_t int_least64_t;
40 typedef uint8_t uint_least8_t;
41 typedef uint16_t uint_least16_t;
42 typedef uint32_t uint_least32_t;
43 typedef uint64_t uint_least64_t;
46 /* 7.18.1.3 Fastest-width integer types */
47 typedef int8_t int_fast8_t;
48 typedef int16_t int_fast16_t;
49 typedef int32_t int_fast32_t;
50 typedef int64_t int_fast64_t;
51 typedef uint8_t uint_fast8_t;
52 typedef uint16_t uint_fast16_t;
53 typedef uint32_t uint_fast32_t;
54 typedef uint64_t uint_fast64_t;
57 /* 7.18.1.4 Integer types capable of holding object pointers */
58 /* intptr_t is defined in <machine/types.h> */
59 /* uintptr_t is defined in <machine/types.h> */
62 /* 7.18.1.5 Greatest-width integer types */
63 typedef long long intmax_t;
64 typedef unsigned long long uintmax_t;
66 /* 7.18.2 Limits of specified-width integer types:
67 * These #defines specify the minimum and maximum limits
68 * of each of the types declared above.
72 /* 7.18.2.1 Limits of exact-width integer types */
74 #define INT16_MAX 32767
75 #define INT32_MAX 2147483647
76 #define INT64_MAX 9223372036854775807LL
79 #define INT16_MIN -32768
81 Note: the literal "most negative int" cannot be written in C --
82 the rules in the standard (section 6.4.4.1 in C99) will give it
83 an unsigned type, so INT32_MIN (and the most negative member of
84 any larger signed type) must be written via a constant expression.
86 #define INT32_MIN (-INT32_MAX-1)
87 #define INT64_MIN (-INT64_MAX-1)
90 #define UINT16_MAX 65535
91 #define UINT32_MAX 4294967295U
92 #define UINT64_MAX 18446744073709551615ULL
94 /* 7.18.2.2 Limits of minimum-width integer types */
95 #define INT_LEAST8_MIN INT8_MIN
96 #define INT_LEAST16_MIN INT16_MIN
97 #define INT_LEAST32_MIN INT32_MIN
98 #define INT_LEAST64_MIN INT64_MIN
100 #define INT_LEAST8_MAX INT8_MAX
101 #define INT_LEAST16_MAX INT16_MAX
102 #define INT_LEAST32_MAX INT32_MAX
103 #define INT_LEAST64_MAX INT64_MAX
105 #define UINT_LEAST8_MAX UINT8_MAX
106 #define UINT_LEAST16_MAX UINT16_MAX
107 #define UINT_LEAST32_MAX UINT32_MAX
108 #define UINT_LEAST64_MAX UINT64_MAX
110 /* 7.18.2.3 Limits of fastest minimum-width integer types */
111 #define INT_FAST8_MIN INT8_MIN
112 #define INT_FAST16_MIN INT16_MIN
113 #define INT_FAST32_MIN INT32_MIN
114 #define INT_FAST64_MIN INT64_MIN
116 #define INT_FAST8_MAX INT8_MAX
117 #define INT_FAST16_MAX INT16_MAX
118 #define INT_FAST32_MAX INT32_MAX
119 #define INT_FAST64_MAX INT64_MAX
121 #define UINT_FAST8_MAX UINT8_MAX
122 #define UINT_FAST16_MAX UINT16_MAX
123 #define UINT_FAST32_MAX UINT32_MAX
124 #define UINT_FAST64_MAX UINT64_MAX
126 /* 7.18.2.4 Limits of integer types capable of holding object pointers */
129 #define INTPTR_MIN INT64_MIN
130 #define INTPTR_MAX INT64_MAX
132 #define INTPTR_MIN INT32_MIN
133 #define INTPTR_MAX INT32_MAX
137 #define UINTPTR_MAX UINT64_MAX
139 #define UINTPTR_MAX UINT32_MAX
142 /* 7.18.2.5 Limits of greatest-width integer types */
143 #define INTMAX_MIN INT64_MIN
144 #define INTMAX_MAX INT64_MAX
146 #define UINTMAX_MAX UINT64_MAX
150 #define PTRDIFF_MIN INT64_MIN
151 #define PTRDIFF_MAX INT64_MAX
153 #define PTRDIFF_MIN INT32_MIN
154 #define PTRDIFF_MAX INT32_MAX
157 /* We have no sig_atomic_t yet, so no SIG_ATOMIC_{MIN,MAX}.
158 Should end up being {-127,127} or {0,255} ... or bigger.
159 My bet would be on one of {U}INT32_{MIN,MAX}. */
162 #define SIZE_MAX UINT64_MAX
164 #define SIZE_MAX UINT32_MAX
167 #if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1
168 #define RSIZE_MAX (SIZE_MAX >> 1)
172 # ifdef __WCHAR_MAX__
173 # define WCHAR_MAX __WCHAR_MAX__
175 # define WCHAR_MAX 0x7fffffff
179 /* WCHAR_MIN should be 0 if wchar_t is an unsigned type and
180 (-WCHAR_MAX-1) if wchar_t is a signed type. Unfortunately,
181 it turns out that -fshort-wchar changes the signedness of
184 # if WCHAR_MAX == 0xffff
187 # define WCHAR_MIN (-WCHAR_MAX-1)
191 #define WINT_MIN INT32_MIN
192 #define WINT_MAX INT32_MAX
194 #define SIG_ATOMIC_MIN INT32_MIN
195 #define SIG_ATOMIC_MAX INT32_MAX
197 /* 7.18.4 Macros for integer constants */
198 #define INT8_C(v) (v)
199 #define INT16_C(v) (v)
200 #define INT32_C(v) (v)
201 #define INT64_C(v) (v ## LL)
203 #define UINT8_C(v) (v ## U)
204 #define UINT16_C(v) (v ## U)
205 #define UINT32_C(v) (v ## U)
206 #define UINT64_C(v) (v ## ULL)
208 #define INTMAX_C(v) (v ## LL)
209 #define UINTMAX_C(v) (v ## ULL)
213 #endif /* _KERNEL_STDINT_H_ */