]> git.saurik.com Git - apple/libc.git/blob - include/inttypes.h
Libc-1439.100.3.tar.gz
[apple/libc.git] / include / inttypes.h
1 /*
2 * Copyright (c) 2000-2004, 2013 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 /*
25 * <inttypes.h> -- Standard C header, defined in ISO/IEC 9899:1999
26 * (aka "C99"), section 7.8. This defines format string conversion
27 * specifiers suitable for use within arguments to fprintf and fscanf
28 * and their ilk.
29 */
30
31 #if !defined(_INTTYPES_H_)
32 #define _INTTYPES_H_
33
34 # define __PRI_8_LENGTH_MODIFIER__ "hh"
35 # define __PRI_64_LENGTH_MODIFIER__ "ll"
36 # define __SCN_64_LENGTH_MODIFIER__ "ll"
37 # define __PRI_MAX_LENGTH_MODIFIER__ "j"
38 # define __SCN_MAX_LENGTH_MODIFIER__ "j"
39
40 # define PRId8 __PRI_8_LENGTH_MODIFIER__ "d"
41 # define PRIi8 __PRI_8_LENGTH_MODIFIER__ "i"
42 # define PRIo8 __PRI_8_LENGTH_MODIFIER__ "o"
43 # define PRIu8 __PRI_8_LENGTH_MODIFIER__ "u"
44 # define PRIx8 __PRI_8_LENGTH_MODIFIER__ "x"
45 # define PRIX8 __PRI_8_LENGTH_MODIFIER__ "X"
46
47 # define PRId16 "hd"
48 # define PRIi16 "hi"
49 # define PRIo16 "ho"
50 # define PRIu16 "hu"
51 # define PRIx16 "hx"
52 # define PRIX16 "hX"
53
54 # define PRId32 "d"
55 # define PRIi32 "i"
56 # define PRIo32 "o"
57 # define PRIu32 "u"
58 # define PRIx32 "x"
59 # define PRIX32 "X"
60
61 # define PRId64 __PRI_64_LENGTH_MODIFIER__ "d"
62 # define PRIi64 __PRI_64_LENGTH_MODIFIER__ "i"
63 # define PRIo64 __PRI_64_LENGTH_MODIFIER__ "o"
64 # define PRIu64 __PRI_64_LENGTH_MODIFIER__ "u"
65 # define PRIx64 __PRI_64_LENGTH_MODIFIER__ "x"
66 # define PRIX64 __PRI_64_LENGTH_MODIFIER__ "X"
67
68 # define PRIdLEAST8 PRId8
69 # define PRIiLEAST8 PRIi8
70 # define PRIoLEAST8 PRIo8
71 # define PRIuLEAST8 PRIu8
72 # define PRIxLEAST8 PRIx8
73 # define PRIXLEAST8 PRIX8
74
75 # define PRIdLEAST16 PRId16
76 # define PRIiLEAST16 PRIi16
77 # define PRIoLEAST16 PRIo16
78 # define PRIuLEAST16 PRIu16
79 # define PRIxLEAST16 PRIx16
80 # define PRIXLEAST16 PRIX16
81
82 # define PRIdLEAST32 PRId32
83 # define PRIiLEAST32 PRIi32
84 # define PRIoLEAST32 PRIo32
85 # define PRIuLEAST32 PRIu32
86 # define PRIxLEAST32 PRIx32
87 # define PRIXLEAST32 PRIX32
88
89 # define PRIdLEAST64 PRId64
90 # define PRIiLEAST64 PRIi64
91 # define PRIoLEAST64 PRIo64
92 # define PRIuLEAST64 PRIu64
93 # define PRIxLEAST64 PRIx64
94 # define PRIXLEAST64 PRIX64
95
96 # define PRIdFAST8 PRId8
97 # define PRIiFAST8 PRIi8
98 # define PRIoFAST8 PRIo8
99 # define PRIuFAST8 PRIu8
100 # define PRIxFAST8 PRIx8
101 # define PRIXFAST8 PRIX8
102
103 # define PRIdFAST16 PRId16
104 # define PRIiFAST16 PRIi16
105 # define PRIoFAST16 PRIo16
106 # define PRIuFAST16 PRIu16
107 # define PRIxFAST16 PRIx16
108 # define PRIXFAST16 PRIX16
109
110 # define PRIdFAST32 PRId32
111 # define PRIiFAST32 PRIi32
112 # define PRIoFAST32 PRIo32
113 # define PRIuFAST32 PRIu32
114 # define PRIxFAST32 PRIx32
115 # define PRIXFAST32 PRIX32
116
117 # define PRIdFAST64 PRId64
118 # define PRIiFAST64 PRIi64
119 # define PRIoFAST64 PRIo64
120 # define PRIuFAST64 PRIu64
121 # define PRIxFAST64 PRIx64
122 # define PRIXFAST64 PRIX64
123
124 /* int32_t is 'int', but intptr_t is 'long'. */
125 # define PRIdPTR "ld"
126 # define PRIiPTR "li"
127 # define PRIoPTR "lo"
128 # define PRIuPTR "lu"
129 # define PRIxPTR "lx"
130 # define PRIXPTR "lX"
131
132 # define PRIdMAX __PRI_MAX_LENGTH_MODIFIER__ "d"
133 # define PRIiMAX __PRI_MAX_LENGTH_MODIFIER__ "i"
134 # define PRIoMAX __PRI_MAX_LENGTH_MODIFIER__ "o"
135 # define PRIuMAX __PRI_MAX_LENGTH_MODIFIER__ "u"
136 # define PRIxMAX __PRI_MAX_LENGTH_MODIFIER__ "x"
137 # define PRIXMAX __PRI_MAX_LENGTH_MODIFIER__ "X"
138
139 # define SCNd8 __PRI_8_LENGTH_MODIFIER__ "d"
140 # define SCNi8 __PRI_8_LENGTH_MODIFIER__ "i"
141 # define SCNo8 __PRI_8_LENGTH_MODIFIER__ "o"
142 # define SCNu8 __PRI_8_LENGTH_MODIFIER__ "u"
143 # define SCNx8 __PRI_8_LENGTH_MODIFIER__ "x"
144
145 # define SCNd16 "hd"
146 # define SCNi16 "hi"
147 # define SCNo16 "ho"
148 # define SCNu16 "hu"
149 # define SCNx16 "hx"
150
151 # define SCNd32 "d"
152 # define SCNi32 "i"
153 # define SCNo32 "o"
154 # define SCNu32 "u"
155 # define SCNx32 "x"
156
157 # define SCNd64 __SCN_64_LENGTH_MODIFIER__ "d"
158 # define SCNi64 __SCN_64_LENGTH_MODIFIER__ "i"
159 # define SCNo64 __SCN_64_LENGTH_MODIFIER__ "o"
160 # define SCNu64 __SCN_64_LENGTH_MODIFIER__ "u"
161 # define SCNx64 __SCN_64_LENGTH_MODIFIER__ "x"
162
163 # define SCNdLEAST8 SCNd8
164 # define SCNiLEAST8 SCNi8
165 # define SCNoLEAST8 SCNo8
166 # define SCNuLEAST8 SCNu8
167 # define SCNxLEAST8 SCNx8
168
169 # define SCNdLEAST16 SCNd16
170 # define SCNiLEAST16 SCNi16
171 # define SCNoLEAST16 SCNo16
172 # define SCNuLEAST16 SCNu16
173 # define SCNxLEAST16 SCNx16
174
175 # define SCNdLEAST32 SCNd32
176 # define SCNiLEAST32 SCNi32
177 # define SCNoLEAST32 SCNo32
178 # define SCNuLEAST32 SCNu32
179 # define SCNxLEAST32 SCNx32
180
181 # define SCNdLEAST64 SCNd64
182 # define SCNiLEAST64 SCNi64
183 # define SCNoLEAST64 SCNo64
184 # define SCNuLEAST64 SCNu64
185 # define SCNxLEAST64 SCNx64
186
187 # define SCNdFAST8 SCNd8
188 # define SCNiFAST8 SCNi8
189 # define SCNoFAST8 SCNo8
190 # define SCNuFAST8 SCNu8
191 # define SCNxFAST8 SCNx8
192
193 # define SCNdFAST16 SCNd16
194 # define SCNiFAST16 SCNi16
195 # define SCNoFAST16 SCNo16
196 # define SCNuFAST16 SCNu16
197 # define SCNxFAST16 SCNx16
198
199 # define SCNdFAST32 SCNd32
200 # define SCNiFAST32 SCNi32
201 # define SCNoFAST32 SCNo32
202 # define SCNuFAST32 SCNu32
203 # define SCNxFAST32 SCNx32
204
205 # define SCNdFAST64 SCNd64
206 # define SCNiFAST64 SCNi64
207 # define SCNoFAST64 SCNo64
208 # define SCNuFAST64 SCNu64
209 # define SCNxFAST64 SCNx64
210
211 # define SCNdPTR "ld"
212 # define SCNiPTR "li"
213 # define SCNoPTR "lo"
214 # define SCNuPTR "lu"
215 # define SCNxPTR "lx"
216
217 # define SCNdMAX __SCN_MAX_LENGTH_MODIFIER__ "d"
218 # define SCNiMAX __SCN_MAX_LENGTH_MODIFIER__ "i"
219 # define SCNoMAX __SCN_MAX_LENGTH_MODIFIER__ "o"
220 # define SCNuMAX __SCN_MAX_LENGTH_MODIFIER__ "u"
221 # define SCNxMAX __SCN_MAX_LENGTH_MODIFIER__ "x"
222
223 #include <sys/cdefs.h>
224 #include <Availability.h>
225
226 #include <_types.h>
227 #include <sys/_types/_wchar_t.h>
228
229 #include <stdint.h>
230
231 __BEGIN_DECLS
232
233 /* 7.8.2.1 */
234 __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
235 extern intmax_t
236 imaxabs(intmax_t j);
237
238 /* 7.8.2.2 */
239 typedef struct {
240 intmax_t quot;
241 intmax_t rem;
242 } imaxdiv_t;
243
244 __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
245 extern imaxdiv_t
246 imaxdiv(intmax_t __numer, intmax_t __denom);
247
248 /* 7.8.2.3 */
249 __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
250 extern intmax_t
251 strtoimax(const char * __restrict __nptr,
252 char ** __restrict __endptr,
253 int __base);
254
255 __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
256 extern uintmax_t
257 strtoumax(const char * __restrict __nptr,
258 char ** __restrict __endptr,
259 int __base);
260
261 /* 7.8.2.4 */
262 __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
263 extern intmax_t
264 wcstoimax(const wchar_t * __restrict __nptr,
265 wchar_t ** __restrict __endptr,
266 int __base);
267
268 __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
269 extern uintmax_t
270 wcstoumax(const wchar_t * __restrict __nptr,
271 wchar_t ** __restrict __endptr,
272 int __base);
273
274 /* Poison the following routines if -fshort-wchar is set */
275 #if !defined(__cplusplus) && defined(__WCHAR_MAX__) && __WCHAR_MAX__ <= 0xffffU
276 #pragma GCC poison wcstoimax wcstoumax
277 #endif
278
279 __END_DECLS
280
281 #ifdef _USE_EXTENDED_LOCALES_
282 #include <xlocale/_inttypes.h>
283 #endif /* _USE_EXTENDED_LOCALES_ */
284
285 /*
286 No need to #undef the __*_{8,64}_LENGTH_MODIFIER__ macros;
287 in fact, you can't #undef them, because later uses of any of
288 their dependents will *not* then do the intended substitution.
289 Expansion of a #define like this one:
290
291 #define x IDENT y
292
293 uses the cpp value of IDENT at the location where x is *expanded*,
294 not where it is #defined.
295 */
296
297 #endif /* !_INTTYPES_H_ */