]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/generic/inttypes.h
typo fix
[thirdparty/glibc.git] / sysdeps / generic / inttypes.h
CommitLineData
568035b7 1/* Copyright (C) 1997-2013 Free Software Foundation, Inc.
1c25bcac
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
41bdb6e2
AJ
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.
1c25bcac
UD
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
41bdb6e2 12 Lesser General Public License for more details.
1c25bcac 13
41bdb6e2 14 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
1c25bcac
UD
17
18/*
63ae7b63 19 * ISO C99: 7.8 Format conversion of integer types <inttypes.h>
1c25bcac
UD
20 */
21
22#ifndef _INTTYPES_H
23#define _INTTYPES_H 1
24
25#include <features.h>
26/* Get the type definitions. */
27#include <stdint.h>
28
68984987 29/* Get a definition for wchar_t. But we must not define wchar_t itself. */
647eb037 30#ifndef ____gwchar_t_defined
1bc83d2b
UD
31# ifdef __cplusplus
32# define __gwchar_t wchar_t
33# elif defined __WCHAR_TYPE__
647eb037 34typedef __WCHAR_TYPE__ __gwchar_t;
68984987 35# else
b61345a1 36# define __need_wchar_t
68984987 37# include <stddef.h>
647eb037 38typedef wchar_t __gwchar_t;
68984987 39# endif
647eb037 40# define ____gwchar_t_defined 1
68984987
UD
41#endif
42
1c25bcac 43
63ae7b63 44/* The ISO C99 standard specifies that these macros must only be
1c25bcac
UD
45 defined if explicitly requested. */
46#if !defined __cplusplus || defined __STDC_FORMAT_MACROS
47
48# if __WORDSIZE == 64
49# define __PRI64_PREFIX "l"
50# define __PRIPTR_PREFIX "l"
51# else
52# define __PRI64_PREFIX "ll"
53# define __PRIPTR_PREFIX
54# endif
55
56/* Macros for printing format specifiers. */
57
58/* Decimal notation. */
59# define PRId8 "d"
60# define PRId16 "d"
61# define PRId32 "d"
62# define PRId64 __PRI64_PREFIX "d"
63
64# define PRIdLEAST8 "d"
65# define PRIdLEAST16 "d"
66# define PRIdLEAST32 "d"
67# define PRIdLEAST64 __PRI64_PREFIX "d"
68
69# define PRIdFAST8 "d"
a658675d
UD
70# define PRIdFAST16 __PRIPTR_PREFIX "d"
71# define PRIdFAST32 __PRIPTR_PREFIX "d"
1c25bcac
UD
72# define PRIdFAST64 __PRI64_PREFIX "d"
73
74
75# define PRIi8 "i"
76# define PRIi16 "i"
77# define PRIi32 "i"
78# define PRIi64 __PRI64_PREFIX "i"
79
80# define PRIiLEAST8 "i"
81# define PRIiLEAST16 "i"
82# define PRIiLEAST32 "i"
83# define PRIiLEAST64 __PRI64_PREFIX "i"
84
85# define PRIiFAST8 "i"
a658675d
UD
86# define PRIiFAST16 __PRIPTR_PREFIX "i"
87# define PRIiFAST32 __PRIPTR_PREFIX "i"
1c25bcac
UD
88# define PRIiFAST64 __PRI64_PREFIX "i"
89
90/* Octal notation. */
91# define PRIo8 "o"
92# define PRIo16 "o"
93# define PRIo32 "o"
94# define PRIo64 __PRI64_PREFIX "o"
95
96# define PRIoLEAST8 "o"
97# define PRIoLEAST16 "o"
98# define PRIoLEAST32 "o"
99# define PRIoLEAST64 __PRI64_PREFIX "o"
100
101# define PRIoFAST8 "o"
a658675d
UD
102# define PRIoFAST16 __PRIPTR_PREFIX "o"
103# define PRIoFAST32 __PRIPTR_PREFIX "o"
1c25bcac
UD
104# define PRIoFAST64 __PRI64_PREFIX "o"
105
106/* Unsigned integers. */
107# define PRIu8 "u"
108# define PRIu16 "u"
109# define PRIu32 "u"
110# define PRIu64 __PRI64_PREFIX "u"
111
112# define PRIuLEAST8 "u"
113# define PRIuLEAST16 "u"
114# define PRIuLEAST32 "u"
115# define PRIuLEAST64 __PRI64_PREFIX "u"
116
117# define PRIuFAST8 "u"
a658675d
UD
118# define PRIuFAST16 __PRIPTR_PREFIX "u"
119# define PRIuFAST32 __PRIPTR_PREFIX "u"
1c25bcac
UD
120# define PRIuFAST64 __PRI64_PREFIX "u"
121
122/* lowercase hexadecimal notation. */
123# define PRIx8 "x"
124# define PRIx16 "x"
125# define PRIx32 "x"
126# define PRIx64 __PRI64_PREFIX "x"
127
128# define PRIxLEAST8 "x"
129# define PRIxLEAST16 "x"
130# define PRIxLEAST32 "x"
131# define PRIxLEAST64 __PRI64_PREFIX "x"
132
133# define PRIxFAST8 "x"
a658675d
UD
134# define PRIxFAST16 __PRIPTR_PREFIX "x"
135# define PRIxFAST32 __PRIPTR_PREFIX "x"
1c25bcac
UD
136# define PRIxFAST64 __PRI64_PREFIX "x"
137
138/* UPPERCASE hexadecimal notation. */
139# define PRIX8 "X"
140# define PRIX16 "X"
141# define PRIX32 "X"
142# define PRIX64 __PRI64_PREFIX "X"
143
144# define PRIXLEAST8 "X"
145# define PRIXLEAST16 "X"
146# define PRIXLEAST32 "X"
147# define PRIXLEAST64 __PRI64_PREFIX "X"
148
149# define PRIXFAST8 "X"
a658675d
UD
150# define PRIXFAST16 __PRIPTR_PREFIX "X"
151# define PRIXFAST32 __PRIPTR_PREFIX "X"
1c25bcac
UD
152# define PRIXFAST64 __PRI64_PREFIX "X"
153
154
155/* Macros for printing `intmax_t' and `uintmax_t'. */
156# define PRIdMAX __PRI64_PREFIX "d"
157# define PRIiMAX __PRI64_PREFIX "i"
158# define PRIoMAX __PRI64_PREFIX "o"
159# define PRIuMAX __PRI64_PREFIX "u"
160# define PRIxMAX __PRI64_PREFIX "x"
161# define PRIXMAX __PRI64_PREFIX "X"
162
163
164/* Macros for printing `intptr_t' and `uintptr_t'. */
165# define PRIdPTR __PRIPTR_PREFIX "d"
166# define PRIiPTR __PRIPTR_PREFIX "i"
167# define PRIoPTR __PRIPTR_PREFIX "o"
168# define PRIuPTR __PRIPTR_PREFIX "u"
169# define PRIxPTR __PRIPTR_PREFIX "x"
170# define PRIXPTR __PRIPTR_PREFIX "X"
171
172
173/* Macros for scanning format specifiers. */
174
175/* Signed decimal notation. */
176# define SCNd8 "hhd"
177# define SCNd16 "hd"
178# define SCNd32 "d"
179# define SCNd64 __PRI64_PREFIX "d"
180
181# define SCNdLEAST8 "hhd"
182# define SCNdLEAST16 "hd"
183# define SCNdLEAST32 "d"
184# define SCNdLEAST64 __PRI64_PREFIX "d"
185
186# define SCNdFAST8 "hhd"
187# define SCNdFAST16 __PRIPTR_PREFIX "d"
188# define SCNdFAST32 __PRIPTR_PREFIX "d"
189# define SCNdFAST64 __PRI64_PREFIX "d"
190
191/* Signed decimal notation. */
192# define SCNi8 "hhi"
193# define SCNi16 "hi"
194# define SCNi32 "i"
195# define SCNi64 __PRI64_PREFIX "i"
196
197# define SCNiLEAST8 "hhi"
198# define SCNiLEAST16 "hi"
199# define SCNiLEAST32 "i"
200# define SCNiLEAST64 __PRI64_PREFIX "i"
201
202# define SCNiFAST8 "hhi"
203# define SCNiFAST16 __PRIPTR_PREFIX "i"
204# define SCNiFAST32 __PRIPTR_PREFIX "i"
205# define SCNiFAST64 __PRI64_PREFIX "i"
206
207/* Unsigned decimal notation. */
208# define SCNu8 "hhu"
209# define SCNu16 "hu"
210# define SCNu32 "u"
211# define SCNu64 __PRI64_PREFIX "u"
212
213# define SCNuLEAST8 "hhu"
214# define SCNuLEAST16 "hu"
215# define SCNuLEAST32 "u"
216# define SCNuLEAST64 __PRI64_PREFIX "u"
217
218# define SCNuFAST8 "hhu"
219# define SCNuFAST16 __PRIPTR_PREFIX "u"
220# define SCNuFAST32 __PRIPTR_PREFIX "u"
221# define SCNuFAST64 __PRI64_PREFIX "u"
222
223/* Octal notation. */
224# define SCNo8 "hho"
225# define SCNo16 "ho"
226# define SCNo32 "o"
227# define SCNo64 __PRI64_PREFIX "o"
228
229# define SCNoLEAST8 "hho"
230# define SCNoLEAST16 "ho"
231# define SCNoLEAST32 "o"
232# define SCNoLEAST64 __PRI64_PREFIX "o"
233
234# define SCNoFAST8 "hho"
235# define SCNoFAST16 __PRIPTR_PREFIX "o"
236# define SCNoFAST32 __PRIPTR_PREFIX "o"
237# define SCNoFAST64 __PRI64_PREFIX "o"
238
239/* Hexadecimal notation. */
240# define SCNx8 "hhx"
241# define SCNx16 "hx"
242# define SCNx32 "x"
243# define SCNx64 __PRI64_PREFIX "x"
244
245# define SCNxLEAST8 "hhx"
246# define SCNxLEAST16 "hx"
247# define SCNxLEAST32 "x"
248# define SCNxLEAST64 __PRI64_PREFIX "x"
249
250# define SCNxFAST8 "hhx"
251# define SCNxFAST16 __PRIPTR_PREFIX "x"
252# define SCNxFAST32 __PRIPTR_PREFIX "x"
253# define SCNxFAST64 __PRI64_PREFIX "x"
254
255
256/* Macros for scanning `intmax_t' and `uintmax_t'. */
257# define SCNdMAX __PRI64_PREFIX "d"
258# define SCNiMAX __PRI64_PREFIX "i"
259# define SCNoMAX __PRI64_PREFIX "o"
260# define SCNuMAX __PRI64_PREFIX "u"
261# define SCNxMAX __PRI64_PREFIX "x"
262
263/* Macros for scaning `intptr_t' and `uintptr_t'. */
264# define SCNdPTR __PRIPTR_PREFIX "d"
265# define SCNiPTR __PRIPTR_PREFIX "i"
266# define SCNoPTR __PRIPTR_PREFIX "o"
267# define SCNuPTR __PRIPTR_PREFIX "u"
268# define SCNxPTR __PRIPTR_PREFIX "x"
269
270#endif /* C++ && format macros */
271
272
273__BEGIN_DECLS
274
275#if __WORDSIZE == 64
276
277/* We have to define the `uintmax_t' type using `ldiv_t'. */
1c25bcac
UD
278typedef struct
279 {
280 long int quot; /* Quotient. */
281 long int rem; /* Remainder. */
417bafec 282 } imaxdiv_t;
1c25bcac
UD
283
284#else
285
286/* We have to define the `uintmax_t' type using `lldiv_t'. */
417bafec 287typedef struct
1c25bcac
UD
288 {
289 long long int quot; /* Quotient. */
290 long long int rem; /* Remainder. */
417bafec 291 } imaxdiv_t;
1c25bcac
UD
292
293#endif
294
295
296/* Compute absolute value of N. */
d8cf93f4 297extern intmax_t imaxabs (intmax_t __n) __THROW __attribute__ ((__const__));
1c25bcac
UD
298
299/* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */
d8cf93f4
UD
300extern imaxdiv_t imaxdiv (intmax_t __numer, intmax_t __denom)
301 __THROW __attribute__ ((__const__));
1c25bcac
UD
302
303/* Like `strtol' but convert to `intmax_t'. */
a784e502 304extern intmax_t strtoimax (const char *__restrict __nptr,
d8cf93f4 305 char **__restrict __endptr, int __base) __THROW;
1c25bcac
UD
306
307/* Like `strtoul' but convert to `uintmax_t'. */
a784e502 308extern uintmax_t strtoumax (const char *__restrict __nptr,
d8cf93f4 309 char ** __restrict __endptr, int __base) __THROW;
1c25bcac
UD
310
311/* Like `wcstol' but convert to `intmax_t'. */
a784e502 312extern intmax_t wcstoimax (const __gwchar_t *__restrict __nptr,
647eb037 313 __gwchar_t **__restrict __endptr, int __base)
68984987 314 __THROW;
1c25bcac
UD
315
316/* Like `wcstoul' but convert to `uintmax_t'. */
a784e502 317extern uintmax_t wcstoumax (const __gwchar_t *__restrict __nptr,
647eb037 318 __gwchar_t ** __restrict __endptr, int __base)
68984987 319 __THROW;
1c25bcac
UD
320
321#ifdef __USE_EXTERN_INLINES
322
323# if __WORDSIZE == 64
324
a784e502 325extern long int __strtol_internal (const char *__restrict __nptr,
d8cf93f4 326 char **__restrict __endptr,
9b2e9577
UD
327 int __base, int __group)
328 __THROW __nonnull ((1)) __wur;
329/* Like `strtol' but convert to `intmax_t'. */
b037a293 330__extern_inline intmax_t
a784e502 331__NTH (strtoimax (const char *__restrict nptr, char **__restrict endptr,
f377d022 332 int base))
1c25bcac
UD
333{
334 return __strtol_internal (nptr, endptr, base, 0);
335}
336
a784e502 337extern unsigned long int __strtoul_internal (const char *__restrict __nptr,
d8cf93f4 338 char ** __restrict __endptr,
9b2e9577
UD
339 int __base, int __group)
340 __THROW __nonnull ((1)) __wur;
341/* Like `strtoul' but convert to `uintmax_t'. */
b037a293 342__extern_inline uintmax_t
a784e502 343__NTH (strtoumax (const char *__restrict nptr, char **__restrict endptr,
f377d022 344 int base))
1c25bcac
UD
345{
346 return __strtoul_internal (nptr, endptr, base, 0);
347}
348
a784e502 349extern long int __wcstol_internal (const __gwchar_t * __restrict __nptr,
647eb037 350 __gwchar_t **__restrict __endptr,
9b2e9577
UD
351 int __base, int __group)
352 __THROW __nonnull ((1)) __wur;
353/* Like `wcstol' but convert to `intmax_t'. */
b037a293 354__extern_inline intmax_t
a784e502 355__NTH (wcstoimax (const __gwchar_t *__restrict nptr,
f377d022 356 __gwchar_t **__restrict endptr, int base))
1c25bcac
UD
357{
358 return __wcstol_internal (nptr, endptr, base, 0);
359}
360
a784e502 361extern unsigned long int __wcstoul_internal (const __gwchar_t *
d8cf93f4 362 __restrict __nptr,
647eb037 363 __gwchar_t **
d8cf93f4 364 __restrict __endptr,
9b2e9577
UD
365 int __base, int __group)
366 __THROW __nonnull ((1)) __wur;
367/* Like `wcstoul' but convert to `uintmax_t'. */
b037a293 368__extern_inline uintmax_t
a784e502 369__NTH (wcstoumax (const __gwchar_t *__restrict nptr,
f377d022 370 __gwchar_t **__restrict endptr, int base))
1c25bcac
UD
371{
372 return __wcstoul_internal (nptr, endptr, base, 0);
373}
374
375# else /* __WORDSIZE == 32 */
376
1c25bcac 377__extension__
a784e502 378extern long long int __strtoll_internal (const char *__restrict __nptr,
d8cf93f4 379 char **__restrict __endptr,
9b2e9577
UD
380 int __base, int __group)
381 __THROW __nonnull ((1)) __wur;
382/* Like `strtol' but convert to `intmax_t'. */
b037a293 383__extern_inline intmax_t
a784e502 384__NTH (strtoimax (const char *__restrict nptr, char **__restrict endptr,
f377d022 385 int base))
1c25bcac
UD
386{
387 return __strtoll_internal (nptr, endptr, base, 0);
388}
389
1c25bcac 390__extension__
a784e502 391extern unsigned long long int __strtoull_internal (const char *
d8cf93f4
UD
392 __restrict __nptr,
393 char **
394 __restrict __endptr,
395 int __base,
9b2e9577
UD
396 int __group)
397 __THROW __nonnull ((1)) __wur;
398/* Like `strtoul' but convert to `uintmax_t'. */
b037a293 399__extern_inline uintmax_t
a784e502 400__NTH (strtoumax (const char *__restrict nptr, char **__restrict endptr,
f377d022 401 int base))
1c25bcac
UD
402{
403 return __strtoull_internal (nptr, endptr, base, 0);
404}
405
1c25bcac 406__extension__
a784e502 407extern long long int __wcstoll_internal (const __gwchar_t *__restrict __nptr,
647eb037 408 __gwchar_t **__restrict __endptr,
9b2e9577
UD
409 int __base, int __group)
410 __THROW __nonnull ((1)) __wur;
411/* Like `wcstol' but convert to `intmax_t'. */
b037a293 412__extern_inline intmax_t
a784e502 413__NTH (wcstoimax (const __gwchar_t *__restrict nptr,
f377d022 414 __gwchar_t **__restrict endptr, int base))
1c25bcac
UD
415{
416 return __wcstoll_internal (nptr, endptr, base, 0);
417}
418
419
1c25bcac 420__extension__
a784e502 421extern unsigned long long int __wcstoull_internal (const __gwchar_t *
d8cf93f4 422 __restrict __nptr,
647eb037 423 __gwchar_t **
d8cf93f4
UD
424 __restrict __endptr,
425 int __base,
9b2e9577
UD
426 int __group)
427 __THROW __nonnull ((1)) __wur;
428/* Like `wcstoul' but convert to `uintmax_t'. */
b037a293 429__extern_inline uintmax_t
a784e502 430__NTH (wcstoumax (const __gwchar_t *__restrict nptr,
f377d022 431 __gwchar_t **__restrict endptr, int base))
1c25bcac
UD
432{
433 return __wcstoull_internal (nptr, endptr, base, 0);
434}
435
436# endif /* __WORDSIZE == 32 */
437#endif /* Use extern inlines. */
438
439__END_DECLS
440
441#endif /* inttypes.h */