1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (C) 1997-2001, 2004, 2007 Free Software Foundation, Inc.
5 * This file is taken from the GNU C Library v2.15, with the unimplemented
6 * functions removed and a few style fixes.
10 * ISO C99: 7.8 Format conversion of integer types <inttypes.h>
16 #include <linux/compiler.h>
18 /* Get a definition for wchar_t. But we must not define wchar_t itself. */
19 #ifndef ____gwchar_t_defined
21 # define __gwchar_t wchar_t
22 # elif defined __WCHAR_TYPE__
23 typedef __WCHAR_TYPE__ __gwchar_t
;
25 # define __need_wchar_t
26 # include <linux/stddef.h>
27 typedef wchar_t __gwchar_t
;
29 # define ____gwchar_t_defined 1
33 * The ISO C99 standard specifies that these macros must only be defined if
34 * explicitly requested
36 #if !defined __cplusplus || defined __STDC_FORMAT_MACROS
38 /* linux/types.h always uses long long for 64-bit and long for uintptr_t */
39 # define __PRI64_PREFIX "ll"
40 # define __PRIPTR_PREFIX "l"
42 /* Macros for printing format specifiers. */
44 /* Decimal notation. */
48 # define PRId64 __PRI64_PREFIX "d"
50 # define PRIdLEAST8 "d"
51 # define PRIdLEAST16 "d"
52 # define PRIdLEAST32 "d"
53 # define PRIdLEAST64 __PRI64_PREFIX "d"
55 # define PRIdFAST8 "d"
56 # define PRIdFAST16 __PRIPTR_PREFIX "d"
57 # define PRIdFAST32 __PRIPTR_PREFIX "d"
58 # define PRIdFAST64 __PRI64_PREFIX "d"
63 # define PRIi64 __PRI64_PREFIX "i"
65 # define PRIiLEAST8 "i"
66 # define PRIiLEAST16 "i"
67 # define PRIiLEAST32 "i"
68 # define PRIiLEAST64 __PRI64_PREFIX "i"
70 # define PRIiFAST8 "i"
71 # define PRIiFAST16 __PRIPTR_PREFIX "i"
72 # define PRIiFAST32 __PRIPTR_PREFIX "i"
73 # define PRIiFAST64 __PRI64_PREFIX "i"
79 # define PRIo64 __PRI64_PREFIX "o"
81 # define PRIoLEAST8 "o"
82 # define PRIoLEAST16 "o"
83 # define PRIoLEAST32 "o"
84 # define PRIoLEAST64 __PRI64_PREFIX "o"
86 # define PRIoFAST8 "o"
87 # define PRIoFAST16 __PRIPTR_PREFIX "o"
88 # define PRIoFAST32 __PRIPTR_PREFIX "o"
89 # define PRIoFAST64 __PRI64_PREFIX "o"
91 /* Unsigned integers. */
95 # define PRIu64 __PRI64_PREFIX "u"
97 # define PRIuLEAST8 "u"
98 # define PRIuLEAST16 "u"
99 # define PRIuLEAST32 "u"
100 # define PRIuLEAST64 __PRI64_PREFIX "u"
102 # define PRIuFAST8 "u"
103 # define PRIuFAST16 __PRIPTR_PREFIX "u"
104 # define PRIuFAST32 __PRIPTR_PREFIX "u"
105 # define PRIuFAST64 __PRI64_PREFIX "u"
107 /* lowercase hexadecimal notation. */
111 # define PRIx64 __PRI64_PREFIX "x"
113 # define PRIxLEAST8 "x"
114 # define PRIxLEAST16 "x"
115 # define PRIxLEAST32 "x"
116 # define PRIxLEAST64 __PRI64_PREFIX "x"
118 # define PRIxFAST8 "x"
119 # define PRIxFAST16 __PRIPTR_PREFIX "x"
120 # define PRIxFAST32 __PRIPTR_PREFIX "x"
121 # define PRIxFAST64 __PRI64_PREFIX "x"
123 /* UPPERCASE hexadecimal notation. */
127 # define PRIX64 __PRI64_PREFIX "X"
129 # define PRIXLEAST8 "X"
130 # define PRIXLEAST16 "X"
131 # define PRIXLEAST32 "X"
132 # define PRIXLEAST64 __PRI64_PREFIX "X"
134 # define PRIXFAST8 "X"
135 # define PRIXFAST16 __PRIPTR_PREFIX "X"
136 # define PRIXFAST32 __PRIPTR_PREFIX "X"
137 # define PRIXFAST64 __PRI64_PREFIX "X"
139 /* Macros for printing `intmax_t' and `uintmax_t'. */
140 # define PRIdMAX __PRI64_PREFIX "d"
141 # define PRIiMAX __PRI64_PREFIX "i"
142 # define PRIoMAX __PRI64_PREFIX "o"
143 # define PRIuMAX __PRI64_PREFIX "u"
144 # define PRIxMAX __PRI64_PREFIX "x"
145 # define PRIXMAX __PRI64_PREFIX "X"
147 /* Macros for printing `intptr_t' and `uintptr_t'. */
148 # define PRIdPTR __PRIPTR_PREFIX "d"
149 # define PRIiPTR __PRIPTR_PREFIX "i"
150 # define PRIoPTR __PRIPTR_PREFIX "o"
151 # define PRIuPTR __PRIPTR_PREFIX "u"
152 # define PRIxPTR __PRIPTR_PREFIX "x"
153 # define PRIXPTR __PRIPTR_PREFIX "X"
155 /* Macros for scanning format specifiers. */
157 /* Signed decimal notation. */
161 # define SCNd64 __PRI64_PREFIX "d"
163 # define SCNdLEAST8 "hhd"
164 # define SCNdLEAST16 "hd"
165 # define SCNdLEAST32 "d"
166 # define SCNdLEAST64 __PRI64_PREFIX "d"
168 # define SCNdFAST8 "hhd"
169 # define SCNdFAST16 __PRIPTR_PREFIX "d"
170 # define SCNdFAST32 __PRIPTR_PREFIX "d"
171 # define SCNdFAST64 __PRI64_PREFIX "d"
173 /* Signed decimal notation. */
177 # define SCNi64 __PRI64_PREFIX "i"
179 # define SCNiLEAST8 "hhi"
180 # define SCNiLEAST16 "hi"
181 # define SCNiLEAST32 "i"
182 # define SCNiLEAST64 __PRI64_PREFIX "i"
184 # define SCNiFAST8 "hhi"
185 # define SCNiFAST16 __PRIPTR_PREFIX "i"
186 # define SCNiFAST32 __PRIPTR_PREFIX "i"
187 # define SCNiFAST64 __PRI64_PREFIX "i"
189 /* Unsigned decimal notation. */
193 # define SCNu64 __PRI64_PREFIX "u"
195 # define SCNuLEAST8 "hhu"
196 # define SCNuLEAST16 "hu"
197 # define SCNuLEAST32 "u"
198 # define SCNuLEAST64 __PRI64_PREFIX "u"
200 # define SCNuFAST8 "hhu"
201 # define SCNuFAST16 __PRIPTR_PREFIX "u"
202 # define SCNuFAST32 __PRIPTR_PREFIX "u"
203 # define SCNuFAST64 __PRI64_PREFIX "u"
205 /* Octal notation. */
209 # define SCNo64 __PRI64_PREFIX "o"
211 # define SCNoLEAST8 "hho"
212 # define SCNoLEAST16 "ho"
213 # define SCNoLEAST32 "o"
214 # define SCNoLEAST64 __PRI64_PREFIX "o"
216 # define SCNoFAST8 "hho"
217 # define SCNoFAST16 __PRIPTR_PREFIX "o"
218 # define SCNoFAST32 __PRIPTR_PREFIX "o"
219 # define SCNoFAST64 __PRI64_PREFIX "o"
221 /* Hexadecimal notation. */
225 # define SCNx64 __PRI64_PREFIX "x"
227 # define SCNxLEAST8 "hhx"
228 # define SCNxLEAST16 "hx"
229 # define SCNxLEAST32 "x"
230 # define SCNxLEAST64 __PRI64_PREFIX "x"
232 # define SCNxFAST8 "hhx"
233 # define SCNxFAST16 __PRIPTR_PREFIX "x"
234 # define SCNxFAST32 __PRIPTR_PREFIX "x"
235 # define SCNxFAST64 __PRI64_PREFIX "x"
237 /* Macros for scanning `intmax_t' and `uintmax_t'. */
238 # define SCNdMAX __PRI64_PREFIX "d"
239 # define SCNiMAX __PRI64_PREFIX "i"
240 # define SCNoMAX __PRI64_PREFIX "o"
241 # define SCNuMAX __PRI64_PREFIX "u"
242 # define SCNxMAX __PRI64_PREFIX "x"
244 /* Macros for scanning `intptr_t' and `uintptr_t'. */
245 # define SCNdPTR __PRIPTR_PREFIX "d"
246 # define SCNiPTR __PRIPTR_PREFIX "i"
247 # define SCNoPTR __PRIPTR_PREFIX "o"
248 # define SCNuPTR __PRIPTR_PREFIX "u"
249 # define SCNxPTR __PRIPTR_PREFIX "x"
251 #endif /* C++ && format macros */
255 /* We have to define the `uintmax_t' type using `ldiv_t'. */
257 long int quot
; /* Quotient. */
258 long int rem
; /* Remainder. */
263 /* We have to define the `uintmax_t' type using `lldiv_t'. */
265 long long int quot
; /* Quotient. */
266 long long int rem
; /* Remainder. */
271 #endif /* inttypes.h */