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 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_INT_FMTIO_H
28 #define _SYS_INT_FMTIO_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
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 #if defined(_CHAR_IS_SIGNED) || defined(__STDC__)
98 #define PRId8 _MODF8 _PRId
99 #define PRIdLEAST8 PRId8
100 #define PRIdFAST8 PRId8
102 #define PRId16 _MODF16 _PRId
103 #define PRIdLEAST16 PRId16
105 #define PRIdFAST16 PRId32
106 #define PRIdLEAST32 PRId32
107 #define PRIdFAST32 PRId32
111 #if defined(_LONGLONG_TYPE)
116 #define PRIdLEAST64 PRId64
117 #define PRIdFAST64 PRId64
120 #if defined(_CHAR_IS_SIGNED) || defined(__STDC__)
121 #define PRIi8 _MODF8 _PRIi
122 #define PRIiLEAST8 PRIi8
123 #define PRIiFAST8 PRIi8
125 #define PRIi16 _MODF16 _PRIi
126 #define PRIiLEAST16 PRIi16
128 #define PRIiFAST16 PRIi32
129 #define PRIiLEAST32 PRIi32
130 #define PRIiFAST32 PRIi32
134 #if defined(_LONGLONG_TYPE)
139 #define PRIiLEAST64 PRIi64
140 #define PRIiFAST64 PRIi64
144 * fprintf macros for unsigned integers
147 #define PRIo8 _MODF8 _PRIo
148 #define PRIoLEAST8 PRIo8
149 #define PRIoFAST8 PRIo8
150 #define PRIo16 _MODF16 _PRIo
151 #define PRIoLEAST16 PRIo16
153 #define PRIoFAST16 PRIo32
154 #define PRIoLEAST32 PRIo32
155 #define PRIoFAST32 PRIo32
159 #if defined(_LONGLONG_TYPE)
164 #define PRIoLEAST64 PRIo64
165 #define PRIoFAST64 PRIo64
168 #define PRIu8 _MODF8 _PRIu
169 #define PRIuLEAST8 PRIu8
170 #define PRIuFAST8 PRIu8
171 #define PRIu16 _MODF16 _PRIu
172 #define PRIuLEAST16 PRIu16
174 #define PRIuFAST16 PRIu32
175 #define PRIuLEAST32 PRIu32
176 #define PRIuFAST32 PRIu32
180 #if defined(_LONGLONG_TYPE)
185 #define PRIuLEAST64 PRIu64
186 #define PRIuFAST64 PRIu64
189 #define PRIx8 _MODF8 _PRIx
190 #define PRIxLEAST8 PRIx8
191 #define PRIxFAST8 PRIx8
192 #define PRIx16 _MODF16 _PRIx
193 #define PRIxLEAST16 PRIx16
195 #define PRIxFAST16 PRIx32
196 #define PRIxLEAST32 PRIx32
197 #define PRIxFAST32 PRIx32
201 #if defined(_LONGLONG_TYPE)
206 #define PRIxLEAST64 PRIx64
207 #define PRIxFAST64 PRIx64
210 #define PRIX8 _MODF8 _PRIX
211 #define PRIXLEAST8 PRIX8
212 #define PRIXFAST8 PRIX8
213 #define PRIX16 _MODF16 _PRIX
214 #define PRIXLEAST16 PRIX16
216 #define PRIXFAST16 PRIX32
217 #define PRIXLEAST32 PRIX32
218 #define PRIXFAST32 PRIX32
222 #if defined(_LONGLONG_TYPE)
227 #define PRIXLEAST64 PRIX64
228 #define PRIXFAST64 PRIX64
232 * fprintf macros for pointers
235 #if defined(_LP64) || defined(_I32LPx)
249 #endif /* defined(_LP64) || defined(_I32LPx) */
252 * fscanf macros for signed integers
254 #if defined(_CHAR_IS_SIGNED) || defined(__STDC__)
256 #define SCNdLEAST8 SCNd8
257 #define SCNdFAST8 SCNd8
260 #define SCNdLEAST16 SCNd16
262 #define SCNdFAST16 SCNd32
263 #define SCNdLEAST32 SCNd32
264 #define SCNdFAST32 SCNd32
266 #define SCNd64 PRId64
267 #define SCNdLEAST64 PRId64
268 #define SCNdFAST64 PRId64
270 #define SCNdPTR PRIdPTR
272 #if defined(_CHAR_IS_SIGNED) || defined(__STDC__)
274 #define SCNiLEAST8 SCNi8
275 #define SCNiFAST8 SCNi8
278 #define SCNiLEAST16 SCNi16
280 #define SCNiFAST16 SCNi32
281 #define SCNiLEAST32 SCNi32
282 #define SCNiFAST32 SCNi32
284 #define SCNi64 PRIi64
285 #define SCNiLEAST64 PRIi64
286 #define SCNiFAST64 PRIi64
288 #define SCNiPTR PRIiPTR
291 * fscanf macros for unsigned integers
294 #define SCNoLEAST8 SCNo8
295 #define SCNoFAST8 SCNo8
297 #define SCNoLEAST16 SCNo16
299 #define SCNoFAST16 SCNo32
300 #define SCNoLEAST32 SCNo32
301 #define SCNoFAST32 SCNo32
303 #define SCNo64 PRIo64
304 #define SCNoLEAST64 PRIo64
305 #define SCNoFAST64 PRIo64
307 #define SCNoPTR PRIoPTR
310 #define SCNuLEAST8 SCNu8
311 #define SCNuFAST8 SCNu8
313 #define SCNuLEAST16 SCNu16
315 #define SCNuFAST16 SCNu32
316 #define SCNuLEAST32 SCNu32
317 #define SCNuFAST32 SCNu32
319 #define SCNu64 PRIu64
320 #define SCNuLEAST64 PRIu64
321 #define SCNuFAST64 PRIu64
323 #define SCNuPTR PRIuPTR
326 #define SCNxLEAST8 SCNx8
327 #define SCNxFAST8 SCNx8
329 #define SCNxLEAST16 SCNx16
331 #define SCNxFAST16 SCNx32
332 #define SCNxLEAST32 SCNx32
333 #define SCNxFAST32 SCNx32
335 #define SCNx64 PRIx64
336 #define SCNxLEAST64 PRIx64
337 #define SCNxFAST64 PRIx64
339 #define SCNxPTR PRIxPTR
342 #define SCNXLEAST8 SCNX8
343 #define SCNXFAST8 SCNX8
345 #define SCNXLEAST16 SCNX16
347 #define SCNXFAST16 SCNX32
348 #define SCNXLEAST32 SCNX32
349 #define SCNXFAST32 SCNX32
351 #define SCNX64 PRIX64
352 #define SCNXLEAST64 PRIX64
353 #define SCNXFAST64 PRIX64
355 #define SCNXPTR PRIXPTR
358 * The following macros define I/O formats for intmax_t and uintmax_t.
360 #if !defined(_LP64) && defined(_LONGLONG_TYPE)
361 #define PRIdMAX "lld"
362 #define PRIiMAX "lli"
363 #define PRIoMAX "llo"
364 #define PRIxMAX "llx"
365 #define PRIuMAX "llu"
366 #define PRIXMAX "llX"
374 #endif /* !defined(_LP64) && defined(_LONGLONG_TYPE) */
376 #define SCNdMAX PRIdMAX
377 #define SCNiMAX PRIiMAX
378 #define SCNoMAX PRIoMAX
379 #define SCNxMAX PRIxMAX
380 #define SCNuMAX PRIuMAX
381 #define SCNXMAX PRIXMAX
387 #endif /* _SYS_INT_FMTIO_H */