master
1/* $NetBSD: int_fmtio.h,v 1.7 2014/08/21 15:27:37 martin 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 _SPARC_INT_FMTIO_H_
33#define _SPARC_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
44#define PRId8 "d" /* int8_t */
45#define PRId16 "d" /* int16_t */
46#define PRId32 "d" /* int32_t */
47#ifdef __arch64__
48#define PRId64 "ld" /* int64_t */
49#else
50#define PRId64 "lld" /* int64_t */
51#endif
52#define PRIdLEAST8 "d" /* int_least8_t */
53#define PRIdLEAST16 "d" /* int_least16_t */
54#define PRIdLEAST32 "d" /* int_least32_t */
55#ifdef __arch64__
56#define PRIdLEAST64 "ld" /* int_least64_t */
57#else
58#define PRIdLEAST64 "lld" /* int_least64_t */
59#endif
60#ifdef __arch64__
61#define PRIdFAST8 "ld" /* int_fast8_t */
62#define PRIdFAST16 "ld" /* int_fast16_t */
63#define PRIdFAST32 "ld" /* int_fast32_t */
64#define PRIdFAST64 "ld" /* int_fast64_t */
65#else
66#define PRIdFAST8 "d" /* int_fast8_t */
67#define PRIdFAST16 "d" /* int_fast16_t */
68#define PRIdFAST32 "d" /* int_fast32_t */
69#define PRIdFAST64 "lld" /* int_fast64_t */
70#endif
71#ifdef __arch64__
72#define PRIdMAX "ld" /* intmax_t */
73#else
74#define PRIdMAX "lld" /* intmax_t */
75#endif
76#define PRIdPTR "ld" /* intptr_t */
77
78#define PRIi8 "i" /* int8_t */
79#define PRIi16 "i" /* int16_t */
80#define PRIi32 "i" /* int32_t */
81#ifdef __arch64__
82#define PRIi64 "li" /* int64_t */
83#else
84#define PRIi64 "lli" /* int64_t */
85#endif
86#define PRIiLEAST8 "i" /* int_least8_t */
87#define PRIiLEAST16 "i" /* int_least16_t */
88#define PRIiLEAST32 "i" /* int_least32_t */
89#ifdef __arch64__
90#define PRIiLEAST64 "li" /* int_least64_t */
91#else
92#define PRIiLEAST64 "lli" /* int_least64_t */
93#endif
94#ifdef __arch64__
95#define PRIiFAST8 "li" /* int_fast8_t */
96#define PRIiFAST16 "li" /* int_fast16_t */
97#define PRIiFAST32 "li" /* int_fast32_t */
98#define PRIiFAST64 "li" /* int_fast64_t */
99#else
100#define PRIiFAST8 "i" /* int_fast8_t */
101#define PRIiFAST16 "i" /* int_fast16_t */
102#define PRIiFAST32 "i" /* int_fast32_t */
103#define PRIiFAST64 "lli" /* int_fast64_t */
104#endif
105#ifdef __arch64__
106#define PRIiMAX "li" /* intmax_t */
107#else
108#define PRIiMAX "lli" /* intmax_t */
109#endif
110#define PRIiPTR "li" /* intptr_t */
111
112/* fprintf macros for unsigned integers */
113
114#define PRIo8 "o" /* uint8_t */
115#define PRIo16 "o" /* uint16_t */
116#define PRIo32 "o" /* uint32_t */
117#ifdef __arch64__
118#define PRIo64 "lo" /* uint64_t */
119#else
120#define PRIo64 "llo" /* uint64_t */
121#endif
122#define PRIoLEAST8 "o" /* uint_least8_t */
123#define PRIoLEAST16 "o" /* uint_least16_t */
124#define PRIoLEAST32 "o" /* uint_least32_t */
125#ifdef __arch64__
126#define PRIoLEAST64 "lo" /* uint_least64_t */
127#else
128#define PRIoLEAST64 "llo" /* uint_least64_t */
129#endif
130#define PRIoFAST8 "o" /* uint_fast8_t */
131#define PRIoFAST16 "o" /* uint_fast16_t */
132#define PRIoFAST32 "o" /* uint_fast32_t */
133#ifdef __arch64__
134#define PRIoFAST64 "lo" /* uint_fast64_t */
135#else
136#define PRIoFAST64 "llo" /* uint_fast64_t */
137#endif
138#ifdef __arch64__
139#define PRIoMAX "lo" /* uintmax_t */
140#else
141#define PRIoMAX "llo" /* uintmax_t */
142#endif
143#define PRIoPTR "lo" /* uintptr_t */
144
145#define PRIu8 "u" /* uint8_t */
146#define PRIu16 "u" /* uint16_t */
147#define PRIu32 "u" /* uint32_t */
148#ifdef __arch64__
149#define PRIu64 "lu" /* uint64_t */
150#else
151#define PRIu64 "llu" /* uint64_t */
152#endif
153#define PRIuLEAST8 "u" /* uint_least8_t */
154#define PRIuLEAST16 "u" /* uint_least16_t */
155#define PRIuLEAST32 "u" /* uint_least32_t */
156#ifdef __arch64__
157#define PRIuLEAST64 "lu" /* uint_least64_t */
158#else
159#define PRIuLEAST64 "llu" /* uint_least64_t */
160#endif
161#define PRIuFAST8 "u" /* uint_fast8_t */
162#define PRIuFAST16 "u" /* uint_fast16_t */
163#define PRIuFAST32 "u" /* uint_fast32_t */
164#ifdef __arch64__
165#define PRIuFAST64 "lu" /* uint_fast64_t */
166#else
167#define PRIuFAST64 "llu" /* uint_fast64_t */
168#endif
169#ifdef __arch64__
170#define PRIuMAX "lu" /* uintmax_t */
171#else
172#define PRIuMAX "llu" /* uintmax_t */
173#endif
174#define PRIuPTR "lu" /* uintptr_t */
175
176#define PRIx8 "x" /* uint8_t */
177#define PRIx16 "x" /* uint16_t */
178#define PRIx32 "x" /* uint32_t */
179#ifdef __arch64__
180#define PRIx64 "lx" /* uint64_t */
181#else
182#define PRIx64 "llx" /* uint64_t */
183#endif
184#define PRIxLEAST8 "x" /* uint_least8_t */
185#define PRIxLEAST16 "x" /* uint_least16_t */
186#define PRIxLEAST32 "x" /* uint_least32_t */
187#ifdef __arch64__
188#define PRIxLEAST64 "lx" /* uint_least64_t */
189#else
190#define PRIxLEAST64 "llx" /* uint_least64_t */
191#endif
192#define PRIxFAST8 "x" /* uint_fast8_t */
193#define PRIxFAST16 "x" /* uint_fast16_t */
194#define PRIxFAST32 "x" /* uint_fast32_t */
195#ifdef __arch64__
196#define PRIxFAST64 "lx" /* uint_fast64_t */
197#else
198#define PRIxFAST64 "llx" /* uint_fast64_t */
199#endif
200#ifdef __arch64__
201#define PRIxMAX "lx" /* uintmax_t */
202#else
203#define PRIxMAX "llx" /* uintmax_t */
204#endif
205#define PRIxPTR "lx" /* uintptr_t */
206
207#define PRIX8 "X" /* uint8_t */
208#define PRIX16 "X" /* uint16_t */
209#define PRIX32 "X" /* uint32_t */
210#ifdef __arch64__
211#define PRIX64 "lX" /* uint64_t */
212#else
213#define PRIX64 "llX" /* uint64_t */
214#endif
215#define PRIXLEAST8 "X" /* uint_least8_t */
216#define PRIXLEAST16 "X" /* uint_least16_t */
217#define PRIXLEAST32 "X" /* uint_least32_t */
218#ifdef __arch64__
219#define PRIXLEAST64 "lX" /* uint_least64_t */
220#else
221#define PRIXLEAST64 "llX" /* uint_least64_t */
222#endif
223#define PRIXFAST8 "X" /* uint_fast8_t */
224#define PRIXFAST16 "X" /* uint_fast16_t */
225#define PRIXFAST32 "X" /* uint_fast32_t */
226#ifdef __arch64__
227#define PRIXFAST64 "lX" /* uint_fast64_t */
228#else
229#define PRIXFAST64 "llX" /* uint_fast64_t */
230#endif
231#ifdef __arch64__
232#define PRIXMAX "lX" /* uintmax_t */
233#else
234#define PRIXMAX "llX" /* uintmax_t */
235#endif
236#define PRIXPTR "lX" /* uintptr_t */
237
238/* fscanf macros for signed integers */
239
240#define SCNd8 "hhd" /* int8_t */
241#define SCNd16 "hd" /* int16_t */
242#define SCNd32 "d" /* int32_t */
243#ifdef __arch64__
244#define SCNd64 "ld" /* int64_t */
245#else
246#define SCNd64 "lld" /* int64_t */
247#endif
248#define SCNdLEAST8 "hhd" /* int_least8_t */
249#define SCNdLEAST16 "hd" /* int_least16_t */
250#define SCNdLEAST32 "d" /* int_least32_t */
251#ifdef __arch64__
252#define SCNdLEAST64 "ld" /* int_least64_t */
253#else
254#define SCNdLEAST64 "lld" /* int_least64_t */
255#endif
256#ifdef __arch64__
257#define SCNdFAST8 "ld" /* int_fast8_t */
258#define SCNdFAST16 "ld" /* int_fast16_t */
259#define SCNdFAST32 "ld" /* int_fast32_t */
260#define SCNdFAST64 "ld" /* int_fast64_t */
261#else
262#define SCNdFAST8 "d" /* int_fast8_t */
263#define SCNdFAST16 "d" /* int_fast16_t */
264#define SCNdFAST32 "d" /* int_fast32_t */
265#define SCNdFAST64 "lld" /* int_fast64_t */
266#endif
267#ifdef __arch64__
268#define SCNdMAX "ld" /* intmax_t */
269#else
270#define SCNdMAX "lld" /* intmax_t */
271#endif
272#define SCNdPTR "ld" /* intptr_t */
273
274#define SCNi8 "hhi" /* int8_t */
275#define SCNi16 "hi" /* int16_t */
276#define SCNi32 "i" /* int32_t */
277#ifdef __arch64__
278#define SCNi64 "li" /* int64_t */
279#else
280#define SCNi64 "lli" /* int64_t */
281#endif
282#define SCNiLEAST8 "hhi" /* int_least8_t */
283#define SCNiLEAST16 "hi" /* int_least16_t */
284#define SCNiLEAST32 "i" /* int_least32_t */
285#ifdef __arch64__
286#define SCNiLEAST64 "li" /* int_least64_t */
287#else
288#define SCNiLEAST64 "lli" /* int_least64_t */
289#endif
290#ifdef __arch64__
291#define SCNiFAST8 "li" /* int_fast8_t */
292#define SCNiFAST16 "li" /* int_fast16_t */
293#define SCNiFAST32 "li" /* int_fast32_t */
294#define SCNiFAST64 "li" /* int_fast64_t */
295#else
296#define SCNiFAST8 "i" /* int_fast8_t */
297#define SCNiFAST16 "i" /* int_fast16_t */
298#define SCNiFAST32 "i" /* int_fast32_t */
299#define SCNiFAST64 "lli" /* int_fast64_t */
300#endif
301#ifdef __arch64__
302#define SCNiMAX "li" /* intmax_t */
303#else
304#define SCNiMAX "lli" /* intmax_t */
305#endif
306#define SCNiPTR "li" /* intptr_t */
307
308/* fscanf macros for unsigned integers */
309
310#define SCNo8 "hho" /* uint8_t */
311#define SCNo16 "ho" /* uint16_t */
312#define SCNo32 "o" /* uint32_t */
313#ifdef __arch64__
314#define SCNo64 "lo" /* uint64_t */
315#else
316#define SCNo64 "llo" /* uint64_t */
317#endif
318#define SCNoLEAST8 "hho" /* uint_least8_t */
319#define SCNoLEAST16 "ho" /* uint_least16_t */
320#define SCNoLEAST32 "o" /* uint_least32_t */
321#ifdef __arch64__
322#define SCNoLEAST64 "lo" /* uint_least64_t */
323#else
324#define SCNoLEAST64 "llo" /* uint_least64_t */
325#endif
326#ifdef __arch64__
327#define SCNoFAST8 "hho" /* uint_fast8_t */
328#define SCNoFAST16 "ho" /* uint_fast16_t */
329#define SCNoFAST32 "o" /* uint_fast32_t */
330#define SCNoFAST64 "lo" /* uint_fast64_t */
331#else
332#define SCNoFAST8 "o" /* uint_fast8_t */
333#define SCNoFAST16 "o" /* uint_fast16_t */
334#define SCNoFAST32 "o" /* uint_fast32_t */
335#define SCNoFAST64 "llo" /* uint_fast64_t */
336#endif
337#ifdef __arch64__
338#define SCNoMAX "lo" /* uintmax_t */
339#else
340#define SCNoMAX "llo" /* uintmax_t */
341#endif
342#define SCNoPTR "lo" /* uintptr_t */
343
344#define SCNu8 "hhu" /* uint8_t */
345#define SCNu16 "hu" /* uint16_t */
346#define SCNu32 "u" /* uint32_t */
347#ifdef __arch64__
348#define SCNu64 "lu" /* uint64_t */
349#else
350#define SCNu64 "llu" /* uint64_t */
351#endif
352#define SCNuLEAST8 "hhu" /* uint_least8_t */
353#define SCNuLEAST16 "hu" /* uint_least16_t */
354#define SCNuLEAST32 "u" /* uint_least32_t */
355#ifdef __arch64__
356#define SCNuLEAST64 "lu" /* uint_least64_t */
357#else
358#define SCNuLEAST64 "llu" /* uint_least64_t */
359#endif
360#ifdef __arch64__
361#define SCNuFAST8 "hhu" /* uint_fast8_t */
362#define SCNuFAST16 "hu" /* uint_fast16_t */
363#define SCNuFAST32 "u" /* uint_fast32_t */
364#define SCNuFAST64 "lu" /* uint_fast64_t */
365#else
366#define SCNuFAST8 "u" /* uint_fast8_t */
367#define SCNuFAST16 "u" /* uint_fast16_t */
368#define SCNuFAST32 "u" /* uint_fast32_t */
369#define SCNuFAST64 "llu" /* uint_fast64_t */
370#endif
371#ifdef __arch64__
372#define SCNuMAX "lu" /* uintmax_t */
373#else
374#define SCNuMAX "llu" /* uintmax_t */
375#endif
376#define SCNuPTR "lu" /* uintptr_t */
377
378#define SCNx8 "hhx" /* uint8_t */
379#define SCNx16 "hx" /* uint16_t */
380#define SCNx32 "x" /* uint32_t */
381#ifdef __arch64__
382#define SCNx64 "lx" /* uint64_t */
383#else
384#define SCNx64 "llx" /* uint64_t */
385#endif
386#define SCNxLEAST8 "hhx" /* uint_least8_t */
387#define SCNxLEAST16 "hx" /* uint_least16_t */
388#define SCNxLEAST32 "x" /* uint_least32_t */
389#ifdef __arch64__
390#define SCNxLEAST64 "lx" /* uint_least64_t */
391#else
392#define SCNxLEAST64 "llx" /* uint_least64_t */
393#endif
394#ifdef __arch64__
395#define SCNxFAST8 "hhx" /* uint_fast8_t */
396#define SCNxFAST16 "hx" /* uint_fast16_t */
397#define SCNxFAST32 "x" /* uint_fast32_t */
398#define SCNxFAST64 "lx" /* uint_fast64_t */
399#else
400#define SCNxFAST8 "x" /* uint_fast8_t */
401#define SCNxFAST16 "x" /* uint_fast16_t */
402#define SCNxFAST32 "x" /* uint_fast32_t */
403#define SCNxFAST64 "llx" /* uint_fast64_t */
404#endif
405#ifdef __arch64__
406#define SCNxMAX "lx" /* uintmax_t */
407#else
408#define SCNxMAX "llx" /* uintmax_t */
409#endif
410#define SCNxPTR "lx" /* uintptr_t */
411
412#endif /* !__INTPTR_FMTd__ */
413
414#endif /* !_SPARC_INT_FMTIO_H_ */