1 | /* |
---|
2 | * COPYRIGHT (c) 2004, 2005. |
---|
3 | * Ralf Corsepius, Ulm/Germany. |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.org/license/LICENSE. |
---|
8 | * |
---|
9 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | /** |
---|
13 | * @file inttypes.h |
---|
14 | */ |
---|
15 | |
---|
16 | #ifndef _INTTYPES_H |
---|
17 | #define _INTTYPES_H |
---|
18 | |
---|
19 | #include <stdint.h> |
---|
20 | |
---|
21 | #define __STRINGIFY(a) #a |
---|
22 | |
---|
23 | /* 8-bit types */ |
---|
24 | #define __PRI8(x) __STRINGIFY(x) |
---|
25 | #define __SCN8(x) __STRINGIFY(hh##x) |
---|
26 | |
---|
27 | |
---|
28 | #define PRId8 __PRI8(d) |
---|
29 | #define PRIi8 __PRI8(i) |
---|
30 | #define PRIo8 __PRI8(o) |
---|
31 | #define PRIu8 __PRI8(u) |
---|
32 | #define PRIx8 __PRI8(x) |
---|
33 | #define PRIX8 __PRI8(X) |
---|
34 | |
---|
35 | #define SCNd8 __SCN8(d) |
---|
36 | #define SCNi8 __SCN8(i) |
---|
37 | #define SCNo8 __SCN8(o) |
---|
38 | #define SCNu8 __SCN8(u) |
---|
39 | #define SCNx8 __SCN8(x) |
---|
40 | |
---|
41 | |
---|
42 | #define PRIdLEAST8 __PRI8(d) |
---|
43 | #define PRIiLEAST8 __PRI8(i) |
---|
44 | #define PRIoLEAST8 __PRI8(o) |
---|
45 | #define PRIuLEAST8 __PRI8(u) |
---|
46 | #define PRIxLEAST8 __PRI8(x) |
---|
47 | #define PRIXLEAST8 __PRI8(X) |
---|
48 | |
---|
49 | #define SCNdLEAST8 __SCN8(d) |
---|
50 | #define SCNiLEAST8 __SCN8(i) |
---|
51 | #define SCNoLEAST8 __SCN8(o) |
---|
52 | #define SCNuLEAST8 __SCN8(u) |
---|
53 | #define SCNxLEAST8 __SCN8(x) |
---|
54 | |
---|
55 | |
---|
56 | #define PRIdFAST8 __PRI8(d) |
---|
57 | #define PRIiFAST8 __PRI8(i) |
---|
58 | #define PRIoFAST8 __PRI8(o) |
---|
59 | #define PRIuFAST8 __PRI8(u) |
---|
60 | #define PRIxFAST8 __PRI8(x) |
---|
61 | #define PRIXFAST8 __PRI8(X) |
---|
62 | |
---|
63 | #define SCNdFAST8 __SCN8(d) |
---|
64 | #define SCNiFAST8 __SCN8(i) |
---|
65 | #define SCNoFAST8 __SCN8(o) |
---|
66 | #define SCNuFAST8 __SCN8(u) |
---|
67 | #define SCNxFAST8 __SCN8(x) |
---|
68 | |
---|
69 | /* 16-bit types */ |
---|
70 | #define __PRI16(x) __STRINGIFY(x) |
---|
71 | #define __SCN16(x) __STRINGIFY(h##x) |
---|
72 | |
---|
73 | |
---|
74 | #define PRId16 __PRI16(d) |
---|
75 | #define PRIi16 __PRI16(i) |
---|
76 | #define PRIo16 __PRI16(o) |
---|
77 | #define PRIu16 __PRI16(u) |
---|
78 | #define PRIx16 __PRI16(x) |
---|
79 | #define PRIX16 __PRI16(X) |
---|
80 | |
---|
81 | #define SCNd16 __SCN16(d) |
---|
82 | #define SCNi16 __SCN16(i) |
---|
83 | #define SCNo16 __SCN16(o) |
---|
84 | #define SCNu16 __SCN16(u) |
---|
85 | #define SCNx16 __SCN16(x) |
---|
86 | |
---|
87 | |
---|
88 | #define PRIdLEAST16 __PRI16(d) |
---|
89 | #define PRIiLEAST16 __PRI16(i) |
---|
90 | #define PRIoLEAST16 __PRI16(o) |
---|
91 | #define PRIuLEAST16 __PRI16(u) |
---|
92 | #define PRIxLEAST16 __PRI16(x) |
---|
93 | #define PRIXLEAST16 __PRI16(X) |
---|
94 | |
---|
95 | #define SCNdLEAST16 __SCN16(d) |
---|
96 | #define SCNiLEAST16 __SCN16(i) |
---|
97 | #define SCNoLEAST16 __SCN16(o) |
---|
98 | #define SCNuLEAST16 __SCN16(u) |
---|
99 | #define SCNxLEAST16 __SCN16(x) |
---|
100 | |
---|
101 | |
---|
102 | #define PRIdFAST16 __PRI16(d) |
---|
103 | #define PRIiFAST16 __PRI16(i) |
---|
104 | #define PRIoFAST16 __PRI16(o) |
---|
105 | #define PRIuFAST16 __PRI16(u) |
---|
106 | #define PRIxFAST16 __PRI16(x) |
---|
107 | #define PRIXFAST16 __PRI16(X) |
---|
108 | |
---|
109 | #define SCNdFAST16 __SCN16(d) |
---|
110 | #define SCNiFAST16 __SCN16(i) |
---|
111 | #define SCNoFAST16 __SCN16(o) |
---|
112 | #define SCNuFAST16 __SCN16(u) |
---|
113 | #define SCNxFAST16 __SCN16(x) |
---|
114 | |
---|
115 | /* 32-bit types */ |
---|
116 | #if defined(__rtems_long32) |
---|
117 | #define __PRI32(x) __STRINGIFY(l##x) |
---|
118 | #define __SCN32(x) __STRINGIFY(l##x) |
---|
119 | #else |
---|
120 | #define __PRI32(x) __STRINGIFY(x) |
---|
121 | #define __SCN32(x) __STRINGIFY(x) |
---|
122 | #endif |
---|
123 | |
---|
124 | #define PRId32 __PRI32(d) |
---|
125 | #define PRIi32 __PRI32(i) |
---|
126 | #define PRIo32 __PRI32(o) |
---|
127 | #define PRIu32 __PRI32(u) |
---|
128 | #define PRIx32 __PRI32(x) |
---|
129 | #define PRIX32 __PRI32(X) |
---|
130 | |
---|
131 | #define SCNd32 __SCN32(d) |
---|
132 | #define SCNi32 __SCN32(i) |
---|
133 | #define SCNo32 __SCN32(o) |
---|
134 | #define SCNu32 __SCN32(u) |
---|
135 | #define SCNx32 __SCN32(x) |
---|
136 | |
---|
137 | |
---|
138 | #define PRIdLEAST32 __PRI32(d) |
---|
139 | #define PRIiLEAST32 __PRI32(i) |
---|
140 | #define PRIoLEAST32 __PRI32(o) |
---|
141 | #define PRIuLEAST32 __PRI32(u) |
---|
142 | #define PRIxLEAST32 __PRI32(x) |
---|
143 | #define PRIXLEAST32 __PRI32(X) |
---|
144 | |
---|
145 | #define SCNdLEAST32 __SCN32(d) |
---|
146 | #define SCNiLEAST32 __SCN32(i) |
---|
147 | #define SCNoLEAST32 __SCN32(o) |
---|
148 | #define SCNuLEAST32 __SCN32(u) |
---|
149 | #define SCNxLEAST32 __SCN32(x) |
---|
150 | |
---|
151 | |
---|
152 | #define PRIdFAST32 __PRI32(d) |
---|
153 | #define PRIiFAST32 __PRI32(i) |
---|
154 | #define PRIoFAST32 __PRI32(o) |
---|
155 | #define PRIuFAST32 __PRI32(u) |
---|
156 | #define PRIxFAST32 __PRI32(x) |
---|
157 | #define PRIXFAST32 __PRI32(X) |
---|
158 | |
---|
159 | #define SCNdFAST32 __SCN32(d) |
---|
160 | #define SCNiFAST32 __SCN32(i) |
---|
161 | #define SCNoFAST32 __SCN32(o) |
---|
162 | #define SCNuFAST32 __SCN32(u) |
---|
163 | #define SCNxFAST32 __SCN32(x) |
---|
164 | |
---|
165 | |
---|
166 | /* 64-bit types */ |
---|
167 | #if defined(__rtems_longlong64) |
---|
168 | #define __PRI64(x) __STRINGIFY(ll##x) |
---|
169 | #define __SCN64(x) __STRINGIFY(ll##x) |
---|
170 | #elif defined(__rtems_long64) |
---|
171 | #define __PRI64(x) __STRINGIFY(l##x) |
---|
172 | #define __SCN64(x) __STRINGIFY(l##x) |
---|
173 | #else |
---|
174 | #define __PRI64(x) __STRINGIFY(x) |
---|
175 | #define __SCN64(x) __STRINGIFY(x) |
---|
176 | #endif |
---|
177 | |
---|
178 | #define PRId64 __PRI64(d) |
---|
179 | #define PRIi64 __PRI64(i) |
---|
180 | #define PRIo64 __PRI64(o) |
---|
181 | #define PRIu64 __PRI64(u) |
---|
182 | #define PRIx64 __PRI64(x) |
---|
183 | #define PRIX64 __PRI64(X) |
---|
184 | |
---|
185 | #define SCNd64 __SCN64(d) |
---|
186 | #define SCNi64 __SCN64(i) |
---|
187 | #define SCNo64 __SCN64(o) |
---|
188 | #define SCNu64 __SCN64(u) |
---|
189 | #define SCNx64 __SCN64(x) |
---|
190 | |
---|
191 | #if __int64_t_defined |
---|
192 | #define PRIdLEAST64 __PRI64(d) |
---|
193 | #define PRIiLEAST64 __PRI64(i) |
---|
194 | #define PRIoLEAST64 __PRI64(o) |
---|
195 | #define PRIuLEAST64 __PRI64(u) |
---|
196 | #define PRIxLEAST64 __PRI64(x) |
---|
197 | #define PRIXLEAST64 __PRI64(X) |
---|
198 | |
---|
199 | #define SCNdLEAST64 __SCN64(d) |
---|
200 | #define SCNiLEAST64 __SCN64(i) |
---|
201 | #define SCNoLEAST64 __SCN64(o) |
---|
202 | #define SCNuLEAST64 __SCN64(u) |
---|
203 | #define SCNxLEAST64 __SCN64(x) |
---|
204 | |
---|
205 | |
---|
206 | #define PRIdFAST64 __PRI64(d) |
---|
207 | #define PRIiFAST64 __PRI64(i) |
---|
208 | #define PRIoFAST64 __PRI64(o) |
---|
209 | #define PRIuFAST64 __PRI64(u) |
---|
210 | #define PRIxFAST64 __PRI64(x) |
---|
211 | #define PRIXFAST64 __PRI64(X) |
---|
212 | |
---|
213 | #define SCNdFAST64 __SCN64(d) |
---|
214 | #define SCNiFAST64 __SCN64(i) |
---|
215 | #define SCNoFAST64 __SCN64(o) |
---|
216 | #define SCNuFAST64 __SCN64(u) |
---|
217 | #define SCNxFAST64 __SCN64(x) |
---|
218 | #endif |
---|
219 | |
---|
220 | /* max-bit types */ |
---|
221 | #if defined(__rtems_longlong64) |
---|
222 | #define __PRIMAX(x) __STRINGIFY(ll##x) |
---|
223 | #define __SCNMAX(x) __STRINGIFY(ll##x) |
---|
224 | #elif defined(__rtems_long64) |
---|
225 | #define __PRIMAX(x) __STRINGIFY(l##x) |
---|
226 | #define __SCNMAX(x) __STRINGIFY(l##x) |
---|
227 | #else |
---|
228 | #define __PRIMAX(x) __STRINGIFY(x) |
---|
229 | #define __SCNMAX(x) __STRINGIFY(x) |
---|
230 | #endif |
---|
231 | |
---|
232 | #define PRIdMAX __PRIMAX(d) |
---|
233 | #define PRIiMAX __PRIMAX(i) |
---|
234 | #define PRIoMAX __PRIMAX(o) |
---|
235 | #define PRIuMAX __PRIMAX(u) |
---|
236 | #define PRIxMAX __PRIMAX(x) |
---|
237 | #define PRIXMAX __PRIMAX(X) |
---|
238 | |
---|
239 | #define SCNdMAX __SCNMAX(d) |
---|
240 | #define SCNiMAX __SCNMAX(i) |
---|
241 | #define SCNoMAX __SCNMAX(o) |
---|
242 | #define SCNuMAX __SCNMAX(u) |
---|
243 | #define SCNxMAX __SCNMAX(x) |
---|
244 | |
---|
245 | /* ptr types */ |
---|
246 | #if defined(__rtems_longlong64) |
---|
247 | #define __PRIPTR(x) __STRINGIFY(ll##x) |
---|
248 | #define __SCNPTR(x) __STRINGIFY(ll##x) |
---|
249 | #elif defined(__rtems_long64) |
---|
250 | #define __PRIPTR(x) __STRINGIFY(l##x) |
---|
251 | #define __SCNPTR(x) __STRINGIFY(l##x) |
---|
252 | #else |
---|
253 | #define __PRIPTR(x) __STRINGIFY(x) |
---|
254 | #define __SCNPTR(x) __STRINGIFY(x) |
---|
255 | #endif |
---|
256 | |
---|
257 | #define PRIdPTR __PRIPTR(d) |
---|
258 | #define PRIiPTR __PRIPTR(i) |
---|
259 | #define PRIoPTR __PRIPTR(o) |
---|
260 | #define PRIuPTR __PRIPTR(u) |
---|
261 | #define PRIxPTR __PRIPTR(x) |
---|
262 | #define PRIXPTR __PRIPTR(X) |
---|
263 | |
---|
264 | #define SCNdPTR __SCNPTR(d) |
---|
265 | #define SCNiPTR __SCNPTR(i) |
---|
266 | #define SCNoPTR __SCNPTR(o) |
---|
267 | #define SCNuPTR __SCNPTR(u) |
---|
268 | #define SCNxPTR __SCNPTR(x) |
---|
269 | |
---|
270 | |
---|
271 | typedef struct { |
---|
272 | intmax_t quot; |
---|
273 | intmax_t rem; |
---|
274 | } imaxdiv_t; |
---|
275 | |
---|
276 | #ifdef __cplusplus |
---|
277 | extern "C" { |
---|
278 | #endif |
---|
279 | |
---|
280 | extern intmax_t imaxabs(intmax_t j); |
---|
281 | extern imaxdiv_t imaxdiv(intmax_t numer, intmax_t denomer); |
---|
282 | extern intmax_t strtoimax(const char *__restrict, char **__restrict, int); |
---|
283 | extern uintmax_t strtoumax(const char *__restrict, char **__restrict, int); |
---|
284 | extern intmax_t wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int); |
---|
285 | extern uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int); |
---|
286 | |
---|
287 | #ifdef __cplusplus |
---|
288 | } |
---|
289 | #endif |
---|
290 | |
---|
291 | #endif |
---|