Update.
[glibc.git] / sysdeps / wordsize-64 / inttypes.h
blob8ec8095620a5b3810e04ef9ef56276708eb2d4a2
1 /* Copyright (C) 1997 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.4 Integral types <inttypes.h>
23 #ifndef _INTTYPES_H
25 #define _INTTYPES_H 1
26 #include <features.h>
28 #define __need_wchar_t
29 #include <stddef.h>
31 /* Exact integral types. */
33 /* Signed. */
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;
40 typedef int int32_t;
41 typedef long int int64_t;
42 #endif
44 /* Unsigned. */
45 typedef unsigned char uint8_t;
46 typedef unsigned short int uint16_t;
47 typedef unsigned int uint32_t;
48 typedef unsigned long int uint64_t;
51 /* Largest integral types. */
52 typedef long int intmax_t;
53 typedef unsigned long int uintmax_t;
56 /* Types for `void *' pointers. */
57 typedef long int intptr_t;
58 typedef unsigned long int uintptr_t;
61 /* Efficient types. */
62 typedef long int intfast_t;
63 typedef unsigned long int uintfast_t;
66 /* Small types. */
68 /* Signed. */
69 typedef signed char int_least8_t;
70 typedef short int int_least16_t;
71 typedef int int_least32_t;
72 typedef long int int_least64_t;
74 /* Unsigned. */
75 typedef unsigned char uint_least8_t;
76 typedef unsigned short int uint_least16_t;
77 typedef unsigned int uint_least32_t;
78 typedef unsigned long int uint_least64_t;
81 /* Fast types. */
83 /* Signed. */
84 typedef signed char int_fast8_t;
85 typedef int int_fast16_t;
86 typedef int int_fast32_t;
87 typedef long int int_fast64_t;
89 /* Unsigned. */
90 typedef unsigned char uint_fast8_t;
91 typedef unsigned int uint_fast16_t;
92 typedef unsigned int uint_fast32_t;
93 typedef unsigned long int uint_fast64_t;
96 /* Limits of integral types. */
98 /* Minimum of signed integral types. */
99 #define INT8_MIN (-128)
100 #define INT16_MIN (-32767-1)
101 #define INT32_MIN (-2147483647-1)
102 #define INT64_MIN (-9223372036854775807L-1)
103 /* Maximum of signed integral types. */
104 #define INT8_MAX (127)
105 #define INT16_MAX (32767)
106 #define INT32_MAX (2147483647)
107 #define INT64_MAX (9223372036854775807L)
109 /* Maximum of unsigned integral types. */
110 #define UINT8_MAX (255U)
111 #define UINT16_MAX (65535U)
112 #define UINT32_MAX (4294967295U)
113 #define UINT64_MAX (18446744073709551615uL)
116 /* Minimum of signed integral types having a minimum size. */
117 #define INT_LEAST8_MIN (-128)
118 #define INT_LEAST16_MIN (-32767-1)
119 #define INT_LEAST32_MIN (-2147483647-1)
120 #define INT_LEAST64_MIN (-9223372036854775807L-1)
121 /* Maximum of signed integral types having a minimum size. */
122 #define INT_LEAST8_MAX (127)
123 #define INT_LEAST16_MAX (32767)
124 #define INT_LEAST32_MAX (2147483647)
125 #define INT_LEAST64_MAX (9223372036854775807L)
127 /* Maximum of unsigned integral types having a minimum size. */
128 #define UINT_LEAST8_MAX (255U)
129 #define UINT_LEAST16_MAX (65535U)
130 #define UINT_LEAST32_MAX (4294967295U)
131 #define UINT_LEAST64_MAX (18446744073709551615uL)
134 /* Minimum of fast signed integral types having a minimum size. */
135 #define INT_FAST8_MIN (-128)
136 #define INT_FAST16_MIN (-2147483647-1)
137 #define INT_FAST32_MIN (-2147483647-1)
138 #define INT_FAST64_MIN (-9223372036854775807L-1)
139 /* Maximum of fast signed integral types having a minimum size. */
140 #define INT_FAST8_MAX (127)
141 #define INT_FAST16_MAX (2147483647)
142 #define INT_FAST32_MAX (2147483647)
143 #define INT_FAST64_MAX (9223372036854775807L)
145 /* Maximum of fast unsigned integral types having a minimum size. */
146 #define UINT_FAST8_MAX (255U)
147 #define UINT_FAST16_MAX (4294967295U)
148 #define UINT_FAST32_MAX (4294967295U)
149 #define UINT_FAST64_MAX (18446744073709551615uL)
152 /* Minimum for most efficient signed integral types. */
153 #define INTFAST_MIN (-9223372036854775807L-1)
154 /* Maximum for most efficient signed integral types. */
155 #define INTFAST_MAX (9223372036854775807L)
157 /* Maximum for most efficient unsigned integral types. */
158 #define UINTFAST_MAX (18446744073709551615uL)
161 /* Minimum for largest signed integral type. */
162 #define INTMAX_MIN (-9223372036854775807L-1)
163 /* Maximum for largest signed integral type. */
164 #define INTMAX_MAX (9223372036854775807L)
166 /* Maximum for largest unsigned integral type. */
167 #define UINTMAX_MAX (18446744073709551615uL)
170 /* Values to test for integral types holding `void *' pointer. */
171 #define INTPTR_MAX (9223372036854775807L)
172 #define UINTPTR_MAX (18446744073709551615uL)
175 /* Signed. */
176 #define INT8_C(c) ((int8_t) c)
177 #define INT16_C(c) ((int16_t) c)
178 #define INT32_C(c) ((int32_t) c)
179 #define INT64_C(c) ((int64_t) __CONCAT (c,l))
181 /* Unsigned. */
182 #define UINT8_C(c) ((uint8_t) __CONCAT (c,u))
183 #define UINT16_C(c) ((uint16_t) __CONCAT (c,u))
184 #define UINT32_C(c) ((uint32_t) __CONCAT (c,u))
185 #define UINT64_C(c) ((uint64_t) __CONCAT (c,ul))
187 /* Maximal type. */
188 #define INTMAX_C(c) ((intmax_t) __CONCAT (c,l))
189 #define UINTMAX_C(c) ((uintmax_t) __CONCAT (c,ul))
192 /* Macros for printing format specifiers. */
194 /* Decimal notation. */
195 #define PRId8 "d"
196 #define PRId16 "d"
197 #define PRId32 "d"
198 #define PRId64 "ld"
200 #define PRIdLEAST8 "d"
201 #define PRIdLEAST16 "d"
202 #define PRIdLEAST32 "d"
203 #define PRIdLEAST64 "ld"
205 #define PRIdFAST8 "d"
206 #define PRIdFAST16 "d"
207 #define PRIdFAST32 "d"
208 #define PRIdFAST64 "ld"
211 #define PRIi8 "i"
212 #define PRIi16 "i"
213 #define PRIi32 "i"
214 #define PRIi64 "li"
216 #define PRIiLEAST8 "i"
217 #define PRIiLEAST16 "i"
218 #define PRIiLEAST32 "i"
219 #define PRIiLEAST64 "li"
221 #define PRIiFAST8 "i"
222 #define PRIiFAST16 "i"
223 #define PRIiFAST32 "i"
224 #define PRIiFAST64 "li"
226 /* Octal notation. */
227 #define PRIo8 "o"
228 #define PRIo16 "o"
229 #define PRIo32 "o"
230 #define PRIo64 "lo"
232 #define PRIoLEAST8 "o"
233 #define PRIoLEAST16 "o"
234 #define PRIoLEAST32 "o"
235 #define PRIoLEAST64 "lo"
237 #define PRIoFAST8 "o"
238 #define PRIoFAST16 "o"
239 #define PRIoFAST32 "o"
240 #define PRIoFAST64 "lo"
242 /* lowercase hexadecimal notation. */
243 #define PRIx8 "x"
244 #define PRIx16 "x"
245 #define PRIx32 "x"
246 #define PRIx64 "lx"
248 #define PRIxLEAST8 "x"
249 #define PRIxLEAST16 "x"
250 #define PRIxLEAST32 "x"
251 #define PRIxLEAST64 "lx"
253 #define PRIxFAST8 "x"
254 #define PRIxFAST16 "x"
255 #define PRIxFAST32 "x"
256 #define PRIxFAST64 "lx"
258 /* UPPERCASE hexadecimal notation. */
259 #define PRIX8 "X"
260 #define PRIX16 "X"
261 #define PRIX32 "X"
262 #define PRIX64 "lX"
264 #define PRIXLEAST8 "X"
265 #define PRIXLEAST16 "X"
266 #define PRIXLEAST32 "X"
267 #define PRIXLEAST64 "lX"
269 #define PRIXFAST8 "X"
270 #define PRIXFAST16 "X"
271 #define PRIXFAST32 "X"
272 #define PRIXFAST64 "lX"
275 /* Unsigned integers. */
276 #define PRIu8 "u"
277 #define PRIu16 "u"
278 #define PRIu32 "u"
279 #define PRIu64 "lu"
281 #define PRIuLEAST8 "u"
282 #define PRIuLEAST16 "u"
283 #define PRIuLEAST32 "u"
284 #define PRIuLEAST64 "lu"
286 #define PRIuFAST8 "u"
287 #define PRIuFAST16 "u"
288 #define PRIuFAST32 "u"
289 #define PRIuFAST64 "lu"
292 /* Macros for printing `intmax_t' and `uintmax_t'. */
293 #define PRIdMAX "ld"
294 #define PRIoMAX "lo"
295 #define PRIxMAX "lx"
296 #define PRIuMAX "lu"
299 /* Macros for printing `intfast_t' and `uintfast_t'. */
300 #define PRIdFAST "ld"
301 #define PRIoFAST "lo"
302 #define PRIxFAST "lx"
303 #define PRIuFAST "lu"
306 /* Macros for printing `intptr_t' and `uintptr_t'. */
307 #define PRIdPTR "ld"
308 #define PRIoPTR "lo"
309 #define PRIxPTR "lx"
310 #define PRIuPTR "lu"
313 /* Macros for printing format specifiers. */
315 /* Decimal notation. */
316 #define SCNd8 "hhd"
317 #define SCNd16 "hd"
318 #define SCNd32 "d"
319 #define SCNd64 "ld"
321 #define SCNi8 "hhi"
322 #define SCNi16 "hi"
323 #define SCNi32 "i"
324 #define SCNi64 "li"
326 #define SCNu8 "hhu"
327 #define SCNu16 "hu"
328 #define SCNu32 "u"
329 #define SCNu64 "lu"
331 /* Octal notation. */
332 #define SCNo8 "hho"
333 #define SCNo16 "ho"
334 #define SCNo32 "o"
335 #define SCNo64 "lo"
337 /* Hexadecimal notation. */
338 #define SCNx8 "hhx"
339 #define SCNx16 "hx"
340 #define SCNx32 "x"
341 #define SCNx64 "lx"
344 /* Macros for scaning `intfast_t' and `uintfast_t'. */
345 #define SCNdFAST "ld"
346 #define SCNiFAST "li"
347 #define SCNoFAST "lo"
348 #define SCNxFAST "lx"
350 /* Macros for scaning `intptr_t' and `uintptr_t'. */
351 #define SCNdPTR "ld"
352 #define SCNiPTR "li"
353 #define SCNoPTR "lo"
354 #define SCNxPTR "lx"
357 /* Limits of other integer types. */
359 /* Limits of `ptrdiff_t' type. */
360 #define PTRDIFF_MIN (-9223372036854775807L-1)
361 #define PTRDIFF_MAX (9223372036854775807L)
363 /* Limits of `sig_atomic_t'. */
364 #define SIG_ATOMIC_MIN (-2147483647-1)
365 #define SIG_ATOMIC_MAX (2147483647)
367 /* Limit of `size_t' type. */
368 #define SIZE_MAX (18446744073709551615uL)
370 /* Limits of `wchar_t'. */
371 #ifndef WCHAR_MIN
372 /* These constants might also be defined in <wchar.h>. */
373 # define WCHAR_MIN (-2147483647-1)
374 # define WCHAR_MAX (2147483647)
375 #endif
377 /* Limits of `wint_t'. */
378 #define WINT_MIN (0)
379 #define WINT_MAX (4294967295U)
382 /* Macros for string conversion. */
384 /* Like `strtol' but convert to `intmax_t'. */
385 extern intmax_t strtoimax __P ((__const char *__restrict __nptr,
386 char **__restrict __endptr, int __base));
388 /* Like `strtoul' but convert to `uintmax_t'. */
389 extern uintmax_t strtoumax __P ((__const char * __restrict __nptr,
390 char ** __restrict __endptr, int __base));
392 /* Like `wcstol' but convert to `intmax_t'. */
393 extern intmax_t wcstoimax __P ((__const wchar_t * __restrict __nptr,
394 wchar_t **__restrict __endptr, int __base));
396 /* Like `wcstoul' but convert to `uintmax_t'. */
397 extern uintmax_t wcstoumax __P ((__const wchar_t * __restrict __nptr,
398 wchar_t ** __restrict __endptr, int __base));
400 #if defined __GNUC__ && __GNUC__ >= 2 && defined __OPTIMIZE__
402 /* Like `strtol' but convert to `intmax_t'. */
403 # ifndef __strtol_internal_defined
404 extern long int __strtol_internal __P ((__const char *__restrict __nptr,
405 char **__restrict __endptr,
406 int __base, int __group));
407 # define __strtol_internal_defined 1
408 # endif
409 extern __inline intmax_t
410 strtoimax (__const char *__restrict nptr, char **__restrict endptr, int base)
412 return __strtol_internal (nptr, endptr, base, 0);
415 /* Like `strtoul' but convert to `uintmax_t'. */
416 # ifndef __strtoul_internal_defined
417 extern unsigned long int __strtoul_internal __P ((__const char *
418 __restrict __nptr,
419 char ** __restrict __endptr,
420 int __base, int __group));
421 # define __strtoul_internal_defined 1
422 # endif
423 extern __inline uintmax_t
424 strtoumax (__const char *__restrict nptr, char **__restrict endptr, int base)
426 return __strtoul_internal (nptr, endptr, base, 0);
429 /* Like `wcstol' but convert to `intmax_t'. */
430 # ifndef __wcstol_internal_defined
431 extern long int __wcstol_internal __P ((__const wchar_t * __restrict __nptr,
432 wchar_t **__restrict __endptr,
433 int __base, int __group));
434 # define __wcstol_internal_defined 1
435 # endif
436 extern __inline intmax_t
437 wcstoimax (__const wchar_t *__restrict nptr, wchar_t **__restrict endptr,
438 int base)
440 return __wcstol_internal (nptr, endptr, base, 0);
444 /* Like `wcstoul' but convert to `uintmax_t'. */
445 # ifndef __wcstoul_internal_defined
446 extern unsigned long int __wcstoul_internal __P ((__const wchar_t *
447 __restrict __nptr,
448 wchar_t **
449 __restrict __endptr,
450 int __base, int __group));
451 # define __wcstoul_internal_defined 1
452 # endif
453 extern __inline uintmax_t
454 wcstoumax (__const wchar_t *__restrict nptr, wchar_t **__restrict endptr,
455 int base)
457 return __wcstoul_internal (nptr, endptr, base, 0);
459 #endif /* GCC and Optimization. */
461 #endif /* inttypes.h */