int_fmtio.h revision 1.2 1 /* $NetBSD: int_fmtio.h,v 1.2 2019/04/13 15:56:18 maya Exp $ */
2
3 /*-
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Klaus Klein.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #ifndef _RISCV_INT_FMTIO_H_
33 #define _RISCV_INT_FMTIO_H_
34
35 #ifdef __INTPTR_FMTd__
36 #include <sys/common_int_fmtio.h>
37 #else
38 /*
39 * 7.8.1 Macros for format specifiers
40 */
41
42 /* fprintf macros for signed integers */
43 #define PRId8 "hhd" /* int8_t */
44 #define PRId16 "hd" /* int16_t */
45 #define PRId32 "d" /* int32_t */
46 #ifdef _LP64
47 #define PRId64 "ld" /* int64_t */
48 #else
49 #define PRId64 "lld" /* int64_t */
50 #endif
51 #define PRIdLEAST8 "hhd" /* int_least8_t */
52 #define PRIdLEAST16 "hd" /* int_least16_t */
53 #define PRIdLEAST32 "d" /* int_least32_t */
54 #ifdef _LP64
55 #define PRIdLEAST64 "ld" /* int_least64_t */
56 #else
57 #define PRIdLEAST64 "lld" /* int_least64_t */
58 #endif
59 #define PRIdFAST8 "hhd" /* int_fast8_t */
60 #define PRIdFAST16 "hd" /* int_fast16_t */
61 #define PRIdFAST32 "d" /* int_fast32_t */
62 #ifdef _LP64
63 #define PRIdFAST64 "ld" /* int_fast64_t */
64 #define PRIdMAX "ld" /* intmax_t */
65 #else
66 #define PRIdFAST64 "lld" /* int_fast64_t */
67 #define PRIdMAX "lld" /* intmax_t */
68 #endif
69 #define PRIdPTR "ld" /* intptr_t */
70
71 #define PRIi8 "hhi" /* int8_t */
72 #define PRIi16 "hi" /* int16_t */
73 #define PRIi32 "i" /* int32_t */
74 #ifdef _LP64
75 #define PRIi64 "li" /* int64_t */
76 #else
77 #define PRIi64 "lli" /* int64_t */
78 #endif
79 #define PRIiLEAST8 "hhi" /* int_least8_t */
80 #define PRIiLEAST16 "hi" /* int_least16_t */
81 #define PRIiLEAST32 "i" /* int_least32_t */
82 #ifdef _LP64
83 #define PRIiLEAST64 "li" /* int_least64_t */
84 #else
85 #define PRIiLEAST64 "lli" /* int_least64_t */
86 #endif
87 #define PRIiFAST8 "hhi" /* int_fast8_t */
88 #define PRIiFAST16 "hi" /* int_fast16_t */
89 #define PRIiFAST32 "i" /* int_fast32_t */
90 #ifdef _LP64
91 #define PRIiFAST64 "li" /* int_fast64_t */
92 #define PRIiMAX "li" /* intmax_t */
93 #else
94 #define PRIiFAST64 "lli" /* int_fast64_t */
95 #define PRIiMAX "lli" /* intmax_t */
96 #endif
97 #define PRIiPTR "li" /* intptr_t */
98
99 /* fprintf macros for unsigned integers */
100
101 #define PRIo8 "hho" /* uint8_t */
102 #define PRIo16 "ho" /* uint16_t */
103 #define PRIo32 "o" /* uint32_t */
104 #define PRIo64 "llo" /* uint64_t */
105 #define PRIoLEAST8 "o" /* uint_least8_t */
106 #define PRIoLEAST16 "hho" /* uint_least16_t */
107 #define PRIoLEAST32 "ho" /* uint_least32_t */
108 #ifdef _LP64
109 #define PRIoLEAST64 "lo" /* uint_least64_t */
110 #else
111 #define PRIoLEAST64 "llo" /* uint_least64_t */
112 #endif
113 #define PRIoFAST8 "hho" /* uint_fast8_t */
114 #define PRIoFAST16 "ho" /* uint_fast16_t */
115 #define PRIoFAST32 "o" /* uint_fast32_t */
116 #ifdef _LP64
117 #define PRIoFAST64 "lo" /* uint_fast64_t */
118 #define PRIoMAX "lo" /* uintmax_t */
119 #else
120 #define PRIoFAST64 "llo" /* uint_fast64_t */
121 #define PRIoMAX "llo" /* uintmax_t */
122 #endif
123 #define PRIoPTR "lo" /* uintptr_t */
124
125 #define PRIu8 "hhu" /* uint8_t */
126 #define PRIu16 "hu" /* uint16_t */
127 #define PRIu32 "u" /* uint32_t */
128 #ifdef _LP64
129 #define PRIu64 "lu" /* uint64_t */
130 #else
131 #define PRIu64 "llu" /* uint64_t */
132 #endif
133 #define PRIuLEAST8 "hhu" /* uint_least8_t */
134 #define PRIuLEAST16 "hu" /* uint_least16_t */
135 #define PRIuLEAST32 "u" /* uint_least32_t */
136 #ifdef _LP64
137 #define PRIuLEAST64 "lu" /* uint_least64_t */
138 #else
139 #define PRIuLEAST64 "llu" /* uint_least64_t */
140 #endif
141 #define PRIuFAST8 "hhu" /* uint_fast8_t */
142 #define PRIuFAST16 "hu" /* uint_fast16_t */
143 #define PRIuFAST32 "u" /* uint_fast32_t */
144 #ifdef _LP64
145 #define PRIuFAST64 "lu" /* uint_fast64_t */
146 #define PRIuMAX "lu" /* uintmax_t */
147 #else
148 #define PRIuFAST64 "llu" /* uint_fast64_t */
149 #define PRIuMAX "llu" /* uintmax_t */
150 #endif
151 #define PRIuPTR "lu" /* uintptr_t */
152
153 #define PRIx8 "hhx" /* uint8_t */
154 #define PRIx16 "hx" /* uint16_t */
155 #define PRIx32 "x" /* uint32_t */
156 #ifdef _LP64
157 #define PRIx64 "lx" /* uint64_t */
158 #else
159 #define PRIx64 "llx" /* uint64_t */
160 #endif
161 #define PRIxLEAST8 "x" /* uint_least8_t */
162 #define PRIxLEAST16 "x" /* uint_least16_t */
163 #define PRIxLEAST32 "x" /* uint_least32_t */
164 #ifdef _LP64
165 #define PRIxLEAST64 "lx" /* uint_least64_t */
166 #else
167 #define PRIxLEAST64 "llx" /* uint_least64_t */
168 #endif
169 #define PRIxFAST8 "x" /* uint_fast8_t */
170 #define PRIxFAST16 "x" /* uint_fast16_t */
171 #define PRIxFAST32 "x" /* uint_fast32_t */
172 #ifdef _LP64
173 #define PRIxFAST64 "lx" /* uint_fast64_t */
174 #define PRIxMAX "lx" /* uintmax_t */
175 #else
176 #define PRIxFAST64 "llx" /* uint_fast64_t */
177 #define PRIxMAX "llx" /* uintmax_t */
178 #endif
179 #define PRIxPTR "lx" /* uintptr_t */
180
181 #define PRIX8 "hhX" /* uint8_t */
182 #define PRIX16 "hX" /* uint16_t */
183 #define PRIX32 "X" /* uint32_t */
184 #ifdef _LP64
185 #define PRIX64 "lX" /* uint64_t */
186 #else
187 #define PRIX64 "llX" /* uint64_t */
188 #endif
189 #define PRIXLEAST8 "X" /* uint_least8_t */
190 #define PRIXLEAST16 "X" /* uint_least16_t */
191 #define PRIXLEAST32 "X" /* uint_least32_t */
192 #ifdef _LP64
193 #define PRIXLEAST64 "lX" /* uint_least64_t */
194 #else
195 #define PRIXLEAST64 "llX" /* uint_least64_t */
196 #endif
197 #define PRIXFAST8 "X" /* uint_fast8_t */
198 #define PRIXFAST16 "X" /* uint_fast16_t */
199 #define PRIXFAST32 "X" /* uint_fast32_t */
200 #ifdef _LP64
201 #define PRIXFAST64 "lX" /* uint_fast64_t */
202 #define PRIXMAX "lX" /* uintmax_t */
203 #else
204 #define PRIXFAST64 "llX" /* uint_fast64_t */
205 #define PRIXMAX "llX" /* uintmax_t */
206 #endif
207 #define PRIXPTR "lX" /* uintptr_t */
208
209 /* fscanf macros for signed integers */
210
211 #define SCNd8 "hhd" /* int8_t */
212 #define SCNd16 "hd" /* int16_t */
213 #define SCNd32 "d" /* int32_t */
214 #ifdef _LP64
215 #define SCNd64 "ld" /* int64_t */
216 #else
217 #define SCNd64 "lld" /* int64_t */
218 #endif
219 #define SCNdLEAST8 "hhd" /* int_least8_t */
220 #define SCNdLEAST16 "hd" /* int_least16_t */
221 #define SCNdLEAST32 "d" /* int_least32_t */
222 #ifdef _LP64
223 #define SCNdLEAST64 "ld" /* int_least64_t */
224 #else
225 #define SCNdLEAST64 "lld" /* int_least64_t */
226 #endif
227 #define SCNdFAST8 "hhd" /* int_fast8_t */
228 #define SCNdFAST16 "hd" /* int_fast16_t */
229 #define SCNdFAST32 "d" /* int_fast32_t */
230 #ifdef _LP64
231 #define SCNdFAST64 "ld" /* int_fast64_t */
232 #define SCNdMAX "ld" /* intmax_t */
233 #else
234 #define SCNdFAST64 "lld" /* int_fast64_t */
235 #define SCNdMAX "lld" /* intmax_t */
236 #endif
237 #define SCNdPTR "ld" /* intptr_t */
238
239 #define SCNi8 "hhi" /* int8_t */
240 #define SCNi16 "hi" /* int16_t */
241 #define SCNi32 "i" /* int32_t */
242 #ifdef _LP64
243 #define SCNi64 "li" /* int64_t */
244 #else
245 #define SCNi64 "lli" /* int64_t */
246 #endif
247 #define SCNiLEAST8 "hhi" /* int_least8_t */
248 #define SCNiLEAST16 "hi" /* int_least16_t */
249 #define SCNiLEAST32 "i" /* int_least32_t */
250 #ifdef _LP64
251 #define SCNiLEAST64 "li" /* int_least64_t */
252 #else
253 #define SCNiLEAST64 "lli" /* int_least64_t */
254 #endif
255 #define SCNiFAST8 "hhi" /* int_fast8_t */
256 #define SCNiFAST16 "hi" /* int_fast16_t */
257 #define SCNiFAST32 "i" /* int_fast32_t */
258 #ifdef _LP64
259 #define SCNiFAST64 "li" /* int_fast64_t */
260 #define SCNiMAX "li" /* intmax_t */
261 #else
262 #define SCNiFAST64 "lli" /* int_fast64_t */
263 #define SCNiMAX "lli" /* intmax_t */
264 #endif
265 #define SCNiPTR "li" /* intptr_t */
266
267 /* fscanf macros for unsigned integers */
268
269 #define SCNo8 "hho" /* uint8_t */
270 #define SCNo16 "ho" /* uint16_t */
271 #define SCNo32 "o" /* uint32_t */
272 #ifdef _LP64
273 #define SCNo64 "lo" /* uint64_t */
274 #else
275 #define SCNo64 "llo" /* uint64_t */
276 #endif
277 #define SCNoLEAST8 "hho" /* uint_least8_t */
278 #define SCNoLEAST16 "ho" /* uint_least16_t */
279 #define SCNoLEAST32 "o" /* uint_least32_t */
280 #ifdef _LP64
281 #define SCNoLEAST64 "lo" /* uint_least64_t */
282 #else
283 #define SCNoLEAST64 "llo" /* uint_least64_t */
284 #endif
285 #define SCNoFAST8 "hho" /* uint_fast8_t */
286 #define SCNoFAST16 "ho" /* uint_fast16_t */
287 #define SCNoFAST32 "o" /* uint_fast32_t */
288 #ifdef _LP64
289 #define SCNoFAST64 "lo" /* uint_fast64_t */
290 #define SCNoMAX "lo" /* uintmax_t */
291 #else
292 #define SCNoFAST64 "llo" /* uint_fast64_t */
293 #define SCNoMAX "llo" /* uintmax_t */
294 #endif
295 #define SCNoPTR "lo" /* uintptr_t */
296
297 #define SCNu8 "hhu" /* uint8_t */
298 #define SCNu16 "hu" /* uint16_t */
299 #define SCNu32 "u" /* uint32_t */
300 #ifdef _LP64
301 #define SCNu64 "lu" /* uint64_t */
302 #else
303 #define SCNu64 "llu" /* uint64_t */
304 #endif
305 #define SCNuLEAST8 "hhu" /* uint_least8_t */
306 #define SCNuLEAST16 "hu" /* uint_least16_t */
307 #define SCNuLEAST32 "u" /* uint_least32_t */
308 #ifdef _LP64
309 #define SCNuLEAST64 "lu" /* uint_least64_t */
310 #else
311 #define SCNuLEAST64 "llu" /* uint_least64_t */
312 #endif
313 #define SCNuFAST8 "hhu" /* uint_fast8_t */
314 #define SCNuFAST16 "hu" /* uint_fast16_t */
315 #define SCNuFAST32 "u" /* uint_fast32_t */
316 #ifdef _LP64
317 #define SCNuFAST64 "lu" /* uint_fast64_t */
318 #define SCNuMAX "lu" /* uintmax_t */
319 #else
320 #define SCNuFAST64 "llu" /* uint_fast64_t */
321 #define SCNuMAX "llu" /* uintmax_t */
322 #endif
323 #define SCNuPTR "lu" /* uintptr_t */
324
325 #define SCNx8 "hhx" /* uint8_t */
326 #define SCNx16 "hx" /* uint16_t */
327 #define SCNx32 "x" /* uint32_t */
328 #ifdef _LP64
329 #define SCNx64 "lx" /* uint64_t */
330 #else
331 #define SCNx64 "llx" /* uint64_t */
332 #endif
333 #define SCNxLEAST8 "hhx" /* uint_least8_t */
334 #define SCNxLEAST16 "hx" /* uint_least16_t */
335 #define SCNxLEAST32 "x" /* uint_least32_t */
336 #ifdef _LP64
337 #define SCNxLEAST64 "lx" /* uint_least64_t */
338 #else
339 #define SCNxLEAST64 "llx" /* uint_least64_t */
340 #endif
341 #define SCNxFAST8 "hhx" /* uint_fast8_t */
342 #define SCNxFAST16 "hx" /* uint_fast16_t */
343 #define SCNxFAST32 "x" /* uint_fast32_t */
344 #ifdef _LP64
345 #define SCNxFAST64 "lx" /* uint_fast64_t */
346 #define SCNxMAX "lx" /* uintmax_t */
347 #else
348 #define SCNxFAST64 "llx" /* uint_fast64_t */
349 #define SCNxMAX "llx" /* uintmax_t */
350 #endif
351 #define SCNxPTR "lx" /* uintptr_t */
352
353 #endif /* !__INTPTR_FMTd__ */
354
355 #endif /* !_RISCV_INT_FMTIO_H_ */
356