PowerPC: Change sched_getcpu to use vDSO getcpu instead of syscall.
[glibc.git] / sysdeps / generic / inttypes.h
blob47fe751e29a9516523db1f4276ef1b99bb837f54
1 /* Copyright (C) 1997-2013 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, see
16 <http://www.gnu.org/licenses/>. */
19 * ISO C99: 7.8 Format conversion of integer types <inttypes.h>
22 #ifndef _INTTYPES_H
23 #define _INTTYPES_H 1
25 #include <features.h>
26 /* Get the type definitions. */
27 #include <stdint.h>
29 /* Get a definition for wchar_t. But we must not define wchar_t itself. */
30 #ifndef ____gwchar_t_defined
31 # ifdef __cplusplus
32 # define __gwchar_t wchar_t
33 # elif defined __WCHAR_TYPE__
34 typedef __WCHAR_TYPE__ __gwchar_t;
35 # else
36 # define __need_wchar_t
37 # include <stddef.h>
38 typedef wchar_t __gwchar_t;
39 # endif
40 # define ____gwchar_t_defined 1
41 #endif
44 /* The ISO C99 standard specifies that these macros must only be
45 defined if explicitly requested. */
46 #if !defined __cplusplus || defined __STDC_FORMAT_MACROS
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
56 /* Macros for printing format specifiers. */
58 /* Decimal notation. */
59 # define PRId8 "d"
60 # define PRId16 "d"
61 # define PRId32 "d"
62 # define PRId64 __PRI64_PREFIX "d"
64 # define PRIdLEAST8 "d"
65 # define PRIdLEAST16 "d"
66 # define PRIdLEAST32 "d"
67 # define PRIdLEAST64 __PRI64_PREFIX "d"
69 # define PRIdFAST8 "d"
70 # define PRIdFAST16 __PRIPTR_PREFIX "d"
71 # define PRIdFAST32 __PRIPTR_PREFIX "d"
72 # define PRIdFAST64 __PRI64_PREFIX "d"
75 # define PRIi8 "i"
76 # define PRIi16 "i"
77 # define PRIi32 "i"
78 # define PRIi64 __PRI64_PREFIX "i"
80 # define PRIiLEAST8 "i"
81 # define PRIiLEAST16 "i"
82 # define PRIiLEAST32 "i"
83 # define PRIiLEAST64 __PRI64_PREFIX "i"
85 # define PRIiFAST8 "i"
86 # define PRIiFAST16 __PRIPTR_PREFIX "i"
87 # define PRIiFAST32 __PRIPTR_PREFIX "i"
88 # define PRIiFAST64 __PRI64_PREFIX "i"
90 /* Octal notation. */
91 # define PRIo8 "o"
92 # define PRIo16 "o"
93 # define PRIo32 "o"
94 # define PRIo64 __PRI64_PREFIX "o"
96 # define PRIoLEAST8 "o"
97 # define PRIoLEAST16 "o"
98 # define PRIoLEAST32 "o"
99 # define PRIoLEAST64 __PRI64_PREFIX "o"
101 # define PRIoFAST8 "o"
102 # define PRIoFAST16 __PRIPTR_PREFIX "o"
103 # define PRIoFAST32 __PRIPTR_PREFIX "o"
104 # define PRIoFAST64 __PRI64_PREFIX "o"
106 /* Unsigned integers. */
107 # define PRIu8 "u"
108 # define PRIu16 "u"
109 # define PRIu32 "u"
110 # define PRIu64 __PRI64_PREFIX "u"
112 # define PRIuLEAST8 "u"
113 # define PRIuLEAST16 "u"
114 # define PRIuLEAST32 "u"
115 # define PRIuLEAST64 __PRI64_PREFIX "u"
117 # define PRIuFAST8 "u"
118 # define PRIuFAST16 __PRIPTR_PREFIX "u"
119 # define PRIuFAST32 __PRIPTR_PREFIX "u"
120 # define PRIuFAST64 __PRI64_PREFIX "u"
122 /* lowercase hexadecimal notation. */
123 # define PRIx8 "x"
124 # define PRIx16 "x"
125 # define PRIx32 "x"
126 # define PRIx64 __PRI64_PREFIX "x"
128 # define PRIxLEAST8 "x"
129 # define PRIxLEAST16 "x"
130 # define PRIxLEAST32 "x"
131 # define PRIxLEAST64 __PRI64_PREFIX "x"
133 # define PRIxFAST8 "x"
134 # define PRIxFAST16 __PRIPTR_PREFIX "x"
135 # define PRIxFAST32 __PRIPTR_PREFIX "x"
136 # define PRIxFAST64 __PRI64_PREFIX "x"
138 /* UPPERCASE hexadecimal notation. */
139 # define PRIX8 "X"
140 # define PRIX16 "X"
141 # define PRIX32 "X"
142 # define PRIX64 __PRI64_PREFIX "X"
144 # define PRIXLEAST8 "X"
145 # define PRIXLEAST16 "X"
146 # define PRIXLEAST32 "X"
147 # define PRIXLEAST64 __PRI64_PREFIX "X"
149 # define PRIXFAST8 "X"
150 # define PRIXFAST16 __PRIPTR_PREFIX "X"
151 # define PRIXFAST32 __PRIPTR_PREFIX "X"
152 # define PRIXFAST64 __PRI64_PREFIX "X"
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"
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"
173 /* Macros for scanning format specifiers. */
175 /* Signed decimal notation. */
176 # define SCNd8 "hhd"
177 # define SCNd16 "hd"
178 # define SCNd32 "d"
179 # define SCNd64 __PRI64_PREFIX "d"
181 # define SCNdLEAST8 "hhd"
182 # define SCNdLEAST16 "hd"
183 # define SCNdLEAST32 "d"
184 # define SCNdLEAST64 __PRI64_PREFIX "d"
186 # define SCNdFAST8 "hhd"
187 # define SCNdFAST16 __PRIPTR_PREFIX "d"
188 # define SCNdFAST32 __PRIPTR_PREFIX "d"
189 # define SCNdFAST64 __PRI64_PREFIX "d"
191 /* Signed decimal notation. */
192 # define SCNi8 "hhi"
193 # define SCNi16 "hi"
194 # define SCNi32 "i"
195 # define SCNi64 __PRI64_PREFIX "i"
197 # define SCNiLEAST8 "hhi"
198 # define SCNiLEAST16 "hi"
199 # define SCNiLEAST32 "i"
200 # define SCNiLEAST64 __PRI64_PREFIX "i"
202 # define SCNiFAST8 "hhi"
203 # define SCNiFAST16 __PRIPTR_PREFIX "i"
204 # define SCNiFAST32 __PRIPTR_PREFIX "i"
205 # define SCNiFAST64 __PRI64_PREFIX "i"
207 /* Unsigned decimal notation. */
208 # define SCNu8 "hhu"
209 # define SCNu16 "hu"
210 # define SCNu32 "u"
211 # define SCNu64 __PRI64_PREFIX "u"
213 # define SCNuLEAST8 "hhu"
214 # define SCNuLEAST16 "hu"
215 # define SCNuLEAST32 "u"
216 # define SCNuLEAST64 __PRI64_PREFIX "u"
218 # define SCNuFAST8 "hhu"
219 # define SCNuFAST16 __PRIPTR_PREFIX "u"
220 # define SCNuFAST32 __PRIPTR_PREFIX "u"
221 # define SCNuFAST64 __PRI64_PREFIX "u"
223 /* Octal notation. */
224 # define SCNo8 "hho"
225 # define SCNo16 "ho"
226 # define SCNo32 "o"
227 # define SCNo64 __PRI64_PREFIX "o"
229 # define SCNoLEAST8 "hho"
230 # define SCNoLEAST16 "ho"
231 # define SCNoLEAST32 "o"
232 # define SCNoLEAST64 __PRI64_PREFIX "o"
234 # define SCNoFAST8 "hho"
235 # define SCNoFAST16 __PRIPTR_PREFIX "o"
236 # define SCNoFAST32 __PRIPTR_PREFIX "o"
237 # define SCNoFAST64 __PRI64_PREFIX "o"
239 /* Hexadecimal notation. */
240 # define SCNx8 "hhx"
241 # define SCNx16 "hx"
242 # define SCNx32 "x"
243 # define SCNx64 __PRI64_PREFIX "x"
245 # define SCNxLEAST8 "hhx"
246 # define SCNxLEAST16 "hx"
247 # define SCNxLEAST32 "x"
248 # define SCNxLEAST64 __PRI64_PREFIX "x"
250 # define SCNxFAST8 "hhx"
251 # define SCNxFAST16 __PRIPTR_PREFIX "x"
252 # define SCNxFAST32 __PRIPTR_PREFIX "x"
253 # define SCNxFAST64 __PRI64_PREFIX "x"
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"
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"
270 #endif /* C++ && format macros */
273 __BEGIN_DECLS
275 #if __WORDSIZE == 64
277 /* We have to define the `uintmax_t' type using `ldiv_t'. */
278 typedef struct
280 long int quot; /* Quotient. */
281 long int rem; /* Remainder. */
282 } imaxdiv_t;
284 #else
286 /* We have to define the `uintmax_t' type using `lldiv_t'. */
287 typedef struct
289 long long int quot; /* Quotient. */
290 long long int rem; /* Remainder. */
291 } imaxdiv_t;
293 #endif
296 /* Compute absolute value of N. */
297 extern intmax_t imaxabs (intmax_t __n) __THROW __attribute__ ((__const__));
299 /* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */
300 extern imaxdiv_t imaxdiv (intmax_t __numer, intmax_t __denom)
301 __THROW __attribute__ ((__const__));
303 /* Like `strtol' but convert to `intmax_t'. */
304 extern intmax_t strtoimax (const char *__restrict __nptr,
305 char **__restrict __endptr, int __base) __THROW;
307 /* Like `strtoul' but convert to `uintmax_t'. */
308 extern uintmax_t strtoumax (const char *__restrict __nptr,
309 char ** __restrict __endptr, int __base) __THROW;
311 /* Like `wcstol' but convert to `intmax_t'. */
312 extern intmax_t wcstoimax (const __gwchar_t *__restrict __nptr,
313 __gwchar_t **__restrict __endptr, int __base)
314 __THROW;
316 /* Like `wcstoul' but convert to `uintmax_t'. */
317 extern uintmax_t wcstoumax (const __gwchar_t *__restrict __nptr,
318 __gwchar_t ** __restrict __endptr, int __base)
319 __THROW;
321 #ifdef __USE_EXTERN_INLINES
323 # if __WORDSIZE == 64
325 extern long int __strtol_internal (const char *__restrict __nptr,
326 char **__restrict __endptr,
327 int __base, int __group)
328 __THROW __nonnull ((1)) __wur;
329 /* Like `strtol' but convert to `intmax_t'. */
330 __extern_inline intmax_t
331 __NTH (strtoimax (const char *__restrict nptr, char **__restrict endptr,
332 int base))
334 return __strtol_internal (nptr, endptr, base, 0);
337 extern unsigned long int __strtoul_internal (const char *__restrict __nptr,
338 char ** __restrict __endptr,
339 int __base, int __group)
340 __THROW __nonnull ((1)) __wur;
341 /* Like `strtoul' but convert to `uintmax_t'. */
342 __extern_inline uintmax_t
343 __NTH (strtoumax (const char *__restrict nptr, char **__restrict endptr,
344 int base))
346 return __strtoul_internal (nptr, endptr, base, 0);
349 extern long int __wcstol_internal (const __gwchar_t * __restrict __nptr,
350 __gwchar_t **__restrict __endptr,
351 int __base, int __group)
352 __THROW __nonnull ((1)) __wur;
353 /* Like `wcstol' but convert to `intmax_t'. */
354 __extern_inline intmax_t
355 __NTH (wcstoimax (const __gwchar_t *__restrict nptr,
356 __gwchar_t **__restrict endptr, int base))
358 return __wcstol_internal (nptr, endptr, base, 0);
361 extern unsigned long int __wcstoul_internal (const __gwchar_t *
362 __restrict __nptr,
363 __gwchar_t **
364 __restrict __endptr,
365 int __base, int __group)
366 __THROW __nonnull ((1)) __wur;
367 /* Like `wcstoul' but convert to `uintmax_t'. */
368 __extern_inline uintmax_t
369 __NTH (wcstoumax (const __gwchar_t *__restrict nptr,
370 __gwchar_t **__restrict endptr, int base))
372 return __wcstoul_internal (nptr, endptr, base, 0);
375 # else /* __WORDSIZE == 32 */
377 __extension__
378 extern long long int __strtoll_internal (const char *__restrict __nptr,
379 char **__restrict __endptr,
380 int __base, int __group)
381 __THROW __nonnull ((1)) __wur;
382 /* Like `strtol' but convert to `intmax_t'. */
383 __extern_inline intmax_t
384 __NTH (strtoimax (const char *__restrict nptr, char **__restrict endptr,
385 int base))
387 return __strtoll_internal (nptr, endptr, base, 0);
390 __extension__
391 extern unsigned long long int __strtoull_internal (const char *
392 __restrict __nptr,
393 char **
394 __restrict __endptr,
395 int __base,
396 int __group)
397 __THROW __nonnull ((1)) __wur;
398 /* Like `strtoul' but convert to `uintmax_t'. */
399 __extern_inline uintmax_t
400 __NTH (strtoumax (const char *__restrict nptr, char **__restrict endptr,
401 int base))
403 return __strtoull_internal (nptr, endptr, base, 0);
406 __extension__
407 extern long long int __wcstoll_internal (const __gwchar_t *__restrict __nptr,
408 __gwchar_t **__restrict __endptr,
409 int __base, int __group)
410 __THROW __nonnull ((1)) __wur;
411 /* Like `wcstol' but convert to `intmax_t'. */
412 __extern_inline intmax_t
413 __NTH (wcstoimax (const __gwchar_t *__restrict nptr,
414 __gwchar_t **__restrict endptr, int base))
416 return __wcstoll_internal (nptr, endptr, base, 0);
420 __extension__
421 extern unsigned long long int __wcstoull_internal (const __gwchar_t *
422 __restrict __nptr,
423 __gwchar_t **
424 __restrict __endptr,
425 int __base,
426 int __group)
427 __THROW __nonnull ((1)) __wur;
428 /* Like `wcstoul' but convert to `uintmax_t'. */
429 __extern_inline uintmax_t
430 __NTH (wcstoumax (const __gwchar_t *__restrict nptr,
431 __gwchar_t **__restrict endptr, int base))
433 return __wcstoull_internal (nptr, endptr, base, 0);
436 # endif /* __WORDSIZE == 32 */
437 #endif /* Use extern inlines. */
439 __END_DECLS
441 #endif /* inttypes.h */