Update.
[glibc.git] / sysdeps / wordsize-32 / inttypes.h
blobc0582c18766137209286e4e5db937a46e841e4cb
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 /* Exact integral types. */
30 /* Signed. */
32 /* There is some amount of overlap with <sys/types.h> as known by inet code */
33 #ifndef __int8_t_defined
34 # define __int8_t_defined
35 typedef signed char int8_t;
36 typedef short int int16_t;
37 typedef int int32_t;
38 typedef long long int int64_t;
39 #endif
41 /* Unsigned. */
42 typedef unsigned char uint8_t;
43 typedef unsigned short int uint16_t;
44 typedef unsigned int uint32_t;
45 typedef unsigned long long int uint64_t;
48 /* Largest integral types. */
49 typedef long long int intmax_t;
50 typedef unsigned long long int uintmax_t;
53 /* Types for `void *' pointers. */
54 typedef int intptr_t;
55 typedef unsigned int uintptr_t;
58 /* Efficient types. */
59 typedef int intfast_t;
60 typedef unsigned int uintfast_t;
63 /* Small types. */
65 /* Signed. */
66 typedef signed char int_least8_t;
67 typedef short int int_least16_t;
68 typedef int int_least32_t;
69 typedef long long int int_least64_t;
71 /* Unsigned. */
72 typedef unsigned char uint_least8_t;
73 typedef unsigned short int uint_least16_t;
74 typedef unsigned int uint_least32_t;
75 typedef unsigned long long int uint_least64_t;
78 /* Fast types. */
80 /* Signed. */
81 typedef signed char int_fast8_t;
82 typedef int int_fast16_t;
83 typedef int int_fast32_t;
84 typedef long long int int_fast64_t;
86 /* Unsigned. */
87 typedef unsigned char uint_fast8_t;
88 typedef unsigned int uint_fast16_t;
89 typedef unsigned int uint_fast32_t;
90 typedef unsigned long long int uint_fast64_t;
93 /* Limits of integral types. */
95 /* Minimum of signed integral types. */
96 #define INT8_MIN (-128)
97 #define INT16_MIN (-32767-1)
98 #define INT32_MIN (-2147483647-1)
99 #define INT64_MIN (-9223372036854775807LL-1)
100 /* Maximum of signed integral types. */
101 #define INT8_MAX (127)
102 #define INT16_MAX (32767)
103 #define INT32_MAX (2147483647)
104 #define INT64_MAX (9223372036854775807LL)
106 /* Maximum of unsigned integral types. */
107 #define UINT8_MAX (255U)
108 #define UINT16_MAX (65535U)
109 #define UINT32_MAX (4294967295U)
110 #define UINT64_MAX (18446744073709551615uLL)
113 /* Minimum of signed integral types having a minimum size. */
114 #define INT_LEAST8_MIN (-128)
115 #define INT_LEAST16_MIN (-32767-1)
116 #define INT_LEAST32_MIN (-2147483647-1)
117 #define INT_LEAST64_MIN (-9223372036854775807LL-1)
118 /* Maximum of signed integral types having a minimum size. */
119 #define INT_LEAST8_MAX (127)
120 #define INT_LEAST16_MAX (32767)
121 #define INT_LEAST32_MAX (2147483647)
122 #define INT_LEAST64_MAX (9223372036854775807LL)
124 /* Maximum of unsigned integral types having a minimum size. */
125 #define UINT_LEAST8_MAX (255U)
126 #define UINT_LEAST16_MAX (65535U)
127 #define UINT_LEAST32_MAX (4294967295U)
128 #define UINT_LEAST64_MAX (18446744073709551615uLL)
131 /* Minimum of fast signed integral types having a minimum size. */
132 #define INT_FAST8_MIN (-128)
133 #define INT_FAST16_MIN (-2147483647-1)
134 #define INT_FAST32_MIN (-2147483647-1)
135 #define INT_FAST64_MIN (-9223372036854775807LL-1)
136 /* Maximum of fast signed integral types having a minimum size. */
137 #define INT_FAST8_MAX (127)
138 #define INT_FAST16_MAX (2147483647)
139 #define INT_FAST32_MAX (2147483647)
140 #define INT_FAST64_MAX (9223372036854775807LL)
142 /* Maximum of fast unsigned integral types having a minimum size. */
143 #define UINT_FAST8_MAX (255U)
144 #define UINT_FAST16_MAX (4294967295U)
145 #define UINT_FAST32_MAX (4294967295U)
146 #define UINT_FAST64_MAX (18446744073709551615uLL)
149 /* Minimum for most efficient signed integral types. */
150 #define INTFAST_MIN (-2147483647-1)
151 /* Maximum for most efficient signed integral types. */
152 #define INTFAST_MAX (2147483647)
154 /* Maximum for most efficient unsigned integral types. */
155 #define UINTFAST_MAX (4294967295U)
158 /* Minimum for largest signed integral type. */
159 #define INTMAX_MIN (-9223372036854775807LL-1)
160 /* Maximum for largest signed integral type. */
161 #define INTMAX_MAX (9223372036854775807LL)
163 /* Maximum for largest unsigned integral type. */
164 #define UINTMAX_MAX (18446744073709551615uLL)
167 /* Values to test for integral types holding `void *' pointer. */
168 #define INTPTR_MAX (2147483647)
169 #define UINTPTR_MAX (4294967295U)
172 /* Signed. */
173 #define INT8_C(c) ((int8_t) c)
174 #define INT16_C(c) ((int16_t) c)
175 #define INT32_C(c) ((int32_t) c)
176 #define INT64_C(c) ((int64_t) __CONCAT (c,ll))
178 /* Unsigned. */
179 #define UINT8_C(c) ((uint8_t) __CONCAT (c,u))
180 #define UINT16_C(c) ((uint16_t) __CONCAT (c,u))
181 #define UINT32_C(c) ((uint32_t) __CONCAT (c,u))
182 #define UINT64_C(c) ((uint64_t) __CONCAT (c,ull))
184 /* Maximal type. */
185 #define INTMAX_C(c) ((intmax_t) __CONCAT (c,ll))
186 #define UINTMAX_C(c) ((uintmax_t) __CONCAT (c,ull))
189 /* Macros for printing format specifiers. */
191 /* Decimal notation. */
192 #define PRId8 "d"
193 #define PRId16 "d"
194 #define PRId32 "d"
195 #define PRId64 "lld"
197 #define PRIdLEAST8 "d"
198 #define PRIdLEAST16 "d"
199 #define PRIdLEAST32 "d"
200 #define PRIdLEAST64 "lld"
202 #define PRIdFAST8 "d"
203 #define PRIdFAST16 "d"
204 #define PRIdFAST32 "d"
205 #define PRIdFAST64 "lld"
208 #define PRIi8 "i"
209 #define PRIi16 "i"
210 #define PRIi32 "i"
211 #define PRIi64 "lli"
213 #define PRIiLEAST8 "i"
214 #define PRIiLEAST16 "i"
215 #define PRIiLEAST32 "i"
216 #define PRIiLEAST64 "lli"
218 #define PRIiFAST8 "i"
219 #define PRIiFAST16 "i"
220 #define PRIiFAST32 "i"
221 #define PRIiFAST64 "lli"
223 /* Octal notation. */
224 #define PRIo8 "o"
225 #define PRIo16 "o"
226 #define PRIo32 "o"
227 #define PRIo64 "llo"
229 #define PRIoLEAST8 "o"
230 #define PRIoLEAST16 "o"
231 #define PRIoLEAST32 "o"
232 #define PRIoLEAST64 "llo"
234 #define PRIoFAST8 "o"
235 #define PRIoFAST16 "o"
236 #define PRIoFAST32 "o"
237 #define PRIoFAST64 "llo"
239 /* lowercase hexadecimal notation. */
240 #define PRIx8 "x"
241 #define PRIx16 "x"
242 #define PRIx32 "x"
243 #define PRIx64 "llx"
245 #define PRIxLEAST8 "x"
246 #define PRIxLEAST16 "x"
247 #define PRIxLEAST32 "x"
248 #define PRIxLEAST64 "llx"
250 #define PRIxFAST8 "x"
251 #define PRIxFAST16 "x"
252 #define PRIxFAST32 "x"
253 #define PRIxFAST64 "llx"
255 /* UPPERCASE hexadecimal notation. */
256 #define PRIX8 "X"
257 #define PRIX16 "X"
258 #define PRIX32 "X"
259 #define PRIX64 "llX"
261 #define PRIXLEAST8 "X"
262 #define PRIXLEAST16 "X"
263 #define PRIXLEAST32 "X"
264 #define PRIXLEAST64 "llX"
266 #define PRIXFAST8 "X"
267 #define PRIXFAST16 "X"
268 #define PRIXFAST32 "X"
269 #define PRIXFAST64 "llX"
272 /* Unsigned integers. */
273 #define PRIu8 "u"
274 #define PRIu16 "u"
275 #define PRIu32 "u"
276 #define PRIu64 "llu"
278 #define PRIuLEAST8 "u"
279 #define PRIuLEAST16 "u"
280 #define PRIuLEAST32 "u"
281 #define PRIuLEAST64 "llu"
283 #define PRIuFAST8 "u"
284 #define PRIuFAST16 "u"
285 #define PRIuFAST32 "u"
286 #define PRIuFAST64 "llu"
289 /* Macros for printing `intmax_t' and `uintmax_t'. */
290 #define PRIdMAX "lld"
291 #define PRIoMAX "llo"
292 #define PRIxMAX "llx"
293 #define PRIuMAX "llu"
296 /* Macros for printing `intfast_t' and `uintfast_t'. */
297 #define PRIdFAST "d"
298 #define PRIoFAST "o"
299 #define PRIxFAST "x"
300 #define PRIuFAST "u"
303 /* Macros for printing `intptr_t' and `uintptr_t'. */
304 #define PRIdPTR "d"
305 #define PRIoPTR "o"
306 #define PRIxPTR "x"
307 #define PRIuPTR "u"
310 /* Macros for printing format specifiers. */
312 /* Decimal notation. */
313 #define SCNd16 "hd"
314 #define SCNd32 "d"
315 #define SCNd64 "lld"
317 #define SCNi16 "hi"
318 #define SCNi32 "i"
319 #define SCNi64 "lli"
321 /* Octal notation. */
322 #define SCNo16 "ho"
323 #define SCNo32 "o"
324 #define SCNo64 "llo"
326 /* Hexadecimal notation. */
327 #define SCNx16 "hx"
328 #define SCNx32 "x"
329 #define SCNx64 "llx"
332 /* Macros for scaning `intfast_t' and `uintfast_t'. */
333 #define SCNdFAST "d"
334 #define SCNiFAST "i"
335 #define SCNoFAST "o"
336 #define SCNxFAST "x"
338 /* Macros for scaning `intptr_t' and `uintptr_t'. */
339 #define SCNdPTR "d"
340 #define SCNiPTR "i"
341 #define SCNoPTR "o"
342 #define SCNxPTR "x"
345 /* Macros for string conversion. */
347 /* Like `strtol' but convert to `intmax_t'. */
348 #define strtoimax(nptr, endptr, base) \
349 __strtoll_internal (nptr, endptr, base, 0)
351 #ifndef __strtoll_internal_defined
352 extern long long int __strtoll_internal __P ((__const char *__restrict __nptr,
353 char **__restrict __endptr,
354 int __base, int __group));
355 # define __strtoll_internal_defined 1
356 #endif
359 /* Like `strtoul' but convert to `uintmax_t'. */
360 #define strtoumax(nptr, endptr, base) \
361 __strtoull_internal (nptr, endptr, base, 0)
363 #ifndef __strtoull_internal_defined
364 extern unsigned long long int __strtoull_internal __P ((__const char *
365 __restrict __nptr,
366 char **
367 __restrict __endptr,
368 int __base,
369 int __group));
370 # define __strtoull_internal_defined 1
371 #endif
373 #endif /* inttypes.h */