1 /* Copyright (C) 1997,1998,1999,2000,2001,2006 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
19 * ISO C99: 7.18 Integer types <stdint.h>
26 #ifdef __UCLIBC_HAS_WCHAR__
27 #include <bits/wchar.h>
28 #endif /* __UCLIBC_HAS_WCHAR__ */
29 #include <bits/wordsize.h>
31 /* Exact integral types. */
35 /* There is some amount of overlap with <sys/types.h> as known by inet code */
36 #ifndef __int8_t_defined
37 # define __int8_t_defined
38 typedef signed char int8_t;
39 typedef short int int16_t;
42 typedef long int int64_t;
45 typedef long long int int64_t;
50 typedef unsigned char uint8_t;
51 typedef unsigned short int uint16_t;
52 #ifndef __uint32_t_defined
53 typedef unsigned int uint32_t;
54 # define __uint32_t_defined
57 typedef unsigned long int uint64_t;
60 typedef unsigned long long int uint64_t;
67 typedef signed char int_least8_t;
68 typedef short int int_least16_t;
69 typedef int int_least32_t;
71 typedef long int int_least64_t;
74 typedef long long int int_least64_t;
78 typedef unsigned char uint_least8_t;
79 typedef unsigned short int uint_least16_t;
80 typedef unsigned int uint_least32_t;
82 typedef unsigned long int uint_least64_t;
85 typedef unsigned long long int uint_least64_t;
92 typedef signed char int_fast8_t;
94 typedef long int int_fast16_t;
95 typedef long int int_fast32_t;
96 typedef long int int_fast64_t;
98 typedef int int_fast16_t;
99 typedef int int_fast32_t;
101 typedef long long int int_fast64_t;
105 typedef unsigned char uint_fast8_t;
107 typedef unsigned long int uint_fast16_t;
108 typedef unsigned long int uint_fast32_t;
109 typedef unsigned long int uint_fast64_t;
111 typedef unsigned int uint_fast16_t;
112 typedef unsigned int uint_fast32_t;
114 typedef unsigned long long int uint_fast64_t;
118 /* Types for `void *' pointers. */
120 # ifndef __intptr_t_defined
121 typedef long int intptr_t;
122 # define __intptr_t_defined
124 typedef unsigned long int uintptr_t;
126 # ifndef __intptr_t_defined
127 typedef int intptr_t;
128 # define __intptr_t_defined
130 typedef unsigned int uintptr_t;
134 /* Largest integral types. */
136 typedef long int intmax_t;
137 typedef unsigned long int uintmax_t;
140 typedef long long int intmax_t;
142 typedef unsigned long long int uintmax_t;
146 # if __WORDSIZE == 64
147 # define __INT64_C(c) c ## L
148 # define __UINT64_C(c) c ## UL
150 # define __INT64_C(c) c ## LL
151 # define __UINT64_C(c) c ## ULL
154 /* Limits of integral types. */
156 /* Minimum of signed integral types. */
157 # define INT8_MIN (-128)
158 # define INT16_MIN (-32767-1)
159 # define INT32_MIN (-2147483647-1)
160 # define INT64_MIN (-__INT64_C(9223372036854775807)-1)
161 /* Maximum of signed integral types. */
162 # define INT8_MAX (127)
163 # define INT16_MAX (32767)
164 # define INT32_MAX (2147483647)
165 # define INT64_MAX (__INT64_C(9223372036854775807))
167 /* Maximum of unsigned integral types. */
168 # define UINT8_MAX (255)
169 # define UINT16_MAX (65535)
170 # define UINT32_MAX (4294967295U)
171 # define UINT64_MAX (__UINT64_C(18446744073709551615))
174 /* Minimum of signed integral types having a minimum size. */
175 # define INT_LEAST8_MIN (-128)
176 # define INT_LEAST16_MIN (-32767-1)
177 # define INT_LEAST32_MIN (-2147483647-1)
178 # define INT_LEAST64_MIN (-__INT64_C(9223372036854775807)-1)
179 /* Maximum of signed integral types having a minimum size. */
180 # define INT_LEAST8_MAX (127)
181 # define INT_LEAST16_MAX (32767)
182 # define INT_LEAST32_MAX (2147483647)
183 # define INT_LEAST64_MAX (__INT64_C(9223372036854775807))
185 /* Maximum of unsigned integral types having a minimum size. */
186 # define UINT_LEAST8_MAX (255)
187 # define UINT_LEAST16_MAX (65535)
188 # define UINT_LEAST32_MAX (4294967295U)
189 # define UINT_LEAST64_MAX (__UINT64_C(18446744073709551615))
192 /* Minimum of fast signed integral types having a minimum size. */
193 # define INT_FAST8_MIN (-128)
194 # if __WORDSIZE == 64
195 # define INT_FAST16_MIN (-9223372036854775807L-1)
196 # define INT_FAST32_MIN (-9223372036854775807L-1)
198 # define INT_FAST16_MIN (-2147483647-1)
199 # define INT_FAST32_MIN (-2147483647-1)
201 # define INT_FAST64_MIN (-__INT64_C(9223372036854775807)-1)
202 /* Maximum of fast signed integral types having a minimum size. */
203 # define INT_FAST8_MAX (127)
204 # if __WORDSIZE == 64
205 # define INT_FAST16_MAX (9223372036854775807L)
206 # define INT_FAST32_MAX (9223372036854775807L)
208 # define INT_FAST16_MAX (2147483647)
209 # define INT_FAST32_MAX (2147483647)
211 # define INT_FAST64_MAX (__INT64_C(9223372036854775807))
213 /* Maximum of fast unsigned integral types having a minimum size. */
214 # define UINT_FAST8_MAX (255)
215 # if __WORDSIZE == 64
216 # define UINT_FAST16_MAX (18446744073709551615UL)
217 # define UINT_FAST32_MAX (18446744073709551615UL)
219 # define UINT_FAST16_MAX (4294967295U)
220 # define UINT_FAST32_MAX (4294967295U)
222 # define UINT_FAST64_MAX (__UINT64_C(18446744073709551615))
225 /* Values to test for integral types holding `void *' pointer. */
226 # if __WORDSIZE == 64
227 # define INTPTR_MIN (-9223372036854775807L-1)
228 # define INTPTR_MAX (9223372036854775807L)
229 # define UINTPTR_MAX (18446744073709551615UL)
231 # define INTPTR_MIN (-2147483647-1)
232 # define INTPTR_MAX (2147483647)
233 # define UINTPTR_MAX (4294967295U)
237 /* Minimum for largest signed integral type. */
238 # define INTMAX_MIN (-__INT64_C(9223372036854775807)-1)
239 /* Maximum for largest signed integral type. */
240 # define INTMAX_MAX (__INT64_C(9223372036854775807))
242 /* Maximum for largest unsigned integral type. */
243 # define UINTMAX_MAX (__UINT64_C(18446744073709551615))
245 /* Limits of other integer types. */
247 /* Limits of `ptrdiff_t' type. */
248 # if __WORDSIZE == 64
249 # define PTRDIFF_MIN (-9223372036854775807L-1)
250 # define PTRDIFF_MAX (9223372036854775807L)
252 # define PTRDIFF_MIN (-2147483647-1)
253 # define PTRDIFF_MAX (2147483647)
256 /* Limits of `sig_atomic_t'. */
257 # define SIG_ATOMIC_MIN (-2147483647-1)
258 # define SIG_ATOMIC_MAX (2147483647)
260 /* Limit of `size_t' type. */
261 # if __WORDSIZE == 64
262 # define SIZE_MAX (18446744073709551615UL)
264 # define SIZE_MAX (4294967295U)
267 #ifdef __UCLIBC_HAS_WCHAR__
268 /* Limits of `wchar_t'. */
270 /* These constants might also be defined in <wchar.h>. */
271 # define WCHAR_MIN __WCHAR_MIN
272 # define WCHAR_MAX __WCHAR_MAX
275 /* Limits of `wint_t'. */
276 # define WINT_MIN (0u)
277 # define WINT_MAX (4294967295u)
278 #endif /* __UCLIBC_HAS_WCHAR__ */
283 # define INT16_C(c) c
284 # define INT32_C(c) c
285 # if __WORDSIZE == 64
286 # define INT64_C(c) c ## L
288 # define INT64_C(c) c ## LL
292 # define UINT8_C(c) c
293 # define UINT16_C(c) c
294 # define UINT32_C(c) c ## U
295 # if __WORDSIZE == 64
296 # define UINT64_C(c) c ## UL
298 # define UINT64_C(c) c ## ULL
302 # if __WORDSIZE == 64
303 # define INTMAX_C(c) c ## L
304 # define UINTMAX_C(c) c ## UL
306 # define INTMAX_C(c) c ## LL
307 # define UINTMAX_C(c) c ## ULL
310 #endif /* stdint.h */