]> git.saurik.com Git - apple/libc.git/blame - include/inttypes.h
Libc-763.13.tar.gz
[apple/libc.git] / include / inttypes.h
CommitLineData
3d9156a7
A
1/*
2 * Copyright (c) 2000, 2001, 2002, 2003, 2004 Apple Computer, Inc.
3 * All rights reserved.
4 *
5 * @APPLE_LICENSE_HEADER_START@
6 *
7 * The contents of this file constitute Original Code as defined in and
8 * are subject to the Apple Public Source License Version 1.1 (the
9 * "License"). You may not use this file except in compliance with the
10 * License. Please obtain a copy of the License at
11 * http://www.apple.com/publicsource and read it before using this file.
12 *
13 * This 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 OR NON-INFRINGEMENT. Please see the
18 * License for the specific language governing rights and limitations
19 * 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
1f2f436a
A
31#if !defined(_INTTYPES_H_)
32#define _INTTYPES_H_
3d9156a7
A
33
34# undef __PRI_8_LENGTH_MODIFIER__
35# undef __PRI_64_LENGTH_MODIFIER__
36# undef __SCN_64_LENGTH_MODIFIER__
37
224c7076
A
38# if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0 > 1020
39# define __PRI_8_LENGTH_MODIFIER__ "hh"
40# define __PRI_64_LENGTH_MODIFIER__ "ll"
41# define __SCN_64_LENGTH_MODIFIER__ "ll"
42# else
3d9156a7
A
43/* These could be "hh", "ll", and "ll" respectively, but that doesn't work on
44 10.2, and these do. Note that there's no way to use scanf to scan a
45 decimal into a 'char' argument on 10.2, so "hh" is used unconditionally
46 and programs that use it won't work on Jaguar. */
224c7076
A
47# define __PRI_8_LENGTH_MODIFIER__ "" /* none */
48# define __PRI_64_LENGTH_MODIFIER__ "q"
49# define __SCN_64_LENGTH_MODIFIER__ "q"
50# endif
3d9156a7
A
51# define __PRI_MAX_LENGTH_MODIFIER__ "j"
52# define __SCN_MAX_LENGTH_MODIFIER__ "j"
53
54# define PRId8 __PRI_8_LENGTH_MODIFIER__ "d"
55# define PRIi8 __PRI_8_LENGTH_MODIFIER__ "i"
56# define PRIo8 __PRI_8_LENGTH_MODIFIER__ "o"
57# define PRIu8 __PRI_8_LENGTH_MODIFIER__ "u"
58# define PRIx8 __PRI_8_LENGTH_MODIFIER__ "x"
59# define PRIX8 __PRI_8_LENGTH_MODIFIER__ "X"
60
61# define PRId16 "hd"
62# define PRIi16 "hi"
63# define PRIo16 "ho"
64# define PRIu16 "hu"
65# define PRIx16 "hx"
66# define PRIX16 "hX"
67
68# define PRId32 "d"
69# define PRIi32 "i"
70# define PRIo32 "o"
71# define PRIu32 "u"
72# define PRIx32 "x"
73# define PRIX32 "X"
74
75# define PRId64 __PRI_64_LENGTH_MODIFIER__ "d"
76# define PRIi64 __PRI_64_LENGTH_MODIFIER__ "i"
77# define PRIo64 __PRI_64_LENGTH_MODIFIER__ "o"
78# define PRIu64 __PRI_64_LENGTH_MODIFIER__ "u"
79# define PRIx64 __PRI_64_LENGTH_MODIFIER__ "x"
80# define PRIX64 __PRI_64_LENGTH_MODIFIER__ "X"
81
82# define PRIdLEAST8 PRId8
83# define PRIiLEAST8 PRIi8
84# define PRIoLEAST8 PRIo8
85# define PRIuLEAST8 PRIu8
86# define PRIxLEAST8 PRIx8
87# define PRIXLEAST8 PRIX8
88
89# define PRIdLEAST16 PRId16
90# define PRIiLEAST16 PRIi16
91# define PRIoLEAST16 PRIo16
92# define PRIuLEAST16 PRIu16
93# define PRIxLEAST16 PRIx16
94# define PRIXLEAST16 PRIX16
95
96# define PRIdLEAST32 PRId32
97# define PRIiLEAST32 PRIi32
98# define PRIoLEAST32 PRIo32
99# define PRIuLEAST32 PRIu32
100# define PRIxLEAST32 PRIx32
101# define PRIXLEAST32 PRIX32
102
103# define PRIdLEAST64 PRId64
104# define PRIiLEAST64 PRIi64
105# define PRIoLEAST64 PRIo64
106# define PRIuLEAST64 PRIu64
107# define PRIxLEAST64 PRIx64
108# define PRIXLEAST64 PRIX64
109
110# define PRIdFAST8 PRId8
111# define PRIiFAST8 PRIi8
112# define PRIoFAST8 PRIo8
113# define PRIuFAST8 PRIu8
114# define PRIxFAST8 PRIx8
115# define PRIXFAST8 PRIX8
116
117# define PRIdFAST16 PRId16
118# define PRIiFAST16 PRIi16
119# define PRIoFAST16 PRIo16
120# define PRIuFAST16 PRIu16
121# define PRIxFAST16 PRIx16
122# define PRIXFAST16 PRIX16
123
124# define PRIdFAST32 PRId32
125# define PRIiFAST32 PRIi32
126# define PRIoFAST32 PRIo32
127# define PRIuFAST32 PRIu32
128# define PRIxFAST32 PRIx32
129# define PRIXFAST32 PRIX32
130
131# define PRIdFAST64 PRId64
132# define PRIiFAST64 PRIi64
133# define PRIoFAST64 PRIo64
134# define PRIuFAST64 PRIu64
135# define PRIxFAST64 PRIx64
136# define PRIXFAST64 PRIX64
137
138/* int32_t is 'int', but intptr_t is 'long'. */
139# define PRIdPTR "ld"
140# define PRIiPTR "li"
141# define PRIoPTR "lo"
142# define PRIuPTR "lu"
143# define PRIxPTR "lx"
144# define PRIXPTR "lX"
145
146# define PRIdMAX __PRI_MAX_LENGTH_MODIFIER__ "d"
147# define PRIiMAX __PRI_MAX_LENGTH_MODIFIER__ "i"
148# define PRIoMAX __PRI_MAX_LENGTH_MODIFIER__ "o"
149# define PRIuMAX __PRI_MAX_LENGTH_MODIFIER__ "u"
150# define PRIxMAX __PRI_MAX_LENGTH_MODIFIER__ "x"
151# define PRIXMAX __PRI_MAX_LENGTH_MODIFIER__ "X"
152
224c7076
A
153# if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0 > 1020
154# define SCNd8 __PRI_8_LENGTH_MODIFIER__ "d"
155# define SCNi8 __PRI_8_LENGTH_MODIFIER__ "i"
156# define SCNo8 __PRI_8_LENGTH_MODIFIER__ "o"
157# define SCNu8 __PRI_8_LENGTH_MODIFIER__ "u"
158# define SCNx8 __PRI_8_LENGTH_MODIFIER__ "x"
159# else
160# define SCNd8 "hhd"
161# define SCNi8 "hhi"
162# define SCNo8 "hho"
163# define SCNu8 "hhu"
164# define SCNx8 "hhx"
165# endif
3d9156a7
A
166
167# define SCNd16 "hd"
168# define SCNi16 "hi"
169# define SCNo16 "ho"
170# define SCNu16 "hu"
171# define SCNx16 "hx"
172
173# define SCNd32 "d"
174# define SCNi32 "i"
175# define SCNo32 "o"
176# define SCNu32 "u"
177# define SCNx32 "x"
178
179# define SCNd64 __SCN_64_LENGTH_MODIFIER__ "d"
180# define SCNi64 __SCN_64_LENGTH_MODIFIER__ "i"
181# define SCNo64 __SCN_64_LENGTH_MODIFIER__ "o"
182# define SCNu64 __SCN_64_LENGTH_MODIFIER__ "u"
183# define SCNx64 __SCN_64_LENGTH_MODIFIER__ "x"
184
185# define SCNdLEAST8 SCNd8
186# define SCNiLEAST8 SCNi8
187# define SCNoLEAST8 SCNo8
188# define SCNuLEAST8 SCNu8
189# define SCNxLEAST8 SCNx8
190
191# define SCNdLEAST16 SCNd16
192# define SCNiLEAST16 SCNi16
193# define SCNoLEAST16 SCNo16
194# define SCNuLEAST16 SCNu16
195# define SCNxLEAST16 SCNx16
196
197# define SCNdLEAST32 SCNd32
198# define SCNiLEAST32 SCNi32
199# define SCNoLEAST32 SCNo32
200# define SCNuLEAST32 SCNu32
201# define SCNxLEAST32 SCNx32
202
203# define SCNdLEAST64 SCNd64
204# define SCNiLEAST64 SCNi64
205# define SCNoLEAST64 SCNo64
206# define SCNuLEAST64 SCNu64
207# define SCNxLEAST64 SCNx64
208
209# define SCNdFAST8 SCNd8
210# define SCNiFAST8 SCNi8
211# define SCNoFAST8 SCNo8
212# define SCNuFAST8 SCNu8
213# define SCNxFAST8 SCNx8
214
215# define SCNdFAST16 SCNd16
216# define SCNiFAST16 SCNi16
217# define SCNoFAST16 SCNo16
218# define SCNuFAST16 SCNu16
219# define SCNxFAST16 SCNx16
220
221# define SCNdFAST32 SCNd32
222# define SCNiFAST32 SCNi32
223# define SCNoFAST32 SCNo32
224# define SCNuFAST32 SCNu32
225# define SCNxFAST32 SCNx32
226
227# define SCNdFAST64 SCNd64
228# define SCNiFAST64 SCNi64
229# define SCNoFAST64 SCNo64
230# define SCNuFAST64 SCNu64
231# define SCNxFAST64 SCNx64
232
233# define SCNdPTR "ld"
234# define SCNiPTR "li"
235# define SCNoPTR "lo"
236# define SCNuPTR "lu"
237# define SCNxPTR "lx"
238
239# define SCNdMAX __SCN_MAX_LENGTH_MODIFIER__ "d"
240# define SCNiMAX __SCN_MAX_LENGTH_MODIFIER__ "i"
241# define SCNoMAX __SCN_MAX_LENGTH_MODIFIER__ "o"
242# define SCNuMAX __SCN_MAX_LENGTH_MODIFIER__ "u"
243# define SCNxMAX __SCN_MAX_LENGTH_MODIFIER__ "x"
244
224c7076
A
245#include <sys/cdefs.h> /* For __BEGIN_DECLS and __END_DECLS */
246#include <_types.h> /* For __darwin_wchar_t */
247#include <stdint.h>
248
249#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
250 /* Translator is not ISO/IEC 9899:1999-compliant. */
251# if !defined(restrict)
252# define restrict
253# define __RESTRICT_KEYWORD_DEFINED__
254# endif
255#endif
256
3d9156a7
A
257__BEGIN_DECLS
258
259 /* 7.8.2.1 */
260 extern intmax_t imaxabs(intmax_t j);
261
262 /* 7.8.2.2 */
263 typedef struct {
264 intmax_t quot;
265 intmax_t rem;
266 } imaxdiv_t;
267
268 extern imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
269
270 /* 7.8.2.3 */
271 extern intmax_t strtoimax(const char * restrict nptr, char ** restrict endptr, int base);
272 extern uintmax_t strtoumax(const char * restrict nptr, char ** restrict endptr, int base);
273
274#ifndef __cplusplus /* wchar_t is a built-in type in C++ */
275# ifndef _WCHAR_T
276# define _WCHAR_T
277 typedef __darwin_wchar_t wchar_t;
278# endif /* _WCHAR_T */
279#endif /* __cplusplus */
280
281 /* 7.8.2.4 */
282 extern intmax_t wcstoimax(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base);
283 extern uintmax_t wcstoumax(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base);
284
224c7076
A
285/* Poison the following routines if -fshort-wchar is set */
286#if !defined(__cplusplus) && defined(__WCHAR_MAX__) && __WCHAR_MAX__ <= 0xffffU
287#pragma GCC poison wcstoimax wcstoumax
288#endif
289
3d9156a7
A
290__END_DECLS
291
292#ifdef _USE_EXTENDED_LOCALES_
293#include <xlocale/_inttypes.h>
294#endif /* _USE_EXTENDED_LOCALES_ */
295
296/*
297 No need to #undef the __*_{8,64}_LENGTH_MODIFIER__ macros;
298 in fact, you can't #undef them, because later uses of any of
299 their dependents will *not* then do the intended substitution.
300 Expansion of a #define like this one:
301
302 #define x IDENT y
303
304 uses the cpp value of IDENT at the location where x is *expanded*,
305 not where it is #defined.
306*/
307
308#if defined(__RESTRICT_KEYWORD_DEFINED__)
309# undef restrict
310# undef __RESTRICT_KEYWORD_DEFINED__
311#endif
312
313#endif /* !_INTTYPES_H_ */