1 /* Copyright (C) 1997, 1998, 1999 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 Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 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 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
20 * ISO C 9X: 7.18 Integer types <stdint.h>
27 #define __need_wchar_t
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 typedef unsigned int uint32_t;
54 typedef unsigned long int uint64_t;
57 typedef unsigned long long int uint64_t;
64 typedef signed char int_least8_t;
65 typedef short int int_least16_t;
66 typedef int int_least32_t;
68 typedef long int int_least64_t;
71 typedef long long int int_least64_t;
75 typedef unsigned char uint_least8_t;
76 typedef unsigned short int uint_least16_t;
77 typedef unsigned int uint_least32_t;
79 typedef unsigned long int uint_least64_t;
82 typedef unsigned long long int uint_least64_t;
89 typedef signed char int_fast8_t;
91 typedef long int int_fast16_t;
92 typedef long int int_fast32_t;
93 typedef long int int_fast64_t;
95 typedef int int_fast16_t;
96 typedef int int_fast32_t;
98 typedef long long int int_fast64_t;
102 typedef unsigned char uint_fast8_t;
104 typedef unsigned long int uint_fast16_t;
105 typedef unsigned long int uint_fast32_t;
106 typedef unsigned long int uint_fast64_t;
108 typedef unsigned int uint_fast16_t;
109 typedef unsigned int uint_fast32_t;
111 typedef unsigned long long int uint_fast64_t;
115 /* Types for `void *' pointers. */
118 typedef long int intptr_t;
119 # define intptr_t intptr_t
121 typedef unsigned long int uintptr_t;
124 typedef int intptr_t;
125 # define intptr_t intptr_t
127 typedef unsigned int uintptr_t;
131 /* Largest integral types. */
133 typedef long int intmax_t;
134 typedef unsigned long int uintmax_t;
137 typedef long long int intmax_t;
139 typedef unsigned long long int uintmax_t;
143 /* The ISO C 9X standard specifies that in C++ implementations these
144 macros should only be defined if explicitly requested. */
145 #if !defined __cplusplus || defined __STDC_LIMIT_MACROS
147 # if __WORDSIZE == 64
148 # define __INT64_C(c) c ## L
149 # define __UINT64_C(c) c ## UL
151 # define __INT64_C(c) c ## LL
152 # define __UINT64_C(c) c ## ULL
155 /* Limits of integral types. */
157 /* Minimum of signed integral types. */
158 # define INT8_MIN (-128)
159 # define INT16_MIN (-32767-1)
160 # define INT32_MIN (-2147483647-1)
161 # define INT64_MIN (-__INT64_C(9223372036854775807)-1)
162 /* Maximum of signed integral types. */
163 # define INT8_MAX (127)
164 # define INT16_MAX (32767)
165 # define INT32_MAX (2147483647)
166 # define INT64_MAX (__INT64_C(9223372036854775807))
168 /* Maximum of unsigned integral types. */
169 # define UINT8_MAX (255U)
170 # define UINT16_MAX (65535U)
171 # define UINT32_MAX (4294967295U)
172 # define UINT64_MAX (__UINT64_C(18446744073709551615))
175 /* Minimum of signed integral types having a minimum size. */
176 # define INT_LEAST8_MIN (-128)
177 # define INT_LEAST16_MIN (-32767-1)
178 # define INT_LEAST32_MIN (-2147483647-1)
179 # define INT_LEAST64_MIN (-__INT64_C(9223372036854775807)-1)
180 /* Maximum of signed integral types having a minimum size. */
181 # define INT_LEAST8_MAX (127)
182 # define INT_LEAST16_MAX (32767)
183 # define INT_LEAST32_MAX (2147483647)
184 # define INT_LEAST64_MAX (__INT64_C(9223372036854775807))
186 /* Maximum of unsigned integral types having a minimum size. */
187 # define UINT_LEAST8_MAX (255U)
188 # define UINT_LEAST16_MAX (65535U)
189 # define UINT_LEAST32_MAX (4294967295U)
190 # define UINT_LEAST64_MAX (__UINT64_C(18446744073709551615))
193 /* Minimum of fast signed integral types having a minimum size. */
194 # define INT_FAST8_MIN (-128)
195 # if __WORDSIZE == 64
196 # define INT_FAST16_MIN (-9223372036854775807L-1)
197 # define INT_FAST32_MIN (-9223372036854775807L-1)
199 # define INT_FAST16_MIN (-2147483647-1)
200 # define INT_FAST32_MIN (-2147483647-1)
202 # define INT_FAST64_MIN (-__INT64_C(9223372036854775807)-1)
203 /* Maximum of fast signed integral types having a minimum size. */
204 # define INT_FAST8_MAX (127)
205 # if __WORDSIZE == 64
206 # define INT_FAST16_MAX (9223372036854775807L)
207 # define INT_FAST32_MAX (9223372036854775807L)
209 # define INT_FAST16_MAX (2147483647)
210 # define INT_FAST32_MAX (2147483647)
212 # define INT_FAST64_MAX (__INT64_C(9223372036854775807))
214 /* Maximum of fast unsigned integral types having a minimum size. */
215 # define UINT_FAST8_MAX (255U)
216 # if __WORDSIZE == 64
217 # define UINT_FAST16_MAX (18446744073709551615UL)
218 # define UINT_FAST32_MAX (18446744073709551615UL)
220 # define UINT_FAST16_MAX (4294967295U)
221 # define UINT_FAST32_MAX (4294967295U)
223 # define UINT_FAST64_MAX (__UINT64_C(18446744073709551615))
226 /* Values to test for integral types holding `void *' pointer. */
227 # if __WORDSIZE == 64
228 # define INTPTR_MIN (-9223372036854775807L-1)
229 # define INTPTR_MAX (9223372036854775807L)
230 # define UINTPTR_MAX (18446744073709551615UL)
232 # define INTPTR_MIN (-2147483647-1)
233 # define INTPTR_MAX (2147483647)
234 # define UINTPTR_MAX (4294967295U)
238 /* Minimum for largest signed integral type. */
239 # define INTMAX_MIN (-__INT64_C(9223372036854775807)-1)
240 /* Maximum for largest signed integral type. */
241 # define INTMAX_MAX (__INT64_C(9223372036854775807))
243 /* Maximum for largest unsigned integral type. */
244 # define UINTMAX_MAX (__UINT64_C(18446744073709551615))
247 /* Limits of other integer types. */
249 /* Limits of `ptrdiff_t' type. */
250 # if __WORDSIZE == 64
251 # define PTRDIFF_MIN (-9223372036854775807L-1)
252 # define PTRDIFF_MAX (9223372036854775807L)
254 # define PTRDIFF_MIN (-2147483647-1)
255 # define PTRDIFF_MAX (2147483647)
258 /* Limits of `sig_atomic_t'. */
259 # define SIG_ATOMIC_MIN (-2147483647-1)
260 # define SIG_ATOMIC_MAX (2147483647)
262 /* Limit of `size_t' type. */
263 # if __WORDSIZE == 64
264 # define SIZE_MAX (18446744073709551615UL)
266 # define SIZE_MAX (4294967295U)
269 /* Limits of `wchar_t'. */
271 /* These constants might also be defined in <wchar.h>. */
272 # define WCHAR_MIN (0)
273 # define WCHAR_MAX (2147483647)
276 /* Limits of `wint_t'. */
277 # define WINT_MIN (0)
278 # define WINT_MAX (2147483647)
280 #endif /* C++ && limit macros */
283 /* The ISO C 9X standard specifies that in C++ implementations these
284 should only be defined if explicitly requested. */
285 #if !defined __cplusplus || defined __STDC_CONSTANT_MACROS
289 # define INT16_C(c) c
290 # define INT32_C(c) c
291 # if __WORDSIZE == 64
292 # define INT64_C(c) c ## L
294 # define INT64_C(c) c ## LL
298 # define UINT8_C(c) c ## U
299 # define UINT16_C(c) c ## U
300 # define UINT32_C(c) c ## U
301 # if __WORDSIZE == 64
302 # define UINT64_C(c) c ## UL
304 # define UINT64_C(c) c ## ULL
308 # if __WORDSIZE == 64
309 # define INTMAX_C(c) c ## L
310 # define UINTMAX_C(c) c ## UL
312 # define INTMAX_C(c) c ## LL
313 # define UINTMAX_C(c) c ## ULL
316 #endif /* C++ && constant macros */
318 #endif /* stdint.h */