elf: Remove /etc/suid-debug support
[glibc.git] / stdlib / inttypes.h
blob42ecf681cc7904de8c7b2345049433351e38d11e
1 /* Copyright (C) 1997-2023 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 <https://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
43 # if __WORDSIZE == 64
44 # define __PRI64_PREFIX "l"
45 # define __PRIPTR_PREFIX "l"
46 # else
47 # define __PRI64_PREFIX "ll"
48 # define __PRIPTR_PREFIX
49 # endif
51 /* Macros for printing format specifiers. */
53 /* Decimal notation. */
54 # define PRId8 "d"
55 # define PRId16 "d"
56 # define PRId32 "d"
57 # define PRId64 __PRI64_PREFIX "d"
59 # define PRIdLEAST8 "d"
60 # define PRIdLEAST16 "d"
61 # define PRIdLEAST32 "d"
62 # define PRIdLEAST64 __PRI64_PREFIX "d"
64 # define PRIdFAST8 "d"
65 # define PRIdFAST16 __PRIPTR_PREFIX "d"
66 # define PRIdFAST32 __PRIPTR_PREFIX "d"
67 # define PRIdFAST64 __PRI64_PREFIX "d"
70 # define PRIi8 "i"
71 # define PRIi16 "i"
72 # define PRIi32 "i"
73 # define PRIi64 __PRI64_PREFIX "i"
75 # define PRIiLEAST8 "i"
76 # define PRIiLEAST16 "i"
77 # define PRIiLEAST32 "i"
78 # define PRIiLEAST64 __PRI64_PREFIX "i"
80 # define PRIiFAST8 "i"
81 # define PRIiFAST16 __PRIPTR_PREFIX "i"
82 # define PRIiFAST32 __PRIPTR_PREFIX "i"
83 # define PRIiFAST64 __PRI64_PREFIX "i"
85 /* Octal notation. */
86 # define PRIo8 "o"
87 # define PRIo16 "o"
88 # define PRIo32 "o"
89 # define PRIo64 __PRI64_PREFIX "o"
91 # define PRIoLEAST8 "o"
92 # define PRIoLEAST16 "o"
93 # define PRIoLEAST32 "o"
94 # define PRIoLEAST64 __PRI64_PREFIX "o"
96 # define PRIoFAST8 "o"
97 # define PRIoFAST16 __PRIPTR_PREFIX "o"
98 # define PRIoFAST32 __PRIPTR_PREFIX "o"
99 # define PRIoFAST64 __PRI64_PREFIX "o"
101 /* Unsigned integers. */
102 # define PRIu8 "u"
103 # define PRIu16 "u"
104 # define PRIu32 "u"
105 # define PRIu64 __PRI64_PREFIX "u"
107 # define PRIuLEAST8 "u"
108 # define PRIuLEAST16 "u"
109 # define PRIuLEAST32 "u"
110 # define PRIuLEAST64 __PRI64_PREFIX "u"
112 # define PRIuFAST8 "u"
113 # define PRIuFAST16 __PRIPTR_PREFIX "u"
114 # define PRIuFAST32 __PRIPTR_PREFIX "u"
115 # define PRIuFAST64 __PRI64_PREFIX "u"
117 /* lowercase hexadecimal notation. */
118 # define PRIx8 "x"
119 # define PRIx16 "x"
120 # define PRIx32 "x"
121 # define PRIx64 __PRI64_PREFIX "x"
123 # define PRIxLEAST8 "x"
124 # define PRIxLEAST16 "x"
125 # define PRIxLEAST32 "x"
126 # define PRIxLEAST64 __PRI64_PREFIX "x"
128 # define PRIxFAST8 "x"
129 # define PRIxFAST16 __PRIPTR_PREFIX "x"
130 # define PRIxFAST32 __PRIPTR_PREFIX "x"
131 # define PRIxFAST64 __PRI64_PREFIX "x"
133 /* UPPERCASE hexadecimal notation. */
134 # define PRIX8 "X"
135 # define PRIX16 "X"
136 # define PRIX32 "X"
137 # define PRIX64 __PRI64_PREFIX "X"
139 # define PRIXLEAST8 "X"
140 # define PRIXLEAST16 "X"
141 # define PRIXLEAST32 "X"
142 # define PRIXLEAST64 __PRI64_PREFIX "X"
144 # define PRIXFAST8 "X"
145 # define PRIXFAST16 __PRIPTR_PREFIX "X"
146 # define PRIXFAST32 __PRIPTR_PREFIX "X"
147 # define PRIXFAST64 __PRI64_PREFIX "X"
150 /* Macros for printing `intmax_t' and `uintmax_t'. */
151 # define PRIdMAX __PRI64_PREFIX "d"
152 # define PRIiMAX __PRI64_PREFIX "i"
153 # define PRIoMAX __PRI64_PREFIX "o"
154 # define PRIuMAX __PRI64_PREFIX "u"
155 # define PRIxMAX __PRI64_PREFIX "x"
156 # define PRIXMAX __PRI64_PREFIX "X"
159 /* Macros for printing `intptr_t' and `uintptr_t'. */
160 # define PRIdPTR __PRIPTR_PREFIX "d"
161 # define PRIiPTR __PRIPTR_PREFIX "i"
162 # define PRIoPTR __PRIPTR_PREFIX "o"
163 # define PRIuPTR __PRIPTR_PREFIX "u"
164 # define PRIxPTR __PRIPTR_PREFIX "x"
165 # define PRIXPTR __PRIPTR_PREFIX "X"
167 /* Binary notation. */
168 # if __GLIBC_USE (ISOC2X)
169 # define PRIb8 "b"
170 # define PRIb16 "b"
171 # define PRIb32 "b"
172 # define PRIb64 __PRI64_PREFIX "b"
174 # define PRIbLEAST8 "b"
175 # define PRIbLEAST16 "b"
176 # define PRIbLEAST32 "b"
177 # define PRIbLEAST64 __PRI64_PREFIX "b"
179 # define PRIbFAST8 "b"
180 # define PRIbFAST16 __PRIPTR_PREFIX "b"
181 # define PRIbFAST32 __PRIPTR_PREFIX "b"
182 # define PRIbFAST64 __PRI64_PREFIX "b"
184 # define PRIbMAX __PRI64_PREFIX "b"
185 # define PRIbPTR __PRIPTR_PREFIX "b"
187 # define PRIB8 "B"
188 # define PRIB16 "B"
189 # define PRIB32 "B"
190 # define PRIB64 __PRI64_PREFIX "B"
192 # define PRIBLEAST8 "B"
193 # define PRIBLEAST16 "B"
194 # define PRIBLEAST32 "B"
195 # define PRIBLEAST64 __PRI64_PREFIX "B"
197 # define PRIBFAST8 "B"
198 # define PRIBFAST16 __PRIPTR_PREFIX "B"
199 # define PRIBFAST32 __PRIPTR_PREFIX "B"
200 # define PRIBFAST64 __PRI64_PREFIX "B"
202 # define PRIBMAX __PRI64_PREFIX "B"
203 # define PRIBPTR __PRIPTR_PREFIX "B"
204 # endif
207 /* Macros for scanning format specifiers. */
209 /* Signed decimal notation. */
210 # define SCNd8 "hhd"
211 # define SCNd16 "hd"
212 # define SCNd32 "d"
213 # define SCNd64 __PRI64_PREFIX "d"
215 # define SCNdLEAST8 "hhd"
216 # define SCNdLEAST16 "hd"
217 # define SCNdLEAST32 "d"
218 # define SCNdLEAST64 __PRI64_PREFIX "d"
220 # define SCNdFAST8 "hhd"
221 # define SCNdFAST16 __PRIPTR_PREFIX "d"
222 # define SCNdFAST32 __PRIPTR_PREFIX "d"
223 # define SCNdFAST64 __PRI64_PREFIX "d"
225 /* Signed decimal notation. */
226 # define SCNi8 "hhi"
227 # define SCNi16 "hi"
228 # define SCNi32 "i"
229 # define SCNi64 __PRI64_PREFIX "i"
231 # define SCNiLEAST8 "hhi"
232 # define SCNiLEAST16 "hi"
233 # define SCNiLEAST32 "i"
234 # define SCNiLEAST64 __PRI64_PREFIX "i"
236 # define SCNiFAST8 "hhi"
237 # define SCNiFAST16 __PRIPTR_PREFIX "i"
238 # define SCNiFAST32 __PRIPTR_PREFIX "i"
239 # define SCNiFAST64 __PRI64_PREFIX "i"
241 /* Unsigned decimal notation. */
242 # define SCNu8 "hhu"
243 # define SCNu16 "hu"
244 # define SCNu32 "u"
245 # define SCNu64 __PRI64_PREFIX "u"
247 # define SCNuLEAST8 "hhu"
248 # define SCNuLEAST16 "hu"
249 # define SCNuLEAST32 "u"
250 # define SCNuLEAST64 __PRI64_PREFIX "u"
252 # define SCNuFAST8 "hhu"
253 # define SCNuFAST16 __PRIPTR_PREFIX "u"
254 # define SCNuFAST32 __PRIPTR_PREFIX "u"
255 # define SCNuFAST64 __PRI64_PREFIX "u"
257 /* Octal notation. */
258 # define SCNo8 "hho"
259 # define SCNo16 "ho"
260 # define SCNo32 "o"
261 # define SCNo64 __PRI64_PREFIX "o"
263 # define SCNoLEAST8 "hho"
264 # define SCNoLEAST16 "ho"
265 # define SCNoLEAST32 "o"
266 # define SCNoLEAST64 __PRI64_PREFIX "o"
268 # define SCNoFAST8 "hho"
269 # define SCNoFAST16 __PRIPTR_PREFIX "o"
270 # define SCNoFAST32 __PRIPTR_PREFIX "o"
271 # define SCNoFAST64 __PRI64_PREFIX "o"
273 /* Hexadecimal notation. */
274 # define SCNx8 "hhx"
275 # define SCNx16 "hx"
276 # define SCNx32 "x"
277 # define SCNx64 __PRI64_PREFIX "x"
279 # define SCNxLEAST8 "hhx"
280 # define SCNxLEAST16 "hx"
281 # define SCNxLEAST32 "x"
282 # define SCNxLEAST64 __PRI64_PREFIX "x"
284 # define SCNxFAST8 "hhx"
285 # define SCNxFAST16 __PRIPTR_PREFIX "x"
286 # define SCNxFAST32 __PRIPTR_PREFIX "x"
287 # define SCNxFAST64 __PRI64_PREFIX "x"
290 /* Macros for scanning `intmax_t' and `uintmax_t'. */
291 # define SCNdMAX __PRI64_PREFIX "d"
292 # define SCNiMAX __PRI64_PREFIX "i"
293 # define SCNoMAX __PRI64_PREFIX "o"
294 # define SCNuMAX __PRI64_PREFIX "u"
295 # define SCNxMAX __PRI64_PREFIX "x"
297 /* Macros for scanning `intptr_t' and `uintptr_t'. */
298 # define SCNdPTR __PRIPTR_PREFIX "d"
299 # define SCNiPTR __PRIPTR_PREFIX "i"
300 # define SCNoPTR __PRIPTR_PREFIX "o"
301 # define SCNuPTR __PRIPTR_PREFIX "u"
302 # define SCNxPTR __PRIPTR_PREFIX "x"
305 /* Binary notation. */
306 # if __GLIBC_USE (ISOC2X)
307 # define SCNb8 "hhb"
308 # define SCNb16 "hb"
309 # define SCNb32 "b"
310 # define SCNb64 __PRI64_PREFIX "b"
312 # define SCNbLEAST8 "hhb"
313 # define SCNbLEAST16 "hb"
314 # define SCNbLEAST32 "b"
315 # define SCNbLEAST64 __PRI64_PREFIX "b"
317 # define SCNbFAST8 "hhb"
318 # define SCNbFAST16 __PRIPTR_PREFIX "b"
319 # define SCNbFAST32 __PRIPTR_PREFIX "b"
320 # define SCNbFAST64 __PRI64_PREFIX "b"
322 # define SCNbMAX __PRI64_PREFIX "b"
323 # define SCNbPTR __PRIPTR_PREFIX "b"
324 # endif
327 __BEGIN_DECLS
329 #if __WORDSIZE == 64
331 /* We have to define the `uintmax_t' type using `ldiv_t'. */
332 typedef struct
334 long int quot; /* Quotient. */
335 long int rem; /* Remainder. */
336 } imaxdiv_t;
338 #else
340 /* We have to define the `uintmax_t' type using `lldiv_t'. */
341 typedef struct
343 __extension__ long long int quot; /* Quotient. */
344 __extension__ long long int rem; /* Remainder. */
345 } imaxdiv_t;
347 #endif
350 /* Compute absolute value of N. */
351 extern intmax_t imaxabs (intmax_t __n) __THROW __attribute__ ((__const__));
353 /* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */
354 extern imaxdiv_t imaxdiv (intmax_t __numer, intmax_t __denom)
355 __THROW __attribute__ ((__const__));
357 /* Like `strtol' but convert to `intmax_t'. */
358 extern intmax_t strtoimax (const char *__restrict __nptr,
359 char **__restrict __endptr, int __base) __THROW;
361 /* Like `strtoul' but convert to `uintmax_t'. */
362 extern uintmax_t strtoumax (const char *__restrict __nptr,
363 char ** __restrict __endptr, int __base) __THROW;
365 /* Like `wcstol' but convert to `intmax_t'. */
366 extern intmax_t wcstoimax (const __gwchar_t *__restrict __nptr,
367 __gwchar_t **__restrict __endptr, int __base)
368 __THROW;
370 /* Like `wcstoul' but convert to `uintmax_t'. */
371 extern uintmax_t wcstoumax (const __gwchar_t *__restrict __nptr,
372 __gwchar_t ** __restrict __endptr, int __base)
373 __THROW;
375 /* Versions of the above functions that handle '0b' and '0B' prefixes
376 in base 0 or 2. */
377 #if __GLIBC_USE (C2X_STRTOL)
378 # ifdef __REDIRECT
379 extern intmax_t __REDIRECT_NTH (strtoimax, (const char *__restrict __nptr,
380 char **__restrict __endptr,
381 int __base), __isoc23_strtoimax);
382 extern uintmax_t __REDIRECT_NTH (strtoumax, (const char *__restrict __nptr,
383 char **__restrict __endptr,
384 int __base), __isoc23_strtoumax);
385 extern intmax_t __REDIRECT_NTH (wcstoimax,
386 (const __gwchar_t *__restrict __nptr,
387 __gwchar_t **__restrict __endptr, int __base),
388 __isoc23_wcstoimax);
389 extern uintmax_t __REDIRECT_NTH (wcstoumax,
390 (const __gwchar_t *__restrict __nptr,
391 __gwchar_t **__restrict __endptr, int __base),
392 __isoc23_wcstoumax);
393 # else
394 extern intmax_t __isoc23_strtoimax (const char *__restrict __nptr,
395 char **__restrict __endptr, int __base)
396 __THROW;
397 extern uintmax_t __isoc23_strtoumax (const char *__restrict __nptr,
398 char ** __restrict __endptr, int __base)
399 __THROW;
400 extern intmax_t __isoc23_wcstoimax (const __gwchar_t *__restrict __nptr,
401 __gwchar_t **__restrict __endptr,
402 int __base)
403 __THROW;
404 extern uintmax_t __isoc23_wcstoumax (const __gwchar_t *__restrict __nptr,
405 __gwchar_t ** __restrict __endptr,
406 int __base)
407 __THROW;
408 # define strtoimax __isoc23_strtoimax
409 # define strtoumax __isoc23_strtoumax
410 # define wcstoimax __isoc23_wcstoimax
411 # define wcstoumax __isoc23_wcstoumax
412 # endif
413 #endif
415 __END_DECLS
417 #endif /* inttypes.h */