1 /* Copyright (C) 1997, 1998, 1999, 2000 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, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 * ISO C99: 7.18 Integer types <stdint.h>
28 /*#define __need_wchar_t*/
31 /*#include <bits/wchar.h>*/
32 #include <bits/wordsize.h>
34 /* Exact integral types. */
38 /* There is some amount of overlap with <sys/types.h> as known by inet code */
39 #ifndef __int8_t_defined
40 # define __int8_t_defined
41 typedef signed char int8_t;
42 typedef short int int16_t;
45 typedef long int int64_t;
48 typedef long long int int64_t;
53 typedef unsigned char uint8_t;
54 typedef unsigned short int uint16_t;
55 #ifndef __uint32_t_defined
56 typedef unsigned int uint32_t;
57 # define __uint32_t_defined
60 typedef unsigned long int uint64_t;
63 typedef unsigned long long int uint64_t;
70 typedef signed char int_least8_t;
71 typedef short int int_least16_t;
72 typedef int int_least32_t;
74 typedef long int int_least64_t;
77 typedef long long int int_least64_t;
81 typedef unsigned char uint_least8_t;
82 typedef unsigned short int uint_least16_t;
83 typedef unsigned int uint_least32_t;
85 typedef unsigned long int uint_least64_t;
88 typedef unsigned long long int uint_least64_t;
95 typedef signed char int_fast8_t;
97 typedef long int int_fast16_t;
98 typedef long int int_fast32_t;
99 typedef long int int_fast64_t;
101 typedef int int_fast16_t;
102 typedef int int_fast32_t;
104 typedef long long int int_fast64_t;
108 typedef unsigned char uint_fast8_t;
110 typedef unsigned long int uint_fast16_t;
111 typedef unsigned long int uint_fast32_t;
112 typedef unsigned long int uint_fast64_t;
114 typedef unsigned int uint_fast16_t;
115 typedef unsigned int uint_fast32_t;
117 typedef unsigned long long int uint_fast64_t;
121 /* Types for `void *' pointers. */
123 # ifndef __intptr_t_defined
124 typedef long int intptr_t;
125 # define __intptr_t_defined
127 typedef unsigned long int uintptr_t;
129 # ifndef __intptr_t_defined
130 typedef int intptr_t;
131 # define __intptr_t_defined
133 typedef unsigned int uintptr_t;
137 /* Largest integral types. */
139 typedef long int intmax_t;
140 typedef unsigned long int uintmax_t;
143 typedef long long int intmax_t;
145 typedef unsigned long long int uintmax_t;
149 /* The ISO C99 standard specifies that in C++ implementations these
150 macros should only be defined if explicitly requested. */
151 #if !defined __cplusplus || defined __STDC_LIMIT_MACROS
153 # if __WORDSIZE == 64
154 # define __INT64_C(c) c ## L
155 # define __UINT64_C(c) c ## UL
157 # define __INT64_C(c) c ## LL
158 # define __UINT64_C(c) c ## ULL
161 /* Limits of integral types. */
163 /* Minimum of signed integral types. */
164 # define INT8_MIN (-128)
165 # define INT16_MIN (-32767-1)
166 # define INT32_MIN (-2147483647-1)
167 # define INT64_MIN (-__INT64_C(9223372036854775807)-1)
168 /* Maximum of signed integral types. */
169 # define INT8_MAX (127)
170 # define INT16_MAX (32767)
171 # define INT32_MAX (2147483647)
172 # define INT64_MAX (__INT64_C(9223372036854775807))
174 /* Maximum of unsigned integral types. */
175 # define UINT8_MAX (255)
176 # define UINT16_MAX (65535)
177 # define UINT32_MAX (4294967295U)
178 # define UINT64_MAX (__UINT64_C(18446744073709551615))
181 /* Minimum of signed integral types having a minimum size. */
182 # define INT_LEAST8_MIN (-128)
183 # define INT_LEAST16_MIN (-32767-1)
184 # define INT_LEAST32_MIN (-2147483647-1)
185 # define INT_LEAST64_MIN (-__INT64_C(9223372036854775807)-1)
186 /* Maximum of signed integral types having a minimum size. */
187 # define INT_LEAST8_MAX (127)
188 # define INT_LEAST16_MAX (32767)
189 # define INT_LEAST32_MAX (2147483647)
190 # define INT_LEAST64_MAX (__INT64_C(9223372036854775807))
192 /* Maximum of unsigned integral types having a minimum size. */
193 # define UINT_LEAST8_MAX (255)
194 # define UINT_LEAST16_MAX (65535)
195 # define UINT_LEAST32_MAX (4294967295U)
196 # define UINT_LEAST64_MAX (__UINT64_C(18446744073709551615))
199 /* Minimum of fast signed integral types having a minimum size. */
200 # define INT_FAST8_MIN (-128)
201 # if __WORDSIZE == 64
202 # define INT_FAST16_MIN (-9223372036854775807L-1)
203 # define INT_FAST32_MIN (-9223372036854775807L-1)
205 # define INT_FAST16_MIN (-2147483647-1)
206 # define INT_FAST32_MIN (-2147483647-1)
208 # define INT_FAST64_MIN (-__INT64_C(9223372036854775807)-1)
209 /* Maximum of fast signed integral types having a minimum size. */
210 # define INT_FAST8_MAX (127)
211 # if __WORDSIZE == 64
212 # define INT_FAST16_MAX (9223372036854775807L)
213 # define INT_FAST32_MAX (9223372036854775807L)
215 # define INT_FAST16_MAX (2147483647)
216 # define INT_FAST32_MAX (2147483647)
218 # define INT_FAST64_MAX (__INT64_C(9223372036854775807))
220 /* Maximum of fast unsigned integral types having a minimum size. */
221 # define UINT_FAST8_MAX (255)
222 # if __WORDSIZE == 64
223 # define UINT_FAST16_MAX (18446744073709551615UL)
224 # define UINT_FAST32_MAX (18446744073709551615UL)
226 # define UINT_FAST16_MAX (4294967295U)
227 # define UINT_FAST32_MAX (4294967295U)
229 # define UINT_FAST64_MAX (__UINT64_C(18446744073709551615))
232 /* Values to test for integral types holding `void *' pointer. */
233 # if __WORDSIZE == 64
234 # define INTPTR_MIN (-9223372036854775807L-1)
235 # define INTPTR_MAX (9223372036854775807L)
236 # define UINTPTR_MAX (18446744073709551615UL)
238 # define INTPTR_MIN (-2147483647-1)
239 # define INTPTR_MAX (2147483647)
240 # define UINTPTR_MAX (4294967295U)
243 #if !defined(__H8300H__) && !defined(__H8300S__)
244 /* Minimum for largest signed integral type. */
245 # define INTMAX_MIN (-__INT64_C(9223372036854775807)-1)
246 /* Maximum for largest signed integral type. */
247 # define INTMAX_MAX (__INT64_C(9223372036854775807))
249 /* Maximum for largest unsigned integral type. */
250 # define UINTMAX_MAX (__UINT64_C(18446744073709551615))
252 /* Minimum for largest signed integral type. */
253 # define INTMAX_MIN (-LONG_LONG_MAX-1)
254 /* Maximum for largest signed integral type. */
255 # define INTMAX_MAX (LONG_LONG_MAX)
257 /* Maximum for largest unsigned integral type. */
258 # define UINTMAX_MAX (LONG_LONG_MAX<<1+1)
261 /* Limits of other integer types. */
263 /* Limits of `ptrdiff_t' type. */
264 # if __WORDSIZE == 64
265 # define PTRDIFF_MIN (-9223372036854775807L-1)
266 # define PTRDIFF_MAX (9223372036854775807L)
268 # define PTRDIFF_MIN (-2147483647-1)
269 # define PTRDIFF_MAX (2147483647)
272 /* Limits of `sig_atomic_t'. */
273 # define SIG_ATOMIC_MIN (-2147483647-1)
274 # define SIG_ATOMIC_MAX (2147483647)
276 /* Limit of `size_t' type. */
277 # if __WORDSIZE == 64
278 # define SIZE_MAX (18446744073709551615UL)
280 # define SIZE_MAX (4294967295U)
284 /* Limits of `wchar_t'. */
286 /* These constants might also be defined in <wchar.h>. */
287 # define WCHAR_MIN __WCHAR_MIN
288 # define WCHAR_MAX __WCHAR_MAX
292 /* Limits of `wint_t'. */
293 # define WINT_MIN (0u)
294 # define WINT_MAX (4294967295u)
296 #endif /* C++ && limit macros */
299 /* The ISO C99 standard specifies that in C++ implementations these
300 should only be defined if explicitly requested. */
301 #if !defined __cplusplus || defined __STDC_CONSTANT_MACROS
305 # define INT16_C(c) c
306 # define INT32_C(c) c
307 # if __WORDSIZE == 64
308 # define INT64_C(c) c ## L
310 # define INT64_C(c) c ## LL
314 # define UINT8_C(c) c ## U
315 # define UINT16_C(c) c ## U
316 # define UINT32_C(c) c ## U
317 # if __WORDSIZE == 64
318 # define UINT64_C(c) c ## UL
320 # define UINT64_C(c) c ## ULL
324 # if __WORDSIZE == 64
325 # define INTMAX_C(c) c ## L
326 # define UINTMAX_C(c) c ## UL
328 # define INTMAX_C(c) c ## LL
329 # define UINTMAX_C(c) c ## ULL
332 #endif /* C++ && constant macros */
334 #endif /* stdint.h */