1 /* Copyright (C) 1997-2016 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>
25 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
26 #include <bits/libc-header-start.h>
27 #include <bits/wchar.h>
28 #include <bits/wordsize.h>
30 /* Exact integral types. */
34 /* There is some amount of overlap with <sys/types.h> as known by inet code */
35 #ifndef __int8_t_defined
36 # define __int8_t_defined
37 typedef signed char int8_t;
38 typedef short int int16_t;
41 typedef long int int64_t;
44 typedef long long int int64_t;
49 typedef unsigned char uint8_t;
50 typedef unsigned short int uint16_t;
51 #ifndef __uint32_t_defined
52 typedef unsigned int uint32_t;
53 # define __uint32_t_defined
56 typedef unsigned long int uint64_t;
59 typedef unsigned long long int uint64_t;
66 typedef signed char int_least8_t;
67 typedef short int int_least16_t;
68 typedef int int_least32_t;
70 typedef long int int_least64_t;
73 typedef long long int int_least64_t;
77 typedef unsigned char uint_least8_t;
78 typedef unsigned short int uint_least16_t;
79 typedef unsigned int uint_least32_t;
81 typedef unsigned long int uint_least64_t;
84 typedef unsigned long long int uint_least64_t;
91 typedef signed char int_fast8_t;
93 typedef long int int_fast16_t;
94 typedef long int int_fast32_t;
95 typedef long int int_fast64_t;
97 typedef int int_fast16_t;
98 typedef int int_fast32_t;
100 typedef long long int int_fast64_t;
104 typedef unsigned char uint_fast8_t;
106 typedef unsigned long int uint_fast16_t;
107 typedef unsigned long int uint_fast32_t;
108 typedef unsigned long int uint_fast64_t;
110 typedef unsigned int uint_fast16_t;
111 typedef unsigned int uint_fast32_t;
113 typedef unsigned long long int uint_fast64_t;
117 /* Types for `void *' pointers. */
119 # ifndef __intptr_t_defined
120 typedef long int intptr_t;
121 # define __intptr_t_defined
123 typedef unsigned long int uintptr_t;
125 # ifndef __intptr_t_defined
126 typedef int intptr_t;
127 # define __intptr_t_defined
129 typedef unsigned int uintptr_t;
133 /* Largest integral types. */
135 typedef long int intmax_t;
136 typedef unsigned long int uintmax_t;
139 typedef long long int intmax_t;
141 typedef unsigned long long int uintmax_t;
145 # if __WORDSIZE == 64
146 # define __INT64_C(c) c ## L
147 # define __UINT64_C(c) c ## UL
149 # define __INT64_C(c) c ## LL
150 # define __UINT64_C(c) c ## ULL
153 /* Limits of integral types. */
155 /* Minimum of signed integral types. */
156 # define INT8_MIN (-128)
157 # define INT16_MIN (-32767-1)
158 # define INT32_MIN (-2147483647-1)
159 # define INT64_MIN (-__INT64_C(9223372036854775807)-1)
160 /* Maximum of signed integral types. */
161 # define INT8_MAX (127)
162 # define INT16_MAX (32767)
163 # define INT32_MAX (2147483647)
164 # define INT64_MAX (__INT64_C(9223372036854775807))
166 /* Maximum of unsigned integral types. */
167 # define UINT8_MAX (255)
168 # define UINT16_MAX (65535)
169 # define UINT32_MAX (4294967295U)
170 # define UINT64_MAX (__UINT64_C(18446744073709551615))
173 /* Minimum of signed integral types having a minimum size. */
174 # define INT_LEAST8_MIN (-128)
175 # define INT_LEAST16_MIN (-32767-1)
176 # define INT_LEAST32_MIN (-2147483647-1)
177 # define INT_LEAST64_MIN (-__INT64_C(9223372036854775807)-1)
178 /* Maximum of signed integral types having a minimum size. */
179 # define INT_LEAST8_MAX (127)
180 # define INT_LEAST16_MAX (32767)
181 # define INT_LEAST32_MAX (2147483647)
182 # define INT_LEAST64_MAX (__INT64_C(9223372036854775807))
184 /* Maximum of unsigned integral types having a minimum size. */
185 # define UINT_LEAST8_MAX (255)
186 # define UINT_LEAST16_MAX (65535)
187 # define UINT_LEAST32_MAX (4294967295U)
188 # define UINT_LEAST64_MAX (__UINT64_C(18446744073709551615))
191 /* Minimum of fast signed integral types having a minimum size. */
192 # define INT_FAST8_MIN (-128)
193 # if __WORDSIZE == 64
194 # define INT_FAST16_MIN (-9223372036854775807L-1)
195 # define INT_FAST32_MIN (-9223372036854775807L-1)
197 # define INT_FAST16_MIN (-2147483647-1)
198 # define INT_FAST32_MIN (-2147483647-1)
200 # define INT_FAST64_MIN (-__INT64_C(9223372036854775807)-1)
201 /* Maximum of fast signed integral types having a minimum size. */
202 # define INT_FAST8_MAX (127)
203 # if __WORDSIZE == 64
204 # define INT_FAST16_MAX (9223372036854775807L)
205 # define INT_FAST32_MAX (9223372036854775807L)
207 # define INT_FAST16_MAX (2147483647)
208 # define INT_FAST32_MAX (2147483647)
210 # define INT_FAST64_MAX (__INT64_C(9223372036854775807))
212 /* Maximum of fast unsigned integral types having a minimum size. */
213 # define UINT_FAST8_MAX (255)
214 # if __WORDSIZE == 64
215 # define UINT_FAST16_MAX (18446744073709551615UL)
216 # define UINT_FAST32_MAX (18446744073709551615UL)
218 # define UINT_FAST16_MAX (4294967295U)
219 # define UINT_FAST32_MAX (4294967295U)
221 # define UINT_FAST64_MAX (__UINT64_C(18446744073709551615))
224 /* Values to test for integral types holding `void *' pointer. */
225 # if __WORDSIZE == 64
226 # define INTPTR_MIN (-9223372036854775807L-1)
227 # define INTPTR_MAX (9223372036854775807L)
228 # define UINTPTR_MAX (18446744073709551615UL)
230 # define INTPTR_MIN (-2147483647-1)
231 # define INTPTR_MAX (2147483647)
232 # define UINTPTR_MAX (4294967295U)
236 /* Minimum for largest signed integral type. */
237 # define INTMAX_MIN (-__INT64_C(9223372036854775807)-1)
238 /* Maximum for largest signed integral type. */
239 # define INTMAX_MAX (__INT64_C(9223372036854775807))
241 /* Maximum for largest unsigned integral type. */
242 # 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 # ifdef __WORDSIZE32_SIZE_ULONG
265 # define SIZE_MAX (4294967295UL)
267 # define SIZE_MAX (4294967295U)
271 /* Limits of `wchar_t'. */
273 /* These constants might also be defined in <wchar.h>. */
274 # define WCHAR_MIN __WCHAR_MIN
275 # define WCHAR_MAX __WCHAR_MAX
278 /* Limits of `wint_t'. */
279 # define WINT_MIN (0u)
280 # define WINT_MAX (4294967295u)
284 # define INT16_C(c) c
285 # define INT32_C(c) c
286 # if __WORDSIZE == 64
287 # define INT64_C(c) c ## L
289 # define INT64_C(c) c ## LL
293 # define UINT8_C(c) c
294 # define UINT16_C(c) c
295 # define UINT32_C(c) c ## U
296 # if __WORDSIZE == 64
297 # define UINT64_C(c) c ## UL
299 # define UINT64_C(c) c ## ULL
303 # if __WORDSIZE == 64
304 # define INTMAX_C(c) c ## L
305 # define UINTMAX_C(c) c ## UL
307 # define INTMAX_C(c) c ## LL
308 # define UINTMAX_C(c) c ## ULL
311 #if __GLIBC_USE (IEC_60559_BFP_EXT)
313 # define INT8_WIDTH 8
314 # define UINT8_WIDTH 8
315 # define INT16_WIDTH 16
316 # define UINT16_WIDTH 16
317 # define INT32_WIDTH 32
318 # define UINT32_WIDTH 32
319 # define INT64_WIDTH 64
320 # define UINT64_WIDTH 64
322 # define INT_LEAST8_WIDTH 8
323 # define UINT_LEAST8_WIDTH 8
324 # define INT_LEAST16_WIDTH 16
325 # define UINT_LEAST16_WIDTH 16
326 # define INT_LEAST32_WIDTH 32
327 # define UINT_LEAST32_WIDTH 32
328 # define INT_LEAST64_WIDTH 64
329 # define UINT_LEAST64_WIDTH 64
331 # define INT_FAST8_WIDTH 8
332 # define UINT_FAST8_WIDTH 8
333 # define INT_FAST16_WIDTH __WORDSIZE
334 # define UINT_FAST16_WIDTH __WORDSIZE
335 # define INT_FAST32_WIDTH __WORDSIZE
336 # define UINT_FAST32_WIDTH __WORDSIZE
337 # define INT_FAST64_WIDTH 64
338 # define UINT_FAST64_WIDTH 64
340 # define INTPTR_WIDTH __WORDSIZE
341 # define UINTPTR_WIDTH __WORDSIZE
343 # define INTMAX_WIDTH 64
344 # define UINTMAX_WIDTH 64
346 # define PTRDIFF_WIDTH __WORDSIZE
347 # define SIG_ATOMIC_WIDTH 32
348 # define SIZE_WIDTH __WORDSIZE
349 # define WCHAR_WIDTH 32
350 # define WINT_WIDTH 32
354 #endif /* stdint.h */