Annotation of src/include/inttypes.h, Revision 1.8
1.8 ! millert 1: /* $OpenBSD: inttypes.h,v 1.7 2006/01/13 17:58:09 millert Exp $ */
1.1 millert 2:
3: /*
1.6 millert 4: * Copyright (c) 1997, 2005 Todd C. Miller <Todd.Miller@courtesan.com>
1.1 millert 5: *
1.4 millert 6: * Permission to use, copy, modify, and distribute this software for any
7: * purpose with or without fee is hereby granted, provided that the above
8: * copyright notice and this permission notice appear in all copies.
1.1 millert 9: *
1.5 millert 10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1.1 millert 17: */
18:
1.6 millert 19: #ifndef _INTTYPES_H_
20: #define _INTTYPES_H_
1.1 millert 21:
1.6 millert 22: #include <sys/stdint.h>
1.1 millert 23:
1.6 millert 24: #if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)
25: /*
26: * 7.8.1 Macros for format specifiers
27: *
28: * Each of the following object-like macros expands to a string
29: * literal containing a conversion specifier, possibly modified by
30: * a prefix such as hh, h, l, or ll, suitable for use within the
31: * format argument of a formatted input/output function when
32: * converting the corresponding integer type. These macro names
33: * have the general form of PRI (character string literals for the
34: * fprintf family) or SCN (character string literals for the fscanf
35: * family), followed by the conversion specifier, followed by a
36: * name corresponding to a similar typedef name. For example,
37: * PRIdFAST32 can be used in a format string to print the value of
38: * an integer of type int_fast32_t.
39: */
40:
41: /* fprintf macros for signed integers */
42: #define PRId8 "d"
43: #define PRId16 "d"
44: #define PRId32 "d"
45: #define PRId64 "lld"
46:
47: #define PRIdLEAST8 "d"
48: #define PRIdLEAST16 "d"
49: #define PRIdLEAST32 "d"
50: #define PRIdLEAST64 "lld"
51:
52: #define PRIdFAST8 "d"
53: #define PRIdFAST16 "d"
54: #define PRIdFAST32 "d"
55: #define PRIdFAST64 "lld"
56:
57: #define PRIdMAX "jd"
58: #define PRIdPTR "ld"
59:
60: #define PRIi8 "i"
61: #define PRIi16 "i"
62: #define PRIi32 "i"
63: #define PRIi64 "lli"
64:
65: #define PRIiLEAST8 "i"
66: #define PRIiLEAST16 "i"
67: #define PRIiLEAST32 "i"
68: #define PRIiLEAST64 "lli"
69:
70: #define PRIiFAST8 "i"
71: #define PRIiFAST16 "i"
72: #define PRIiFAST32 "i"
73: #define PRIiFAST64 "lli"
74:
75: #define PRIiMAX "ji"
76: #define PRIiPTR "li"
77:
78: /* fprintf macros for unsigned integers */
79: #define PRIo8 "o"
80: #define PRIo16 "o"
81: #define PRIo32 "o"
82: #define PRIo64 "llo"
83:
84: #define PRIoLEAST8 "o"
85: #define PRIoLEAST16 "o"
86: #define PRIoLEAST32 "o"
87: #define PRIoLEAST64 "llo"
88:
89: #define PRIoFAST8 "o"
90: #define PRIoFAST16 "o"
91: #define PRIoFAST32 "o"
92: #define PRIoFAST64 "llo"
93:
94: #define PRIoMAX "jo"
95: #define PRIoPTR "lo"
96:
97: #define PRIu8 "u"
98: #define PRIu16 "u"
99: #define PRIu32 "u"
100: #define PRIu64 "llu"
101:
102: #define PRIuLEAST8 "u"
103: #define PRIuLEAST16 "u"
104: #define PRIuLEAST32 "u"
105: #define PRIuLEAST64 "llu"
106:
107: #define PRIuFAST8 "u"
108: #define PRIuFAST16 "u"
109: #define PRIuFAST32 "u"
110: #define PRIuFAST64 "llu"
111:
112: #define PRIuMAX "ju"
113: #define PRIuPTR "lu"
114:
115: #define PRIx8 "x"
116: #define PRIx16 "x"
117: #define PRIx32 "x"
118: #define PRIx64 "llx"
119:
120: #define PRIxLEAST8 "x"
121: #define PRIxLEAST16 "x"
122: #define PRIxLEAST32 "x"
123: #define PRIxLEAST64 "llx"
124:
125: #define PRIxFAST8 "x"
126: #define PRIxFAST16 "x"
127: #define PRIxFAST32 "x"
128: #define PRIxFAST64 "llx"
129:
130: #define PRIxMAX "jx"
131: #define PRIxPTR "lx"
132:
133: #define PRIX8 "X"
134: #define PRIX16 "X"
135: #define PRIX32 "X"
136: #define PRIX64 "llX"
137:
138: #define PRIXLEAST8 "X"
139: #define PRIXLEAST16 "X"
140: #define PRIXLEAST32 "X"
141: #define PRIXLEAST64 "llX"
142:
143: #define PRIXFAST8 "X"
144: #define PRIXFAST16 "X"
145: #define PRIXFAST32 "X"
146: #define PRIXFAST64 "llX"
147:
148: #define PRIXMAX "jX"
149: #define PRIXPTR "lX"
150:
151: /* fscanf macros for signed integers */
152: #define SCNd8 "hhd"
153: #define SCNd16 "hd"
154: #define SCNd32 "d"
155: #define SCNd64 "lld"
156:
157: #define SCNdLEAST8 "hhd"
158: #define SCNdLEAST16 "hd"
159: #define SCNdLEAST32 "d"
160: #define SCNdLEAST64 "lld"
161:
162: #define SCNdFAST8 "hhd"
163: #define SCNdFAST16 "hd"
164: #define SCNdFAST32 "d"
165: #define SCNdFAST64 "lld"
166:
167: #define SCNdMAX "jd"
168: #define SCNdPTR "ld"
169:
170: #define SCNi8 "hhi"
171: #define SCNi16 "hi"
172: #define SCNi32 "i"
173: #define SCNi64 "lli"
174:
175: #define SCNiLEAST8 "hhi"
176: #define SCNiLEAST16 "hi"
177: #define SCNiLEAST32 "i"
178: #define SCNiLEAST64 "lli"
179:
180: #define SCNiFAST8 "hhi"
181: #define SCNiFAST16 "hi"
182: #define SCNiFAST32 "i"
183: #define SCNiFAST64 "lli"
184:
185: #define SCNiMAX "ji"
186: #define SCNiPTR "li"
187:
188: /* fscanf macros for unsigned integers */
189: #define SCNo8 "hho"
190: #define SCNo16 "ho"
191: #define SCNo32 "o"
192: #define SCNo64 "llo"
193:
194: #define SCNoLEAST8 "hho"
195: #define SCNoLEAST16 "ho"
196: #define SCNoLEAST32 "o"
197: #define SCNoLEAST64 "llo"
198:
199: #define SCNoFAST8 "hho"
200: #define SCNoFAST16 "ho"
201: #define SCNoFAST32 "o"
202: #define SCNoFAST64 "llo"
203:
204: #define SCNoMAX "jo"
205: #define SCNoPTR "lo"
206:
207: #define SCNu8 "hhu"
208: #define SCNu16 "hu"
209: #define SCNu32 "u"
210: #define SCNu64 "llu"
211:
212: #define SCNuLEAST8 "hhu"
213: #define SCNuLEAST16 "hu"
214: #define SCNuLEAST32 "u"
215: #define SCNuLEAST64 "llu"
216:
217: #define SCNuFAST8 "hhu"
218: #define SCNuFAST16 "hu"
219: #define SCNuFAST32 "u"
220: #define SCNuFAST64 "llu"
221:
222: #define SCNuMAX "ju"
223: #define SCNuPTR "lu"
224:
225: #define SCNx8 "hhx"
226: #define SCNx16 "hx"
227: #define SCNx32 "x"
228: #define SCNx64 "llx"
229:
230: #define SCNxLEAST8 "hhx"
231: #define SCNxLEAST16 "hx"
232: #define SCNxLEAST32 "x"
233: #define SCNxLEAST64 "llx"
234:
235: #define SCNxFAST8 "hhx"
236: #define SCNxFAST16 "hx"
237: #define SCNxFAST32 "x"
238: #define SCNxFAST64 "llx"
239:
240: #define SCNxMAX "jx"
241: #define SCNxPTR "lx"
242:
243: #endif /* __cplusplus || __STDC_FORMAT_MACROS */
244:
1.7 millert 245: typedef struct {
246: intmax_t quot; /* quotient */
247: intmax_t rem; /* remainder */
248: } imaxdiv_t;
249:
250: __BEGIN_DECLS
251: intmax_t imaxabs(intmax_t);
252: imaxdiv_t imaxdiv(intmax_t, intmax_t);
253: intmax_t strtoimax(const char *, char **, int);
254: uintmax_t strtoumax(const char *, char **, int);
255: __END_DECLS
1.1 millert 256:
257: #endif /* _INTTYPES_H_ */