]>
Commit | Line | Data |
---|---|---|
e518937a | 1 | /* Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. |
f166d865 UD |
2 | This file is part of the GNU C Library. |
3 | ||
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. | |
8 | ||
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. | |
13 | ||
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. */ | |
18 | ||
19 | /* | |
14ea22e9 | 20 | * ISO C 9X: 7.5 Format conversion of integer types <inttypes.h> |
f166d865 UD |
21 | */ |
22 | ||
23 | #ifndef _INTTYPES_H | |
24 | #define _INTTYPES_H 1 | |
f166d865 | 25 | |
14ea22e9 UD |
26 | #include <features.h> |
27 | /* Get the type definitions. */ | |
28 | #include <stdint.h> | |
f166d865 UD |
29 | |
30 | ||
14ea22e9 UD |
31 | /* The ISO C 9X standard specifies that these macros must only be |
32 | defined if explicitly requested. */ | |
33 | #if !defined __cplusplus || defined __STDC_FORMAT_MACROS | |
f166d865 UD |
34 | |
35 | /* Macros for printing format specifiers. */ | |
36 | ||
37 | /* Decimal notation. */ | |
14ea22e9 UD |
38 | # define PRId8 "d" |
39 | # define PRId16 "d" | |
40 | # define PRId32 "d" | |
41 | # define PRId64 "lld" | |
f166d865 | 42 | |
14ea22e9 UD |
43 | # define PRIdLEAST8 "d" |
44 | # define PRIdLEAST16 "d" | |
45 | # define PRIdLEAST32 "d" | |
46 | # define PRIdLEAST64 "lld" | |
f166d865 | 47 | |
14ea22e9 UD |
48 | # define PRIdFAST8 "d" |
49 | # define PRIdFAST16 "d" | |
50 | # define PRIdFAST32 "d" | |
51 | # define PRIdFAST64 "lld" | |
f166d865 UD |
52 | |
53 | ||
14ea22e9 UD |
54 | # define PRIi8 "i" |
55 | # define PRIi16 "i" | |
56 | # define PRIi32 "i" | |
57 | # define PRIi64 "lli" | |
f166d865 | 58 | |
14ea22e9 UD |
59 | # define PRIiLEAST8 "i" |
60 | # define PRIiLEAST16 "i" | |
61 | # define PRIiLEAST32 "i" | |
62 | # define PRIiLEAST64 "lli" | |
f166d865 | 63 | |
14ea22e9 UD |
64 | # define PRIiFAST8 "i" |
65 | # define PRIiFAST16 "i" | |
66 | # define PRIiFAST32 "i" | |
67 | # define PRIiFAST64 "lli" | |
f166d865 UD |
68 | |
69 | /* Octal notation. */ | |
14ea22e9 UD |
70 | # define PRIo8 "o" |
71 | # define PRIo16 "o" | |
72 | # define PRIo32 "o" | |
73 | # define PRIo64 "llo" | |
f166d865 | 74 | |
14ea22e9 UD |
75 | # define PRIoLEAST8 "o" |
76 | # define PRIoLEAST16 "o" | |
77 | # define PRIoLEAST32 "o" | |
78 | # define PRIoLEAST64 "llo" | |
f166d865 | 79 | |
14ea22e9 UD |
80 | # define PRIoFAST8 "o" |
81 | # define PRIoFAST16 "o" | |
82 | # define PRIoFAST32 "o" | |
83 | # define PRIoFAST64 "llo" | |
f166d865 | 84 | |
bfce746a UD |
85 | /* Unsigned integers. */ |
86 | # define PRIu8 "u" | |
87 | # define PRIu16 "u" | |
88 | # define PRIu32 "u" | |
89 | # define PRIu64 "llu" | |
90 | ||
91 | # define PRIuLEAST8 "u" | |
92 | # define PRIuLEAST16 "u" | |
93 | # define PRIuLEAST32 "u" | |
94 | # define PRIuLEAST64 "llu" | |
95 | ||
96 | # define PRIuFAST8 "u" | |
97 | # define PRIuFAST16 "u" | |
98 | # define PRIuFAST32 "u" | |
99 | # define PRIuFAST64 "llu" | |
100 | ||
f166d865 | 101 | /* lowercase hexadecimal notation. */ |
14ea22e9 UD |
102 | # define PRIx8 "x" |
103 | # define PRIx16 "x" | |
104 | # define PRIx32 "x" | |
105 | # define PRIx64 "llx" | |
f166d865 | 106 | |
14ea22e9 UD |
107 | # define PRIxLEAST8 "x" |
108 | # define PRIxLEAST16 "x" | |
109 | # define PRIxLEAST32 "x" | |
110 | # define PRIxLEAST64 "llx" | |
f166d865 | 111 | |
14ea22e9 UD |
112 | # define PRIxFAST8 "x" |
113 | # define PRIxFAST16 "x" | |
114 | # define PRIxFAST32 "x" | |
115 | # define PRIxFAST64 "llx" | |
f166d865 UD |
116 | |
117 | /* UPPERCASE hexadecimal notation. */ | |
14ea22e9 UD |
118 | # define PRIX8 "X" |
119 | # define PRIX16 "X" | |
120 | # define PRIX32 "X" | |
121 | # define PRIX64 "llX" | |
f166d865 | 122 | |
14ea22e9 UD |
123 | # define PRIXLEAST8 "X" |
124 | # define PRIXLEAST16 "X" | |
125 | # define PRIXLEAST32 "X" | |
126 | # define PRIXLEAST64 "llX" | |
f166d865 | 127 | |
14ea22e9 UD |
128 | # define PRIXFAST8 "X" |
129 | # define PRIXFAST16 "X" | |
130 | # define PRIXFAST32 "X" | |
131 | # define PRIXFAST64 "llX" | |
f166d865 UD |
132 | |
133 | ||
f166d865 | 134 | /* Macros for printing `intmax_t' and `uintmax_t'. */ |
14ea22e9 | 135 | # define PRIdMAX "lld" |
bfce746a | 136 | # define PRIiMAX "lli" |
14ea22e9 | 137 | # define PRIoMAX "llo" |
14ea22e9 | 138 | # define PRIuMAX "llu" |
bfce746a UD |
139 | # define PRIxMAX "llx" |
140 | # define PRIXMAX "llX" | |
f166d865 UD |
141 | |
142 | ||
143 | /* Macros for printing `intptr_t' and `uintptr_t'. */ | |
14ea22e9 | 144 | # define PRIdPTR "d" |
bfce746a | 145 | # define PRIiPTR "i" |
14ea22e9 | 146 | # define PRIoPTR "o" |
14ea22e9 | 147 | # define PRIuPTR "u" |
bfce746a UD |
148 | # define PRIxPTR "x" |
149 | # define PRIXPTR "X" | |
f166d865 UD |
150 | |
151 | ||
14ea22e9 | 152 | /* Macros for scanning format specifiers. */ |
f166d865 | 153 | |
bfce746a | 154 | /* Signed decimal notation. */ |
14ea22e9 UD |
155 | # define SCNd8 "hhd" |
156 | # define SCNd16 "hd" | |
157 | # define SCNd32 "d" | |
158 | # define SCNd64 "lld" | |
f166d865 | 159 | |
bfce746a UD |
160 | # define SCNdLEAST8 "hhd" |
161 | # define SCNdLEAST16 "hd" | |
162 | # define SCNdLEAST32 "d" | |
163 | # define SCNdLEAST64 "lld" | |
164 | ||
165 | # define SCNdFAST8 "hhd" | |
166 | # define SCNdFAST16 "d" | |
167 | # define SCNdFAST32 "d" | |
168 | # define SCNdFAST64 "lld" | |
169 | ||
170 | /* Signed decimal notation. */ | |
14ea22e9 UD |
171 | # define SCNi8 "hhi" |
172 | # define SCNi16 "hi" | |
173 | # define SCNi32 "i" | |
174 | # define SCNi64 "lli" | |
f166d865 | 175 | |
bfce746a UD |
176 | # define SCNiLEAST8 "hhi" |
177 | # define SCNiLEAST16 "hi" | |
178 | # define SCNiLEAST32 "i" | |
179 | # define SCNiLEAST64 "lli" | |
180 | ||
181 | # define SCNiFAST8 "hhi" | |
182 | # define SCNiFAST16 "i" | |
183 | # define SCNiFAST32 "i" | |
184 | # define SCNiFAST64 "lli" | |
185 | ||
186 | /* Unsigned decimal notation. */ | |
14ea22e9 UD |
187 | # define SCNu8 "hhu" |
188 | # define SCNu16 "hu" | |
189 | # define SCNu32 "u" | |
190 | # define SCNu64 "llu" | |
9756dfe1 | 191 | |
bfce746a UD |
192 | # define SCNuLEAST8 "hhu" |
193 | # define SCNuLEAST16 "hu" | |
194 | # define SCNuLEAST32 "u" | |
195 | # define SCNuLEAST64 "llu" | |
196 | ||
197 | # define SCNuFAST8 "hhu" | |
198 | # define SCNuFAST16 "u" | |
199 | # define SCNuFAST32 "u" | |
200 | # define SCNuFAST64 "llu" | |
201 | ||
f166d865 | 202 | /* Octal notation. */ |
14ea22e9 UD |
203 | # define SCNo8 "hho" |
204 | # define SCNo16 "ho" | |
205 | # define SCNo32 "o" | |
206 | # define SCNo64 "llo" | |
f166d865 | 207 | |
bfce746a UD |
208 | # define SCNoLEAST8 "hho" |
209 | # define SCNoLEAST16 "ho" | |
210 | # define SCNoLEAST32 "o" | |
211 | # define SCNoLEAST64 "llo" | |
212 | ||
213 | # define SCNoFAST8 "hho" | |
214 | # define SCNoFAST16 "o" | |
215 | # define SCNoFAST32 "o" | |
216 | # define SCNoFAST64 "llo" | |
217 | ||
f166d865 | 218 | /* Hexadecimal notation. */ |
14ea22e9 UD |
219 | # define SCNx8 "hhx" |
220 | # define SCNx16 "hx" | |
221 | # define SCNx32 "x" | |
222 | # define SCNx64 "llx" | |
f166d865 | 223 | |
bfce746a UD |
224 | # define SCNxLEAST8 "hhx" |
225 | # define SCNxLEAST16 "hx" | |
226 | # define SCNxLEAST32 "x" | |
227 | # define SCNxLEAST64 "llx" | |
228 | ||
229 | # define SCNxFAST8 "hhx" | |
230 | # define SCNxFAST16 "x" | |
231 | # define SCNxFAST32 "x" | |
232 | # define SCNxFAST64 "llx" | |
233 | ||
234 | ||
235 | /* Macros for scanning `intmax_t' and `uintmax_t'. */ | |
236 | # define SCNdMAX "lld" | |
237 | # define SCNiMAX "lli" | |
238 | # define SCNoMAX "llo" | |
239 | # define SCNuMAX "llu" | |
240 | # define SCNxMAX "llx" | |
f166d865 UD |
241 | |
242 | /* Macros for scaning `intptr_t' and `uintptr_t'. */ | |
14ea22e9 UD |
243 | # define SCNdPTR "d" |
244 | # define SCNiPTR "i" | |
245 | # define SCNoPTR "o" | |
bfce746a | 246 | # define SCNuPTR "u" |
14ea22e9 | 247 | # define SCNxPTR "x" |
cc3fa755 | 248 | |
14ea22e9 | 249 | #endif /* C++ && format macros */ |
cc3fa755 | 250 | |
cc3fa755 | 251 | |
14ea22e9 | 252 | __BEGIN_DECLS |
dfd2257a | 253 | |
e518937a UD |
254 | /* We have to define the `uintmax_t' type using `lldiv_t'. */ |
255 | #ifndef _STDLIB_H | |
256 | /* Returned by `lldiv'. */ | |
257 | __extension__ typedef struct | |
258 | { | |
259 | long long int quot; /* Quotient. */ | |
260 | long long int rem; /* Remainder. */ | |
261 | } lldiv_t; | |
262 | # define __lldiv_t_defined 1 | |
263 | #endif | |
264 | ||
265 | /* Returned by `imaxdiv'. */ | |
266 | typedef lldiv_t imaxdiv_t; | |
267 | ||
268 | ||
269 | /* Compute absolute value of N. */ | |
270 | extern intmax_t imaxabs __P ((intmax_t __n)) __attribute__ ((__const__)); | |
271 | ||
272 | /* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */ | |
273 | extern imaxdiv_t imaxdiv __P ((intmax_t __numer, intmax_t __denom)) | |
274 | __attribute__ ((__const__)); | |
275 | ||
dfd2257a | 276 | /* Like `strtol' but convert to `intmax_t'. */ |
d71b808a UD |
277 | extern intmax_t strtoimax __P ((__const char *__restrict __nptr, |
278 | char **__restrict __endptr, int __base)); | |
dfd2257a | 279 | |
d71b808a UD |
280 | /* Like `strtoul' but convert to `uintmax_t'. */ |
281 | extern uintmax_t strtoumax __P ((__const char * __restrict __nptr, | |
282 | char ** __restrict __endptr, int __base)); | |
283 | ||
284 | /* Like `wcstol' but convert to `intmax_t'. */ | |
285 | extern intmax_t wcstoimax __P ((__const wchar_t * __restrict __nptr, | |
286 | wchar_t **__restrict __endptr, int __base)); | |
287 | ||
288 | /* Like `wcstoul' but convert to `uintmax_t'. */ | |
289 | extern uintmax_t wcstoumax __P ((__const wchar_t * __restrict __nptr, | |
290 | wchar_t ** __restrict __endptr, int __base)); | |
291 | ||
0c6cee5d | 292 | #ifdef __USE_EXTERN_INLINES |
d71b808a | 293 | |
e518937a UD |
294 | /* We ant to use the appropriate functions from <stdlib.h> but cannot |
295 | assume the header is read already. */ | |
296 | __extension__ extern long long int llabs __P ((long long int __x)) | |
297 | __attribute__ ((__const__)); | |
298 | __extension__ extern lldiv_t lldiv __P ((long long int __numer, | |
299 | long long int __denom)) | |
300 | __attribute__ ((__const__)); | |
301 | ||
302 | ||
303 | /* Compute absolute value of N. */ | |
304 | extern __inline intmax_t | |
305 | imaxabs (intmax_t __n) __THROW | |
306 | { | |
307 | return llabs (__n); | |
308 | } | |
309 | ||
310 | /* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */ | |
311 | extern __inline imaxdiv_t | |
312 | imaxdiv (intmax_t __numer, intmax_t __denom) __THROW | |
313 | { | |
314 | return lldiv (__numer, __denom); | |
315 | } | |
316 | ||
d71b808a UD |
317 | /* Like `strtol' but convert to `intmax_t'. */ |
318 | # ifndef __strtoll_internal_defined | |
7782d0bf | 319 | __extension__ |
dfd2257a UD |
320 | extern long long int __strtoll_internal __P ((__const char *__restrict __nptr, |
321 | char **__restrict __endptr, | |
322 | int __base, int __group)); | |
d71b808a UD |
323 | # define __strtoll_internal_defined 1 |
324 | # endif | |
325 | extern __inline intmax_t | |
99e46354 UD |
326 | strtoimax (__const char *__restrict nptr, char **__restrict endptr, |
327 | int base) __THROW | |
d71b808a UD |
328 | { |
329 | return __strtoll_internal (nptr, endptr, base, 0); | |
330 | } | |
dfd2257a UD |
331 | |
332 | /* Like `strtoul' but convert to `uintmax_t'. */ | |
d71b808a | 333 | # ifndef __strtoull_internal_defined |
7782d0bf | 334 | __extension__ |
dfd2257a UD |
335 | extern unsigned long long int __strtoull_internal __P ((__const char * |
336 | __restrict __nptr, | |
337 | char ** | |
338 | __restrict __endptr, | |
339 | int __base, | |
340 | int __group)); | |
d71b808a UD |
341 | # define __strtoull_internal_defined 1 |
342 | # endif | |
343 | extern __inline uintmax_t | |
99e46354 UD |
344 | strtoumax (__const char *__restrict nptr, char **__restrict endptr, |
345 | int base) __THROW | |
d71b808a UD |
346 | { |
347 | return __strtoull_internal (nptr, endptr, base, 0); | |
348 | } | |
cc3fa755 UD |
349 | |
350 | /* Like `wcstol' but convert to `intmax_t'. */ | |
d71b808a | 351 | # ifndef __wcstoll_internal_defined |
7782d0bf | 352 | __extension__ |
cc3fa755 UD |
353 | extern long long int __wcstoll_internal __P ((__const wchar_t * |
354 | __restrict __nptr, | |
355 | wchar_t **__restrict __endptr, | |
356 | int __base, int __group)); | |
d71b808a UD |
357 | # define __wcstoll_internal_defined 1 |
358 | # endif | |
359 | extern __inline intmax_t | |
99e46354 UD |
360 | wcstoimax (__const wchar_t *__restrict nptr, wchar_t **__restrict endptr, |
361 | int base) __THROW | |
d71b808a UD |
362 | { |
363 | return __wcstoll_internal (nptr, endptr, base, 0); | |
364 | } | |
cc3fa755 UD |
365 | |
366 | ||
367 | /* Like `wcstoul' but convert to `uintmax_t'. */ | |
d71b808a | 368 | # ifndef __wcstoull_internal_defined |
7782d0bf | 369 | __extension__ |
cc3fa755 UD |
370 | extern unsigned long long int __wcstoull_internal __P ((__const wchar_t * |
371 | __restrict __nptr, | |
372 | wchar_t ** | |
373 | __restrict __endptr, | |
374 | int __base, | |
375 | int __group)); | |
d71b808a UD |
376 | # define __wcstoull_internal_defined 1 |
377 | # endif | |
378 | extern __inline uintmax_t | |
99e46354 UD |
379 | wcstoumax (__const wchar_t *__restrict nptr, wchar_t **__restrict endptr, |
380 | int base) __THROW | |
d71b808a UD |
381 | { |
382 | return __wcstoull_internal (nptr, endptr, base, 0); | |
383 | } | |
0c6cee5d | 384 | #endif /* Use extern inlines. */ |
cc3fa755 | 385 | |
14ea22e9 UD |
386 | __END_DECLS |
387 | ||
f166d865 | 388 | #endif /* inttypes.h */ |