xref: /haiku/headers/posix/inttypes.h (revision 16d5c24e533eb14b7b8a99ee9f3ec9ba66335b1e)
1 /*
2  * Copyright 2002-2008 Haiku inc. All rights reserved.
3  * Distributed under the terms of the MIT License
4  */
5 #ifndef _INTTYPES_H_
6 #define _INTTYPES_H_
7 
8 
9 #include <stdint.h>
10 
11 
12 typedef struct {
13 	intmax_t	quot;	/* quotient */
14 	intmax_t	rem;	/* remainder */
15 } imaxdiv_t;
16 
17 #if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)
18 /* fprintf() macros for signed integers */
19 #	define PRId8			"d"
20 #	define PRIdLEAST8		"d"
21 #	define PRIdFAST8		"d"
22 #	define PRIi8			"i"
23 #	define PRIiLEAST8		"i"
24 #	define PRIiFAST8		"i"
25 
26 #	define PRId16			"d"
27 #	define PRIdLEAST16		"d"
28 #	define PRIdFAST16		"d"
29 #	define PRIi16			"i"
30 #	define PRIiLEAST16		"i"
31 #	define PRIiFAST16		"i"
32 
33 #	define PRId32			"d"
34 #	define PRIdLEAST32		"d"
35 #	define PRIdFAST32		"d"
36 #	define PRIi32			"i"
37 #	define PRIiLEAST32		"i"
38 #	define PRIiFAST32		"i"
39 
40 #	define PRId64			"lld"
41 #	define PRIdLEAST64		"lld"
42 #	define PRIdFAST64		"lld"
43 #	define PRIi64			"lli"
44 #	define PRIiLEAST64		"lli"
45 #	define PRIiFAST64		"lli"
46 
47 #	define PRIdMAX			"lld"
48 #	define PRIdPTR			"d"
49 #	define PRIiMAX			"lli"
50 #	define PRIiPTR			"i"
51 
52 /* fprintf() macros for unsigned integers */
53 #	define PRIu8			"u"
54 #	define PRIuLEAST8		"u"
55 #	define PRIuFAST8		"u"
56 #	define PRIo8			"o"
57 #	define PRIoLEAST8		"o"
58 #	define PRIoFAST8		"o"
59 #	define PRIx8			"x"
60 #	define PRIxLEAST8		"x"
61 #	define PRIxFAST8		"x"
62 #	define PRIX8			"X"
63 #	define PRIXLEAST8		"X"
64 #	define PRIXFAST8		"X"
65 
66 #	define PRIu16			"u"
67 #	define PRIuLEAST16		"u"
68 #	define PRIuFAST16		"u"
69 #	define PRIo16			"o"
70 #	define PRIoLEAST16		"o"
71 #	define PRIoFAST16		"o"
72 #	define PRIx16			"x"
73 #	define PRIxLEAST16		"x"
74 #	define PRIxFAST16		"x"
75 #	define PRIX16			"X"
76 #	define PRIXLEAST16		"X"
77 #	define PRIXFAST16		"X"
78 
79 #	define PRIu32			"u"
80 #	define PRIuLEAST32		"u"
81 #	define PRIuFAST32		"u"
82 #	define PRIo32			"o"
83 #	define PRIoLEAST32		"o"
84 #	define PRIoFAST32		"o"
85 #	define PRIx32			"x"
86 #	define PRIxLEAST32		"x"
87 #	define PRIxFAST32		"x"
88 #	define PRIX32			"X"
89 #	define PRIXLEAST32		"X"
90 #	define PRIXFAST32		"X"
91 
92 #	define PRIu64			"llu"
93 #	define PRIuLEAST64		"llu"
94 #	define PRIuFAST64		"llu"
95 #	define PRIo64			"llo"
96 #	define PRIoLEAST64		"llo"
97 #	define PRIoFAST64		"llo"
98 #	define PRIx64			"llx"
99 #	define PRIxLEAST64		"llx"
100 #	define PRIxFAST64		"llx"
101 #	define PRIX64			"llX"
102 #	define PRIXLEAST64		"llX"
103 #	define PRIXFAST64		"llX"
104 
105 #	define PRIuMAX			"llu"
106 #	define PRIuPTR			"u"
107 #	define PRIoMAX			"llo"
108 #	define PRIoPTR			"o"
109 #	define PRIxMAX			"llx"
110 #	define PRIxPTR			"x"
111 #	define PRIXMAX			"llX"
112 #	define PRIXPTR			"X"
113 
114 /* fscanf() macros for signed integers */
115 #	define SCNd8 			"hhd"
116 #	define SCNdLEAST8 		"hhd"
117 #	define SCNdFAST8 		"d"
118 #	define SCNi8 			"hhi"
119 #	define SCNiLEAST8 		"hhi"
120 #	define SCNiFAST8 		"i"
121 
122 #	define SCNd16			"hd"
123 #	define SCNdLEAST16		"hd"
124 #	define SCNdFAST16		"d"
125 #	define SCNi16 			"hi"
126 #	define SCNiLEAST16		"hi"
127 #	define SCNiFAST16		"i"
128 
129 #	define SCNd32 			"d"
130 #	define SCNdLEAST32		"d"
131 #	define SCNdFAST32		"d"
132 #	define SCNi32 			"i"
133 #	define SCNiLEAST32		"i"
134 #	define SCNiFAST32		"i"
135 
136 #	define SCNd64			"lld"
137 #	define SCNdLEAST64		"lld"
138 #	define SCNdFAST64		"lld"
139 #	define SCNi64 			"lli"
140 #	define SCNiLEAST64		"lli"
141 #	define SCNiFAST64 		"lli"
142 
143 #	define SCNdMAX			"lld"
144 #	define SCNdPTR			"d"
145 #	define SCNiMAX			"lli"
146 #	define SCNiPTR			"i"
147 
148 /* fscanf() macros for unsigned integers */
149 #	define SCNu8 			"hhu"
150 #	define SCNuLEAST8 		"hhu"
151 #	define SCNuFAST8 		"u"
152 #	define SCNo8 			"hho"
153 #	define SCNoLEAST8 		"hho"
154 #	define SCNoFAST8 		"o"
155 #	define SCNx8 			"hhx"
156 #	define SCNxLEAST8 		"hhx"
157 #	define SCNxFAST8 		"x"
158 
159 #	define SCNu16			"hu"
160 #	define SCNuLEAST16		"hu"
161 #	define SCNuFAST16		"u"
162 #	define SCNo16			"ho"
163 #	define SCNoLEAST16		"ho"
164 #	define SCNoFAST16		"o"
165 #	define SCNx16			"hx"
166 #	define SCNxLEAST16		"hx"
167 #	define SCNxFAST16		"x"
168 
169 #	define SCNu32 			"u"
170 #	define SCNuLEAST32		"u"
171 #	define SCNuFAST32		"u"
172 #	define SCNo32 			"o"
173 #	define SCNoLEAST32		"o"
174 #	define SCNoFAST32		"o"
175 #	define SCNx32 			"x"
176 #	define SCNxLEAST32		"x"
177 #	define SCNxFAST32		"x"
178 
179 #	define SCNu64			"llu"
180 #	define SCNuLEAST64		"llu"
181 #	define SCNuFAST64		"llu"
182 #	define SCNo64			"llo"
183 #	define SCNoLEAST64		"llo"
184 #	define SCNoFAST64		"llo"
185 #	define SCNx64			"llx"
186 #	define SCNxLEAST64		"llx"
187 #	define SCNxFAST64		"llx"
188 
189 #	define SCNuMAX			"llu"
190 #	define SCNuPTR			"u"
191 #	define SCNoMAX			"llo"
192 #	define SCNoPTR			"o"
193 #	define SCNxMAX			"llx"
194 #	define SCNxPTR			"x"
195 #endif /* !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) */
196 
197 
198 #ifdef __cplusplus
199 extern "C" {
200 #endif
201 
202 extern intmax_t		imaxabs(intmax_t num);
203 extern imaxdiv_t	imaxdiv(intmax_t numer, intmax_t denom);
204 
205 extern intmax_t		strtoimax(const char *string, char **_end, int base);
206 extern uintmax_t	strtoumax(const char *string, char **_end, int base);
207 /* extern intmax_t		wcstoimax(const __wchar_t *, __wchar_t **, int); */
208 /* extern uintmax_t	wcstoumax(const __wchar_t *, __wchar_t **, int); */
209 
210 #ifdef __cplusplus
211 }
212 #endif
213 
214 #endif	/* _INTTYPES_H_ */
215