1/* $NetBSD: common_int_fmtio.h,v 1.1 2014/07/25 21:43:13 joerg Exp $ */
2
3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Joerg Sonnenberger.
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 _SYS_COMMON_INT_FMTIO_H_
33#define _SYS_COMMON_INT_FMTIO_H_
34
35#ifndef __INTPTR_FMTd__
36#error Your compiler does not provide format string macros.
37#endif
38
39/*
40 * 7.8.1 Macros for format specifiers
41 */
42
43/* fprintf macros for signed integers */
44#define PRId8 __INT8_FMTd__
45#define PRId16 __INT16_FMTd__
46#define PRId32 __INT32_FMTd__
47#define PRId64 __INT64_FMTd__
48#define PRIdLEAST8 __INT_LEAST8_FMTd__
49#define PRIdLEAST16 __INT_LEAST16_FMTd__
50#define PRIdLEAST32 __INT_LEAST32_FMTd__
51#define PRIdLEAST64 __INT_LEAST64_FMTd__
52#define PRIdFAST8 __INT_FAST8_FMTd__
53#define PRIdFAST16 __INT_FAST16_FMTd__
54#define PRIdFAST32 __INT_FAST32_FMTd__
55#define PRIdFAST64 __INT_FAST64_FMTd__
56#define PRIdMAX __INTMAX_FMTd__
57#define PRIdPTR __INTPTR_FMTd__
58
59#define PRIi8 __INT8_FMTi__
60#define PRIi16 __INT16_FMTi__
61#define PRIi32 __INT32_FMTi__
62#define PRIi64 __INT64_FMTi__
63#define PRIiLEAST8 __INT_LEAST8_FMTi__
64#define PRIiLEAST16 __INT_LEAST16_FMTi__
65#define PRIiLEAST32 __INT_LEAST32_FMTi__
66#define PRIiLEAST64 __INT_LEAST64_FMTi__
67#define PRIiFAST8 __INT_FAST8_FMTi__
68#define PRIiFAST16 __INT_FAST16_FMTi__
69#define PRIiFAST32 __INT_FAST32_FMTi__
70#define PRIiFAST64 __INT_FAST64_FMTi__
71#define PRIiMAX __INTMAX_FMTi__
72#define PRIiPTR __INTPTR_FMTi__
73
74/* fprintf macros for unsigned integers */
75
76#define PRIo8 __UINT8_FMTo__
77#define PRIo16 __UINT16_FMTo__
78#define PRIo32 __UINT32_FMTo__
79#define PRIo64 __UINT64_FMTo__
80#define PRIoLEAST8 __UINT_LEAST8_FMTo__
81#define PRIoLEAST16 __UINT_LEAST16_FMTo__
82#define PRIoLEAST32 __UINT_LEAST32_FMTo__
83#define PRIoLEAST64 __UINT_LEAST64_FMTo__
84#define PRIoFAST8 __UINT_FAST8_FMTo__
85#define PRIoFAST16 __UINT_FAST16_FMTo__
86#define PRIoFAST32 __UINT_FAST32_FMTo__
87#define PRIoFAST64 __UINT_FAST64_FMTo__
88#define PRIoMAX __UINTMAX_FMTo__
89#define PRIoPTR __UINTPTR_FMTo__
90
91#define PRIu8 __UINT8_FMTu__
92#define PRIu16 __UINT16_FMTu__
93#define PRIu32 __UINT32_FMTu__
94#define PRIu64 __UINT64_FMTu__
95#define PRIuLEAST8 __UINT_LEAST8_FMTu__
96#define PRIuLEAST16 __UINT_LEAST16_FMTu__
97#define PRIuLEAST32 __UINT_LEAST32_FMTu__
98#define PRIuLEAST64 __UINT_LEAST64_FMTu__
99#define PRIuFAST8 __UINT_FAST8_FMTu__
100#define PRIuFAST16 __UINT_FAST16_FMTu__
101#define PRIuFAST32 __UINT_FAST32_FMTu__
102#define PRIuFAST64 __UINT_FAST64_FMTu__
103#define PRIuMAX __UINTMAX_FMTu__
104#define PRIuPTR __UINTPTR_FMTu__
105
106#define PRIx8 __UINT8_FMTx__
107#define PRIx16 __UINT16_FMTx__
108#define PRIx32 __UINT32_FMTx__
109#define PRIx64 __UINT64_FMTx__
110#define PRIxLEAST8 __UINT_LEAST8_FMTx__
111#define PRIxLEAST16 __UINT_LEAST16_FMTx__
112#define PRIxLEAST32 __UINT_LEAST32_FMTx__
113#define PRIxLEAST64 __UINT_LEAST64_FMTx__
114#define PRIxFAST8 __UINT_FAST8_FMTx__
115#define PRIxFAST16 __UINT_FAST16_FMTx__
116#define PRIxFAST32 __UINT_FAST32_FMTx__
117#define PRIxFAST64 __UINT_FAST64_FMTx__
118#define PRIxMAX __UINTMAX_FMTx__
119#define PRIxPTR __UINTPTR_FMTx__
120
121#define PRIX8 __UINT8_FMTX__
122#define PRIX16 __UINT16_FMTX__
123#define PRIX32 __UINT32_FMTX__
124#define PRIX64 __UINT64_FMTX__
125#define PRIXLEAST8 __UINT_LEAST8_FMTX__
126#define PRIXLEAST16 __UINT_LEAST16_FMTX__
127#define PRIXLEAST32 __UINT_LEAST32_FMTX__
128#define PRIXLEAST64 __UINT_LEAST64_FMTX__
129#define PRIXFAST8 __UINT_FAST8_FMTX__
130#define PRIXFAST16 __UINT_FAST16_FMTX__
131#define PRIXFAST32 __UINT_FAST32_FMTX__
132#define PRIXFAST64 __UINT_FAST64_FMTX__
133#define PRIXMAX __UINTMAX_FMTX__
134#define PRIXPTR __UINTPTR_FMTX__
135
136/* fscanf macros for signed integers */
137
138#define SCNd8 __INT8_FMTd__
139#define SCNd16 __INT16_FMTd__
140#define SCNd32 __INT32_FMTd__
141#define SCNd64 __INT64_FMTd__
142#define SCNdLEAST8 __INT_LEAST8_FMTd__
143#define SCNdLEAST16 __INT_LEAST16_FMTd__
144#define SCNdLEAST32 __INT_LEAST32_FMTd__
145#define SCNdLEAST64 __INT_LEAST64_FMTd__
146#define SCNdFAST8 __INT_FAST8_FMTd__
147#define SCNdFAST16 __INT_FAST16_FMTd__
148#define SCNdFAST32 __INT_FAST32_FMTd__
149#define SCNdFAST64 __INT_FAST64_FMTd__
150#define SCNdMAX __INTMAX_FMTd__
151#define SCNdPTR __INTPTR_FMTd__
152
153#define SCNi8 __INT8_FMTi__
154#define SCNi16 __INT16_FMTi__
155#define SCNi32 __INT32_FMTi__
156#define SCNi64 __INT64_FMTi__
157#define SCNiLEAST8 __INT_LEAST8_FMTi__
158#define SCNiLEAST16 __INT_LEAST16_FMTi__
159#define SCNiLEAST32 __INT_LEAST32_FMTi__
160#define SCNiLEAST64 __INT_LEAST64_FMTi__
161#define SCNiFAST8 __INT_FAST8_FMTi__
162#define SCNiFAST16 __INT_FAST16_FMTi__
163#define SCNiFAST32 __INT_FAST32_FMTi__
164#define SCNiFAST64 __INT_FAST64_FMTi__
165#define SCNiMAX __INTMAX_FMTi__
166#define SCNiPTR __INTPTR_FMTi__
167
168/* fscanf macros for unsigned integers */
169
170#define SCNo8 __UINT8_FMTo__
171#define SCNo16 __UINT16_FMTo__
172#define SCNo32 __UINT32_FMTo__
173#define SCNo64 __UINT64_FMTo__
174#define SCNoLEAST8 __UINT_LEAST8_FMTo__
175#define SCNoLEAST16 __UINT_LEAST16_FMTo__
176#define SCNoLEAST32 __UINT_LEAST32_FMTo__
177#define SCNoLEAST64 __UINT_LEAST64_FMTo__
178#define SCNoFAST8 __UINT_FAST8_FMTo__
179#define SCNoFAST16 __UINT_FAST16_FMTo__
180#define SCNoFAST32 __UINT_FAST32_FMTo__
181#define SCNoFAST64 __UINT_FAST64_FMTo__
182#define SCNoMAX __UINTMAX_FMTo__
183#define SCNoPTR __UINTPTR_FMTo__
184
185#define SCNu8 __UINT8_FMTu__
186#define SCNu16 __UINT16_FMTu__
187#define SCNu32 __UINT32_FMTu__
188#define SCNu64 __UINT64_FMTu__
189#define SCNuLEAST8 __UINT_LEAST8_FMTu__
190#define SCNuLEAST16 __UINT_LEAST16_FMTu__
191#define SCNuLEAST32 __UINT_LEAST32_FMTu__
192#define SCNuLEAST64 __UINT_LEAST64_FMTu__
193#define SCNuFAST8 __UINT_FAST8_FMTu__
194#define SCNuFAST16 __UINT_FAST16_FMTu__
195#define SCNuFAST32 __UINT_FAST32_FMTu__
196#define SCNuFAST64 __UINT_FAST64_FMTu__
197#define SCNuMAX __UINTMAX_FMTu__
198#define SCNuPTR __UINTPTR_FMTu__
199
200#define SCNx8 __UINT8_FMTx__
201#define SCNx16 __UINT16_FMTx__
202#define SCNx32 __UINT32_FMTx__
203#define SCNx64 __UINT64_FMTx__
204#define SCNxLEAST8 __UINT_LEAST8_FMTx__
205#define SCNxLEAST16 __UINT_LEAST16_FMTx__
206#define SCNxLEAST32 __UINT_LEAST32_FMTx__
207#define SCNxLEAST64 __UINT_LEAST64_FMTx__
208#define SCNxFAST8 __UINT_FAST8_FMTx__
209#define SCNxFAST16 __UINT_FAST16_FMTx__
210#define SCNxFAST32 __UINT_FAST32_FMTx__
211#define SCNxFAST64 __UINT_FAST64_FMTx__
212#define SCNxMAX __UINTMAX_FMTx__
213#define SCNxPTR __UINTPTR_FMTx__
214
215#define SCNX8 __UINT8_FMTX__
216#define SCNX16 __UINT16_FMTX__
217#define SCNX32 __UINT32_FMTX__
218#define SCNX64 __UINT64_FMTX__
219#define SCNXLEAST8 __UINT_LEAST8_FMTX__
220#define SCNXLEAST16 __UINT_LEAST16_FMTX__
221#define SCNXLEAST32 __UINT_LEAST32_FMTX__
222#define SCNXLEAST64 __UINT_LEAST64_FMTX__
223#define SCNXFAST8 __UINT_FAST8_FMTX__
224#define SCNXFAST16 __UINT_FAST16_FMTX__
225#define SCNXFAST32 __UINT_FAST32_FMTX__
226#define SCNXFAST64 __UINT_FAST64_FMTX__
227#define SCNXMAX __UINTMAX_FMTX__
228#define SCNXPTR __UINTPTR_FMTX__
229
230#endif /* _SYS_COMMON_INT_FMTIO_H_ */
231