Print this page
remove support for non-ANSI compilation
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/int_fmtio.h
+++ new/usr/src/uts/common/sys/int_fmtio.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22 /*
23 + * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 + *
23 25 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 26 * Use is subject to license terms.
25 27 */
26 28
27 29 #ifndef _SYS_INT_FMTIO_H
28 30 #define _SYS_INT_FMTIO_H
29 31
30 -#pragma ident "%Z%%M% %I% %E% SMI"
31 -
32 32 /*
33 33 * This file, <sys/int_fmtio.h>, is part of the Sun Microsystems implementation
34 34 * of <inttypes.h> as defined by the ISO C Standard, ISO/IEC 9899:1999
35 35 * Programming language - C.
36 36 *
37 37 * ISO International Organization for Standardization.
38 38 *
39 39 * Programs/Modules should not directly include this file. Access to the
40 40 * types defined in this file should be through the inclusion of one of the
41 41 * following files:
42 42 *
43 43 * <sys/inttypes.h> Provides the Kernel and Driver appropriate
44 44 * components of <inttypes.h>.
45 45 *
46 46 * <inttypes.h> For use by applications.
47 47 *
48 48 * See these files for more details.
49 49 */
50 50
51 51 #include <sys/feature_tests.h>
52 52
53 53 #ifdef __cplusplus
54 54 extern "C" {
55 55 #endif
56 56
57 57 /*
58 58 * Formatted I/O
59 59 *
60 60 * The following macros can be used even when an implementation has not
61 61 * extended the printf/scanf family of functions.
62 62 *
63 63 * The form of the names of the macros is either "PRI" for printf specifiers
64 64 * or "SCN" for scanf specifiers, followed by the conversion specifier letter
65 65 * followed by the datatype size. For example, PRId32 is the macro for
66 66 * the printf d conversion specifier with the flags for 32 bit datatype.
67 67 *
68 68 * An example using one of these macros:
69 69 *
70 70 * uint64_t u;
71 71 * printf("u = %016" PRIx64 "\n", u);
72 72 *
73 73 * For the purpose of example, the definitions of the printf/scanf macros
74 74 * below have the values appropriate for a machine with 8 bit shorts, 16
75 75 * bit shorts, 32 bit ints, 32 or 64 bit longs depending on compilation
76 76 * mode, and 64 bit long longs.
77 77 */
78 78
79 79 /*
80 80 * fprintf macros for signed integers
81 81 */
82 82 #if defined(_KERNEL)
83 83 #define _MODF8 ""
84 84 #define _MODF16 ""
85 85 #else
86 86 #define _MODF8 "hh"
↓ open down ↓ |
45 lines elided |
↑ open up ↑ |
87 87 #define _MODF16 "h"
88 88 #endif
89 89
90 90 #define _PRId "d"
91 91 #define _PRIi "i"
92 92 #define _PRIo "o"
93 93 #define _PRIu "u"
94 94 #define _PRIx "x"
95 95 #define _PRIX "X"
96 96
97 -#if defined(_CHAR_IS_SIGNED) || defined(__STDC__)
98 97 #define PRId8 _MODF8 _PRId
99 98 #define PRIdLEAST8 PRId8
100 99 #define PRIdFAST8 PRId8
101 -#endif
102 100 #define PRId16 _MODF16 _PRId
103 101 #define PRIdLEAST16 PRId16
104 102 #define PRId32 "d"
105 103 #define PRIdFAST16 PRId32
106 104 #define PRIdLEAST32 PRId32
107 105 #define PRIdFAST32 PRId32
108 106 #ifdef _LP64
109 107 #define PRId64 "ld"
110 108 #else /* _ILP32 */
111 109 #if defined(_LONGLONG_TYPE)
112 110 #define PRId64 "lld"
113 111 #endif
114 112 #endif
115 113 #ifdef PRId64
116 114 #define PRIdLEAST64 PRId64
117 115 #define PRIdFAST64 PRId64
118 116 #endif
119 117
120 -#if defined(_CHAR_IS_SIGNED) || defined(__STDC__)
121 118 #define PRIi8 _MODF8 _PRIi
122 119 #define PRIiLEAST8 PRIi8
123 120 #define PRIiFAST8 PRIi8
124 -#endif
125 121 #define PRIi16 _MODF16 _PRIi
126 122 #define PRIiLEAST16 PRIi16
127 123 #define PRIi32 "i"
128 124 #define PRIiFAST16 PRIi32
129 125 #define PRIiLEAST32 PRIi32
130 126 #define PRIiFAST32 PRIi32
131 127 #ifdef _LP64
132 128 #define PRIi64 "li"
133 129 #else /* _ILP32 */
134 130 #if defined(_LONGLONG_TYPE)
135 131 #define PRIi64 "lli"
136 132 #endif
137 133 #endif
138 134 #ifdef PRIi64
139 135 #define PRIiLEAST64 PRIi64
140 136 #define PRIiFAST64 PRIi64
141 137 #endif
142 138
143 139 /*
144 140 * fprintf macros for unsigned integers
145 141 */
146 142
147 143 #define PRIo8 _MODF8 _PRIo
148 144 #define PRIoLEAST8 PRIo8
149 145 #define PRIoFAST8 PRIo8
150 146 #define PRIo16 _MODF16 _PRIo
151 147 #define PRIoLEAST16 PRIo16
152 148 #define PRIo32 "o"
153 149 #define PRIoFAST16 PRIo32
154 150 #define PRIoLEAST32 PRIo32
155 151 #define PRIoFAST32 PRIo32
156 152 #ifdef _LP64
157 153 #define PRIo64 "lo"
158 154 #else /* _ILP32 */
159 155 #if defined(_LONGLONG_TYPE)
160 156 #define PRIo64 "llo"
161 157 #endif
162 158 #endif
163 159 #ifdef PRIo64
164 160 #define PRIoLEAST64 PRIo64
165 161 #define PRIoFAST64 PRIo64
166 162 #endif
167 163
168 164 #define PRIu8 _MODF8 _PRIu
169 165 #define PRIuLEAST8 PRIu8
170 166 #define PRIuFAST8 PRIu8
171 167 #define PRIu16 _MODF16 _PRIu
172 168 #define PRIuLEAST16 PRIu16
173 169 #define PRIu32 "u"
174 170 #define PRIuFAST16 PRIu32
175 171 #define PRIuLEAST32 PRIu32
176 172 #define PRIuFAST32 PRIu32
177 173 #ifdef _LP64
178 174 #define PRIu64 "lu"
179 175 #else /* _ILP32 */
180 176 #if defined(_LONGLONG_TYPE)
181 177 #define PRIu64 "llu"
182 178 #endif
183 179 #endif
184 180 #ifdef PRIu64
185 181 #define PRIuLEAST64 PRIu64
186 182 #define PRIuFAST64 PRIu64
187 183 #endif
188 184
189 185 #define PRIx8 _MODF8 _PRIx
190 186 #define PRIxLEAST8 PRIx8
191 187 #define PRIxFAST8 PRIx8
192 188 #define PRIx16 _MODF16 _PRIx
193 189 #define PRIxLEAST16 PRIx16
194 190 #define PRIx32 "x"
195 191 #define PRIxFAST16 PRIx32
196 192 #define PRIxLEAST32 PRIx32
197 193 #define PRIxFAST32 PRIx32
198 194 #ifdef _LP64
199 195 #define PRIx64 "lx"
200 196 #else /* _ILP32 */
201 197 #if defined(_LONGLONG_TYPE)
202 198 #define PRIx64 "llx"
203 199 #endif
204 200 #endif
205 201 #ifdef PRIx64
206 202 #define PRIxLEAST64 PRIx64
207 203 #define PRIxFAST64 PRIx64
208 204 #endif
209 205
210 206 #define PRIX8 _MODF8 _PRIX
211 207 #define PRIXLEAST8 PRIX8
212 208 #define PRIXFAST8 PRIX8
213 209 #define PRIX16 _MODF16 _PRIX
214 210 #define PRIXLEAST16 PRIX16
215 211 #define PRIX32 "X"
216 212 #define PRIXFAST16 PRIX32
217 213 #define PRIXLEAST32 PRIX32
218 214 #define PRIXFAST32 PRIX32
219 215 #ifdef _LP64
220 216 #define PRIX64 "lX"
221 217 #else /* _ILP32 */
222 218 #if defined(_LONGLONG_TYPE)
223 219 #define PRIX64 "llX"
224 220 #endif
225 221 #endif
226 222 #ifdef PRIX64
227 223 #define PRIXLEAST64 PRIX64
228 224 #define PRIXFAST64 PRIX64
229 225 #endif
230 226
231 227 /*
232 228 * fprintf macros for pointers
233 229 */
234 230
235 231 #if defined(_LP64) || defined(_I32LPx)
236 232 #define PRIdPTR "ld"
237 233 #define PRIiPTR "li"
238 234 #define PRIoPTR "lo"
239 235 #define PRIuPTR "lu"
240 236 #define PRIxPTR "lx"
241 237 #define PRIXPTR "lX"
242 238 #else
243 239 #define PRIdPTR "d"
↓ open down ↓ |
109 lines elided |
↑ open up ↑ |
244 240 #define PRIiPTR "i"
245 241 #define PRIoPTR "o"
246 242 #define PRIuPTR "u"
247 243 #define PRIxPTR "x"
248 244 #define PRIXPTR "X"
249 245 #endif /* defined(_LP64) || defined(_I32LPx) */
250 246
251 247 /*
252 248 * fscanf macros for signed integers
253 249 */
254 -#if defined(_CHAR_IS_SIGNED) || defined(__STDC__)
255 250 #define SCNd8 "hhd"
256 251 #define SCNdLEAST8 SCNd8
257 252 #define SCNdFAST8 SCNd8
258 -#endif
259 253 #define SCNd16 "hd"
260 254 #define SCNdLEAST16 SCNd16
261 255 #define SCNd32 "d"
262 256 #define SCNdFAST16 SCNd32
263 257 #define SCNdLEAST32 SCNd32
264 258 #define SCNdFAST32 SCNd32
265 259 #ifdef PRId64
266 260 #define SCNd64 PRId64
267 261 #define SCNdLEAST64 PRId64
268 262 #define SCNdFAST64 PRId64
269 263 #endif
270 264 #define SCNdPTR PRIdPTR
271 265
272 -#if defined(_CHAR_IS_SIGNED) || defined(__STDC__)
273 266 #define SCNi8 "hhi"
274 267 #define SCNiLEAST8 SCNi8
275 268 #define SCNiFAST8 SCNi8
276 -#endif
277 269 #define SCNi16 "hi"
278 270 #define SCNiLEAST16 SCNi16
279 271 #define SCNi32 "i"
280 272 #define SCNiFAST16 SCNi32
281 273 #define SCNiLEAST32 SCNi32
282 274 #define SCNiFAST32 SCNi32
283 275 #ifdef PRIi64
284 276 #define SCNi64 PRIi64
285 277 #define SCNiLEAST64 PRIi64
286 278 #define SCNiFAST64 PRIi64
287 279 #endif
288 280 #define SCNiPTR PRIiPTR
289 281
290 282 /*
291 283 * fscanf macros for unsigned integers
292 284 */
293 285 #define SCNo8 "hho"
294 286 #define SCNoLEAST8 SCNo8
295 287 #define SCNoFAST8 SCNo8
296 288 #define SCNo16 "ho"
297 289 #define SCNoLEAST16 SCNo16
298 290 #define SCNo32 "o"
299 291 #define SCNoFAST16 SCNo32
300 292 #define SCNoLEAST32 SCNo32
301 293 #define SCNoFAST32 SCNo32
302 294 #ifdef PRIo64
303 295 #define SCNo64 PRIo64
304 296 #define SCNoLEAST64 PRIo64
305 297 #define SCNoFAST64 PRIo64
306 298 #endif
307 299 #define SCNoPTR PRIoPTR
308 300
309 301 #define SCNu8 "hhu"
310 302 #define SCNuLEAST8 SCNu8
311 303 #define SCNuFAST8 SCNu8
312 304 #define SCNu16 "hu"
313 305 #define SCNuLEAST16 SCNu16
314 306 #define SCNu32 "u"
315 307 #define SCNuFAST16 SCNu32
316 308 #define SCNuLEAST32 SCNu32
317 309 #define SCNuFAST32 SCNu32
318 310 #ifdef PRIu64
319 311 #define SCNu64 PRIu64
320 312 #define SCNuLEAST64 PRIu64
321 313 #define SCNuFAST64 PRIu64
322 314 #endif
323 315 #define SCNuPTR PRIuPTR
324 316
325 317 #define SCNx8 "hhx"
326 318 #define SCNxLEAST8 SCNx8
327 319 #define SCNxFAST8 SCNx8
328 320 #define SCNx16 "hx"
329 321 #define SCNxLEAST16 SCNx16
330 322 #define SCNx32 "x"
331 323 #define SCNxFAST16 SCNx32
332 324 #define SCNxLEAST32 SCNx32
333 325 #define SCNxFAST32 SCNx32
334 326 #ifdef PRIx64
335 327 #define SCNx64 PRIx64
336 328 #define SCNxLEAST64 PRIx64
337 329 #define SCNxFAST64 PRIx64
338 330 #endif
339 331 #define SCNxPTR PRIxPTR
340 332
341 333 #define SCNX8 "hhX"
342 334 #define SCNXLEAST8 SCNX8
343 335 #define SCNXFAST8 SCNX8
344 336 #define SCNX16 "hX"
345 337 #define SCNXLEAST16 SCNX16
346 338 #define SCNX32 "X"
347 339 #define SCNXFAST16 SCNX32
348 340 #define SCNXLEAST32 SCNX32
349 341 #define SCNXFAST32 SCNX32
350 342 #ifdef PRIX64
351 343 #define SCNX64 PRIX64
352 344 #define SCNXLEAST64 PRIX64
353 345 #define SCNXFAST64 PRIX64
354 346 #endif
355 347 #define SCNXPTR PRIXPTR
356 348
357 349 /*
358 350 * The following macros define I/O formats for intmax_t and uintmax_t.
359 351 */
360 352 #if !defined(_LP64) && defined(_LONGLONG_TYPE)
361 353 #define PRIdMAX "lld"
362 354 #define PRIiMAX "lli"
363 355 #define PRIoMAX "llo"
364 356 #define PRIxMAX "llx"
365 357 #define PRIuMAX "llu"
366 358 #define PRIXMAX "llX"
367 359 #else
368 360 #define PRIdMAX "ld"
369 361 #define PRIiMAX "li"
370 362 #define PRIoMAX "lo"
371 363 #define PRIxMAX "lx"
372 364 #define PRIuMAX "lu"
373 365 #define PRIXMAX "lX"
374 366 #endif /* !defined(_LP64) && defined(_LONGLONG_TYPE) */
375 367
376 368 #define SCNdMAX PRIdMAX
377 369 #define SCNiMAX PRIiMAX
378 370 #define SCNoMAX PRIoMAX
379 371 #define SCNxMAX PRIxMAX
380 372 #define SCNuMAX PRIuMAX
381 373 #define SCNXMAX PRIXMAX
382 374
383 375 #ifdef __cplusplus
384 376 }
385 377 #endif
386 378
387 379 #endif /* _SYS_INT_FMTIO_H */
↓ open down ↓ |
101 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX