summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/include/inttypes.h
blob: c1c69220ea08d0d76639a0792134c693d45e1ae7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
/*
 *  COPYRIGHT (c) 2004.
 *  Ralf Corsepius, Ulm/Germany.
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.org/license/LICENSE.
 *
 *  $Id$
 */

/**
 *  @file  sys/_inttypes.h
 */

#ifndef __INTTYPES_H
#define __INTTYPES_H

#include <stdint.h>

#define __STRINGIFY(a) #a

/* 8-bit types */
#define __PRI8(x) __STRINGIFY(x)
#define __SCN8(x) __STRINGIFY(hh##x)


#define PRId8		__PRI8(d)
#define PRIi8		__PRI8(i)
#define PRIo8		__PRI8(o)
#define PRIu8		__PRI8(u)
#define PRIx8		__PRI8(x)
#define PRIX8		__PRI8(X)

#define SCNd8		__SCN8(d)
#define SCNi8		__SCN8(i)
#define SCNo8		__SCN8(o)
#define SCNu8		__SCN8(u)
#define SCNx8		__SCN8(x)


#define PRIdLEAST8	__PRI8(d)
#define PRIiLEAST8	__PRI8(i)
#define PRIoLEAST8	__PRI8(o)
#define PRIuLEAST8	__PRI8(u)
#define PRIxLEAST8	__PRI8(x)
#define PRIXLEAST8	__PRI8(X)

#define SCNdLEAST8	__SCN8(d)
#define SCNiLEAST8	__SCN8(i)
#define SCNoLEAST8	__SCN8(o)
#define SCNuLEAST8	__SCN8(u)
#define SCNxLEAST8	__SCN8(x)


#define PRIdFAST8	__PRI8(d)
#define PRIiFAST8	__PRI8(i)
#define PRIoFAST8	__PRI8(o)
#define PRIuFAST8	__PRI8(u)
#define PRIxFAST8	__PRI8(x)
#define PRIXFAST8	__PRI8(X)

#define SCNdFAST8	__SCN8(d)
#define SCNiFAST8	__SCN8(i)
#define SCNoFAST8	__SCN8(o)
#define SCNuFAST8	__SCN8(u)
#define SCNxFAST8	__SCN8(x)

/* 16-bit types */
#define __PRI16(x) __STRINGIFY(x)
#define __SCN16(x) __STRINGIFY(h##x)


#define PRId16		__PRI16(d)
#define PRIi16		__PRI16(i)
#define PRIo16		__PRI16(o)
#define PRIu16		__PRI16(u)
#define PRIx16		__PRI16(x)
#define PRIX16		__PRI16(X)

#define SCNd16		__SCN16(d)
#define SCNi16		__SCN16(i)
#define SCNo16		__SCN16(o)
#define SCNu16		__SCN16(u)
#define SCNx16		__SCN16(x)


#define PRIdLEAST16	__PRI16(d)
#define PRIiLEAST16	__PRI16(i)
#define PRIoLEAST16	__PRI16(o)
#define PRIuLEAST16	__PRI16(u)
#define PRIxLEAST16	__PRI16(x)
#define PRIXLEAST16	__PRI16(X)

#define SCNdLEAST16	__SCN16(d)
#define SCNiLEAST16	__SCN16(i)
#define SCNoLEAST16	__SCN16(o)
#define SCNuLEAST16	__SCN16(u)
#define SCNxLEAST16	__SCN16(x)


#define PRIdFAST16	__PRI16(d)
#define PRIiFAST16	__PRI16(i)
#define PRIoFAST16	__PRI16(o)
#define PRIuFAST16	__PRI16(u)
#define PRIxFAST16	__PRI16(x)
#define PRIXFAST16	__PRI16(X)

#define SCNdFAST16	__SCN16(d)
#define SCNiFAST16	__SCN16(i)
#define SCNoFAST16	__SCN16(o)
#define SCNuFAST16	__SCN16(u)
#define SCNxFAST16	__SCN16(x)

/* 32-bit types */
#if defined(__rtems_long32)
#define __PRI32(x) __STRINGIFY(l##x)
#define __SCN32(x) __STRINGIFY(l##x)
#else
#define __PRI32(x) __STRINGIFY(x)
#define __SCN32(x) __STRINGIFY(x)
#endif

#define PRId32		__PRI32(d)
#define PRIi32		__PRI32(i)
#define PRIo32		__PRI32(o)
#define PRIu32		__PRI32(u)
#define PRIx32		__PRI32(x)
#define PRIX32		__PRI32(X)

#define SCNd32		__SCN32(d)
#define SCNi32		__SCN32(i)
#define SCNo32		__SCN32(o)
#define SCNu32		__SCN32(u)
#define SCNx32		__SCN32(x)


#define PRIdLEAST32	__PRI32(d)
#define PRIiLEAST32	__PRI32(i)
#define PRIoLEAST32	__PRI32(o)
#define PRIuLEAST32	__PRI32(u)
#define PRIxLEAST32	__PRI32(x)
#define PRIXLEAST32	__PRI32(X)

#define SCNdLEAST32	__SCN32(d)
#define SCNiLEAST32	__SCN32(i)
#define SCNoLEAST32	__SCN32(o)
#define SCNuLEAST32	__SCN32(u)
#define SCNxLEAST32	__SCN32(x)


#define PRIdFAST32	__PRI32(d)
#define PRIiFAST32	__PRI32(i)
#define PRIoFAST32	__PRI32(o)
#define PRIuFAST32	__PRI32(u)
#define PRIxFAST32	__PRI32(x)
#define PRIXFAST32	__PRI32(X)

#define SCNdFAST32	__SCN32(d)
#define SCNiFAST32	__SCN32(i)
#define SCNoFAST32	__SCN32(o)
#define SCNuFAST32	__SCN32(u)
#define SCNxFAST32	__SCN32(x)


/* 64-bit types */
#if defined(__rtems_longlong64)
#define __PRI64(x) __STRINGIFY(ll##x)
#define __SCN64(x) __STRINGIFY(ll##x)
#elif defined(__rtems_long64)
#define __PRI64(x) __STRINGIFY(l##x)
#define __SCN64(x) __STRINGIFY(l##x)
#else
#define __PRI64(x) __STRINGIFY(x)
#define __SCN64(x) __STRINGIFY(x)
#endif

#define PRId64		__PRI64(d)
#define PRIi64		__PRI64(i)
#define PRIo64		__PRI64(o)
#define PRIu64		__PRI64(u)
#define PRIx64		__PRI64(x)
#define PRIX64		__PRI64(X)

#define SCNd64		__SCN64(d)
#define SCNi64		__SCN64(i)
#define SCNo64		__SCN64(o)
#define SCNu64		__SCN64(u)
#define SCNx64		__SCN64(x)

#if __int64_t_defined
#define PRIdLEAST64	__PRI64(d)
#define PRIiLEAST64	__PRI64(i)
#define PRIoLEAST64	__PRI64(o)
#define PRIuLEAST64	__PRI64(u)
#define PRIxLEAST64	__PRI64(x)
#define PRIXLEAST64	__PRI64(X)

#define SCNdLEAST64	__SCN64(d)
#define SCNiLEAST64	__SCN64(i)
#define SCNoLEAST64	__SCN64(o)
#define SCNuLEAST64	__SCN64(u)
#define SCNxLEAST64	__SCN64(x)


#define PRIdFAST64	__PRI64(d)
#define PRIiFAST64	__PRI64(i)
#define PRIoFAST64	__PRI64(o)
#define PRIuFAST64	__PRI64(u)
#define PRIxFAST64	__PRI64(x)
#define PRIXFAST64	__PRI64(X)

#define SCNdFAST64	__SCN64(d)
#define SCNiFAST64	__SCN64(i)
#define SCNoFAST64	__SCN64(o)
#define SCNuFAST64	__SCN64(u)
#define SCNxFAST64	__SCN64(x)
#endif

/* max-bit types */
#if defined(__rtems_longlong64)
#define __PRIMAX(x) __STRINGIFY(ll##x)
#define __SCNMAX(x) __STRINGIFY(ll##x)
#elif defined(__rtems_long64)
#define __PRIMAX(x) __STRINGIFY(l##x)
#define __SCNMAX(x) __STRINGIFY(l##x)
#else
#define __PRIMAX(x) __STRINGIFY(x)
#define __SCNMAX(x) __STRINGIFY(x)
#endif

#define PRIdMAX		__PRIMAX(d)
#define PRIiMAX		__PRIMAX(i)
#define PRIoMAX		__PRIMAX(o)
#define PRIuMAX		__PRIMAX(u)
#define PRIxMAX		__PRIMAX(x)
#define PRIXMAX		__PRIMAX(X)

#define SCNdMAX		__SCNMAX(d)
#define SCNiMAX		__SCNMAX(i)
#define SCNoMAX		__SCNMAX(o)
#define SCNuMAX		__SCNMAX(u)
#define SCNxMAX		__SCNMAX(x)

/* ptr types */
#if defined(__rtems_longlong64)
#define __PRIPTR(x) __STRINGIFY(ll##x)
#define __SCNPTR(x) __STRINGIFY(ll##x)
#elif defined(__rtems_long64)
#define __PRIPTR(x) __STRINGIFY(l##x)
#define __SCNPTR(x) __STRINGIFY(l##x)
#else
#define __PRIPTR(x) __STRINGIFY(x)
#define __SCNPTR(x) __STRINGIFY(x)
#endif

#define PRIdPTR		__PRIPTR(d)
#define PRIiPTR		__PRIPTR(i)
#define PRIoPTR		__PRIPTR(o)
#define PRIuPTR		__PRIPTR(u)
#define PRIxPTR		__PRIPTR(x)
#define PRIXPTR		__PRIPTR(X)

#define SCNdPTR		__SCNPTR(d)
#define SCNiPTR		__SCNPTR(i)
#define SCNoPTR		__SCNPTR(o)
#define SCNuPTR		__SCNPTR(u)
#define SCNxPTR		__SCNPTR(x)


typedef struct {
  intmax_t	quot;
  intmax_t	rem;
} imaxdiv_t;

#ifdef __cplusplus
extern "C" {
#endif

extern intmax_t  imaxabs(intmax_t j);
extern imaxdiv_t imaxdiv(intmax_t numer, intmax_t denomer);
extern intmax_t  strtoimax(const char *__restrict, char **__restrict, int);
extern uintmax_t strtoumax(const char *__restrict, char **__restrict, int);
extern intmax_t  wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int);
extern uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);

#ifdef __cplusplus
}
#endif

#endif