4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
25 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
29 #ifndef _SYS_INT_FMTIO_H
30 #define _SYS_INT_FMTIO_H
33 * This file, <sys/int_fmtio.h>, is part of the Sun Microsystems implementation
34 * of <inttypes.h> as defined by the ISO C Standard, ISO/IEC 9899:1999
35 * Programming language - C.
37 * ISO International Organization for Standardization.
39 * Programs/Modules should not directly include this file. Access to the
40 * types defined in this file should be through the inclusion of one of the
43 * <sys/inttypes.h> Provides the Kernel and Driver appropriate
44 * components of <inttypes.h>.
46 * <inttypes.h> For use by applications.
48 * See these files for more details.
51 #include <sys/feature_tests.h>
60 * The following macros can be used even when an implementation has not
61 * extended the printf/scanf family of functions.
63 * The form of the names of the macros is either "PRI" for printf specifiers
64 * or "SCN" for scanf specifiers, followed by the conversion specifier letter
65 * followed by the datatype size. For example, PRId32 is the macro for
66 * the printf d conversion specifier with the flags for 32 bit datatype.
68 * An example using one of these macros:
71 * printf("u = %016" PRIx64 "\n", u);
73 * For the purpose of example, the definitions of the printf/scanf macros
74 * below have the values appropriate for a machine with 8 bit shorts, 16
75 * bit shorts, 32 bit ints, 32 or 64 bit longs depending on compilation
76 * mode, and 64 bit long longs.
80 * fprintf macros for signed integers
97 #define PRId8 _MODF8 _PRId
98 #define PRIdLEAST8 PRId8
99 #define PRIdFAST8 PRId8
100 #define PRId16 _MODF16 _PRId
101 #define PRIdLEAST16 PRId16
103 #define PRIdFAST16 PRId32
104 #define PRIdLEAST32 PRId32
105 #define PRIdFAST32 PRId32
109 #if defined(_LONGLONG_TYPE)
114 #define PRIdLEAST64 PRId64
115 #define PRIdFAST64 PRId64
118 #define PRIi8 _MODF8 _PRIi
119 #define PRIiLEAST8 PRIi8
120 #define PRIiFAST8 PRIi8
121 #define PRIi16 _MODF16 _PRIi
122 #define PRIiLEAST16 PRIi16
124 #define PRIiFAST16 PRIi32
125 #define PRIiLEAST32 PRIi32
126 #define PRIiFAST32 PRIi32
130 #if defined(_LONGLONG_TYPE)
135 #define PRIiLEAST64 PRIi64
136 #define PRIiFAST64 PRIi64
140 * fprintf macros for unsigned integers
143 #define PRIo8 _MODF8 _PRIo
144 #define PRIoLEAST8 PRIo8
145 #define PRIoFAST8 PRIo8
146 #define PRIo16 _MODF16 _PRIo
147 #define PRIoLEAST16 PRIo16
149 #define PRIoFAST16 PRIo32
150 #define PRIoLEAST32 PRIo32
151 #define PRIoFAST32 PRIo32
155 #if defined(_LONGLONG_TYPE)
160 #define PRIoLEAST64 PRIo64
161 #define PRIoFAST64 PRIo64
164 #define PRIu8 _MODF8 _PRIu
165 #define PRIuLEAST8 PRIu8
166 #define PRIuFAST8 PRIu8
167 #define PRIu16 _MODF16 _PRIu
168 #define PRIuLEAST16 PRIu16
170 #define PRIuFAST16 PRIu32
171 #define PRIuLEAST32 PRIu32
172 #define PRIuFAST32 PRIu32
176 #if defined(_LONGLONG_TYPE)
181 #define PRIuLEAST64 PRIu64
182 #define PRIuFAST64 PRIu64
185 #define PRIx8 _MODF8 _PRIx
186 #define PRIxLEAST8 PRIx8
187 #define PRIxFAST8 PRIx8
188 #define PRIx16 _MODF16 _PRIx
189 #define PRIxLEAST16 PRIx16
191 #define PRIxFAST16 PRIx32
192 #define PRIxLEAST32 PRIx32
193 #define PRIxFAST32 PRIx32
197 #if defined(_LONGLONG_TYPE)
202 #define PRIxLEAST64 PRIx64
203 #define PRIxFAST64 PRIx64
206 #define PRIX8 _MODF8 _PRIX
207 #define PRIXLEAST8 PRIX8
208 #define PRIXFAST8 PRIX8
209 #define PRIX16 _MODF16 _PRIX
210 #define PRIXLEAST16 PRIX16
212 #define PRIXFAST16 PRIX32
213 #define PRIXLEAST32 PRIX32
214 #define PRIXFAST32 PRIX32
218 #if defined(_LONGLONG_TYPE)
223 #define PRIXLEAST64 PRIX64
224 #define PRIXFAST64 PRIX64
228 * fprintf macros for pointers
231 #if defined(_LP64) || defined(_I32LPx)
245 #endif /* defined(_LP64) || defined(_I32LPx) */
248 * fscanf macros for signed integers
251 #define SCNdLEAST8 SCNd8
252 #define SCNdFAST8 SCNd8
254 #define SCNdLEAST16 SCNd16
256 #define SCNdFAST16 SCNd32
257 #define SCNdLEAST32 SCNd32
258 #define SCNdFAST32 SCNd32
260 #define SCNd64 PRId64
261 #define SCNdLEAST64 PRId64
262 #define SCNdFAST64 PRId64
264 #define SCNdPTR PRIdPTR
267 #define SCNiLEAST8 SCNi8
268 #define SCNiFAST8 SCNi8
270 #define SCNiLEAST16 SCNi16
272 #define SCNiFAST16 SCNi32
273 #define SCNiLEAST32 SCNi32
274 #define SCNiFAST32 SCNi32
276 #define SCNi64 PRIi64
277 #define SCNiLEAST64 PRIi64
278 #define SCNiFAST64 PRIi64
280 #define SCNiPTR PRIiPTR
283 * fscanf macros for unsigned integers
286 #define SCNoLEAST8 SCNo8
287 #define SCNoFAST8 SCNo8
289 #define SCNoLEAST16 SCNo16
291 #define SCNoFAST16 SCNo32
292 #define SCNoLEAST32 SCNo32
293 #define SCNoFAST32 SCNo32
295 #define SCNo64 PRIo64
296 #define SCNoLEAST64 PRIo64
297 #define SCNoFAST64 PRIo64
299 #define SCNoPTR PRIoPTR
302 #define SCNuLEAST8 SCNu8
303 #define SCNuFAST8 SCNu8
305 #define SCNuLEAST16 SCNu16
307 #define SCNuFAST16 SCNu32
308 #define SCNuLEAST32 SCNu32
309 #define SCNuFAST32 SCNu32
311 #define SCNu64 PRIu64
312 #define SCNuLEAST64 PRIu64
313 #define SCNuFAST64 PRIu64
315 #define SCNuPTR PRIuPTR
318 #define SCNxLEAST8 SCNx8
319 #define SCNxFAST8 SCNx8
321 #define SCNxLEAST16 SCNx16
323 #define SCNxFAST16 SCNx32
324 #define SCNxLEAST32 SCNx32
325 #define SCNxFAST32 SCNx32
327 #define SCNx64 PRIx64
328 #define SCNxLEAST64 PRIx64
329 #define SCNxFAST64 PRIx64
331 #define SCNxPTR PRIxPTR
334 #define SCNXLEAST8 SCNX8
335 #define SCNXFAST8 SCNX8
337 #define SCNXLEAST16 SCNX16
339 #define SCNXFAST16 SCNX32
340 #define SCNXLEAST32 SCNX32
341 #define SCNXFAST32 SCNX32
343 #define SCNX64 PRIX64
344 #define SCNXLEAST64 PRIX64
345 #define SCNXFAST64 PRIX64
347 #define SCNXPTR PRIXPTR
350 * The following macros define I/O formats for intmax_t and uintmax_t.
352 #if !defined(_LP64) && defined(_LONGLONG_TYPE)
353 #define PRIdMAX "lld"
354 #define PRIiMAX "lli"
355 #define PRIoMAX "llo"
356 #define PRIxMAX "llx"
357 #define PRIuMAX "llu"
358 #define PRIXMAX "llX"
366 #endif /* !defined(_LP64) && defined(_LONGLONG_TYPE) */
368 #define SCNdMAX PRIdMAX
369 #define SCNiMAX PRIiMAX
370 #define SCNoMAX PRIoMAX
371 #define SCNxMAX PRIxMAX
372 #define SCNuMAX PRIuMAX
373 #define SCNXMAX PRIXMAX
379 #endif /* _SYS_INT_FMTIO_H */