Embedded Artistry libc
C Standard Library Support for Bare-metal Systems
stdint.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2000-2010 Apple Inc.
3  * All rights reserved.
4  */
5 
6 #ifndef STDINT_H_
7 #define STDINT_H_
8 
9 #include <limits.h>
10 
11 #if __LP64__
12 #define __WORDSIZE 64
13 #else
14 #define __WORDSIZE 32
15 #endif
16 
17 /* from ISO/IEC 988:1999 spec */
18 
19 /* 7.18.1.1 Exact-width integer types */
20 #include <_types/_int16_t.h>
21 #include <_types/_int32_t.h>
22 #include <_types/_int64_t.h>
23 #include <_types/_int8_t.h>
24 #include <_types/_uint16_t.h>
25 #include <_types/_uint32_t.h>
26 #include <_types/_uint64_t.h>
27 #include <_types/_uint8_t.h>
28 
29 /* 7.18.1.2 Minimum-width integer types */
31 typedef int8_t int_least8_t;
32 
34 typedef int16_t int_least16_t;
35 
37 typedef int32_t int_least32_t;
38 
40 typedef int64_t int_least64_t;
41 
43 typedef uint8_t uint_least8_t;
44 
46 typedef uint16_t uint_least16_t;
47 
49 typedef uint32_t uint_least32_t;
50 
52 typedef uint64_t uint_least64_t;
53 
54 /* 7.18.1.3 Fastest-width integer types */
56 typedef int8_t int_fast8_t;
57 
59 typedef int32_t int_fast16_t;
60 
62 typedef int32_t int_fast32_t;
63 
65 typedef int64_t int_fast64_t;
66 
68 typedef uint8_t uint_fast8_t;
69 
71 typedef uint32_t uint_fast16_t;
72 
74 typedef uint32_t uint_fast32_t;
75 
77 typedef uint64_t uint_fast64_t;
78 
79 /* 7.18.1.4 Integer types capable of holding object pointers */
80 #include <_types/_intptr_t.h>
81 #include <_types/_uintptr_t.h>
82 
83 /* 7.18.1.5 Greatest-width integer types */
84 #include <_types/_intmax_t.h>
85 #include <_types/_uintmax_t.h>
86 
87 /* 7.18.2 Limits of specified-width integer types:
88  * These #defines specify the minimum and maximum limits
89  * of each of the types declared above.
90  */
91 
92 /* 7.18.2.1 Limits of exact-width integer types */
94 #define INT8_MAX 127
95 
97 #define INT16_MAX 32767
98 
100 #define INT32_MAX 2147483647
101 
103 #define INT64_MAX 9223372036854775807LL
104 
106 #define INT8_MIN -128
107 
109 #define INT16_MIN -32768
110 /*
111  Note: the literal "most negative int" cannot be written in C --
112  the rules in the standard (section 6.4.4.1 in C99) will give it
113  an unsigned type, so INT32_MIN (and the most negative member of
114  any larger signed type) must be written via a constant expression.
115 */
117 #define INT32_MIN (-INT32_MAX - 1)
118 
120 #define INT64_MIN (-INT64_MAX - 1)
121 
123 #define UINT8_MAX 255
124 
126 #define UINT16_MAX 65535
127 
129 #define UINT32_MAX 4294967295U
130 
132 #define UINT64_MAX 18446744073709551615ULL
133 
134 /* 7.18.2.2 Limits of minimum-width integer types */
136 #define INT_LEAST8_MIN INT8_MIN
137 
139 #define INT_LEAST16_MIN INT16_MIN
140 
142 #define INT_LEAST32_MIN INT32_MIN
143 
145 #define INT_LEAST64_MIN INT64_MIN
146 
148 #define UINT_LEAST8_MIN UINT8_MIN
149 
151 #define UINT_LEAST16_MIN UINT16_MIN
152 
154 #define UINT_LEAST32_MIN UINT32_MIN
155 
157 #define UINT_LEAST64_MIN UINT64_MIN
158 
160 #define INT_LEAST8_MAX INT8_MAX
161 
163 #define INT_LEAST16_MAX INT16_MAX
164 
166 #define INT_LEAST32_MAX INT32_MAX
167 
169 #define INT_LEAST64_MAX INT64_MAX
170 
172 #define UINT_LEAST8_MAX UINT8_MAX
173 
175 #define UINT_LEAST16_MAX UINT16_MAX
176 
178 #define UINT_LEAST32_MAX UINT32_MAX
179 
181 #define UINT_LEAST64_MAX UINT64_MAX
182 
183 /* 7.18.2.3 Limits of fastest minimum-width integer types */
185 #define INT_FAST8_MIN INT8_MIN
186 
188 #define INT_FAST16_MIN INT32_MIN
189 
191 #define INT_FAST32_MIN INT32_MIN
192 
194 #define INT_FAST64_MIN INT64_MIN
195 
197 #define INT_FAST8_MAX INT8_MAX
198 
200 #define INT_FAST16_MAX INT32_MAX
201 
203 #define INT_FAST32_MAX INT32_MAX
204 
206 #define INT_FAST64_MAX INT64_MAX
207 
209 #define UINT_FAST8_MIN UINT8_MIN
210 
212 #define UINT_FAST16_MIN UINT32_MIN
213 
215 #define UINT_FAST32_MIN UINT32_MIN
216 
218 #define UINT_FAST64_MIN UINT64_MIN
219 
221 #define UINT_FAST8_MAX UINT8_MAX
222 
224 #define UINT_FAST16_MAX UINT32_MAX
225 
227 #define UINT_FAST32_MAX UINT32_MAX
228 
230 #define UINT_FAST64_MAX UINT64_MAX
231 
232 #if __WORDSIZE == 64
233 
234 #define INTPTR_MIN INT64_MIN
235 
237 #define INTPTR_MAX INT64_MAX
238 
240 #define UINTPTR_MAX UINT64_MAX
241 
243 #define PTRDIFF_MIN INT64_MIN
244 
246 #define PTRDIFF_MAX INT64_MAX
247 
249 #define SIZE_MAX UINT64_MAX
250 
251 #else // __WORDSIZE is 32 bits
252 
254 #define INTPTR_MIN INT32_MIN
255 
257 #define INTPTR_MAX INT32_MAX
258 
260 #define UINTPTR_MAX UINT32_MAX
261 
263 #define PTRDIFF_MIN INT32_MIN
264 
266 #define PTRDIFF_MAX INT32_MAX
267 #endif
268 
270 #define INTMAX_MIN INT64_MIN
271 
273 #define INTMAX_MAX INT64_MAX
274 
276 #define UINTMAX_MAX UINT64_MAX
277 
279 #define SIZE_MAX UINT32_MAX
280 
281 #if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1
282 
287 #define RSIZE_MAX (SIZE_MAX >> 1)
288 #endif
289 
290 #ifndef WCHAR_MAX
291 #ifdef __WCHAR_MAX__
292 
294 #define WCHAR_MAX __WCHAR_MAX__
295 #else
296 
298 #define WCHAR_MAX 0x7fffffff
299 #endif
300 #endif
301 
302 /* WCHAR_MIN should be 0 if wchar_t is an unsigned type and
303  (-WCHAR_MAX-1) if wchar_t is a signed type. Unfortunately,
304  it turns out that -fshort-wchar changes the signedness of
305  the type. */
306 #ifndef WCHAR_MIN
307 #if WCHAR_MAX == 0xffff
308 
310 #define WCHAR_MIN 0
311 #else
312 
314 #define WCHAR_MIN (-WCHAR_MAX - 1)
315 #endif
316 #endif
317 
319 #define WINT_MIN INT32_MIN
320 
322 #define WINT_MAX INT32_MAX
323 
325 #define SIG_ATOMIC_MIN INT32_MIN
326 
328 #define SIG_ATOMIC_MAX INT32_MAX
329 
330 /* 7.18.4 Macros for integer constants */
333 #define INT8_C(v) (v)
334 
337 #define INT16_C(v) (v)
338 
341 #define INT32_C(v) (v)
342 
345 #define INT64_C(v) (v##LL)
346 
349 #define UINT8_C(v) (v##U)
350 
353 #define UINT16_C(v) (v##U)
354 
357 #define UINT32_C(v) (v##U)
358 
361 #define UINT64_C(v) (v##ULL)
362 
363 #ifdef __LP64__
364 
367 #define INTMAX_C(v) (v##L)
368 
371 #define UINTMAX_C(v) (v##UL)
372 #else
373 
376 #define INTMAX_C(v) (v##LL)
377 
380 #define UINTMAX_C(v) (v##ULL)
381 #endif
382 
383 #endif /* STDINT_H_ */
int32_t int_fast32_t
Definition: stdint.h:62
int64_t int_fast64_t
Definition: stdint.h:65
int8_t int_fast8_t
Definition: stdint.h:56
uint16_t uint_least16_t
Definition: stdint.h:46
int64_t int_least64_t
Definition: stdint.h:40
uint64_t uint_least64_t
Definition: stdint.h:52
uint32_t uint_fast16_t
Definition: stdint.h:71
int32_t int_least32_t
Definition: stdint.h:37
uint8_t uint_least8_t
Definition: stdint.h:43
int8_t int_least8_t
Definition: stdint.h:31
uint8_t uint_fast8_t
Definition: stdint.h:68
uint32_t uint_least32_t
Definition: stdint.h:49
uint64_t uint_fast64_t
Definition: stdint.h:77
int32_t int_fast16_t
Definition: stdint.h:59
int16_t int_least16_t
Definition: stdint.h:34
uint32_t uint_fast32_t
Definition: stdint.h:74