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