Subversion Repositories Kolibri OS

Rev

Rev 4930 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4349 Serge 1
/*
2
 * Copyright (c) 2004, 2005 by
3
 * Ralf Corsepius, Ulm/Germany. All rights reserved.
4
 *
5
 * Permission to use, copy, modify, and distribute this software
6
 * is freely granted, provided that this notice is preserved.
7
 */
8
 
9
/**
10
 *  @file  inttypes.h
11
 */
12
 
13
#ifndef _INTTYPES_H
14
#define _INTTYPES_H
15
 
6099 serge 16
#include 
17
#include 
18
#include 
4349 Serge 19
#include 
20
#define __need_wchar_t
21
#include 
22
 
23
#define __STRINGIFY(a) #a
24
 
25
/* 8-bit types */
6099 serge 26
#define __PRI8(x) __INT8 __STRINGIFY(x)
27
#define __PRI8LEAST(x) __LEAST8 __STRINGIFY(x)
28
#define __PRI8FAST(x) __FAST8 __STRINGIFY(x)
4349 Serge 29
 
6099 serge 30
/* NOTICE: scanning 8-bit types requires use of the hh specifier
31
 * which is only supported on newlib platforms that
32
 * are built with C99 I/O format support enabled.  If the flag in
33
 * newlib.h hasn't been set during configuration to indicate this, the 8-bit
34
 * scanning format macros are disabled here as they result in undefined
35
 * behaviour which can include memory overwrite.  Overriding the flag after the
36
 * library has been built is not recommended as it will expose the underlying
37
 * undefined behaviour.
38
 */
4349 Serge 39
 
6099 serge 40
#if defined(_WANT_IO_C99_FORMATS)
41
  #define __SCN8(x) __INT8 __STRINGIFY(x)
42
	#define __SCN8LEAST(x) __LEAST8 __STRINGIFY(x)
43
	#define __SCN8FAST(x) __FAST8 __STRINGIFY(x)
44
#endif /* _WANT_IO_C99_FORMATS */
45
 
46
 
4349 Serge 47
#define PRId8		__PRI8(d)
48
#define PRIi8		__PRI8(i)
49
#define PRIo8		__PRI8(o)
50
#define PRIu8		__PRI8(u)
51
#define PRIx8		__PRI8(x)
52
#define PRIX8		__PRI8(X)
53
 
6099 serge 54
/* Macros below are only enabled for a newlib built with C99 I/O format support. */
55
#if defined(_WANT_IO_C99_FORMATS)
56
 
4349 Serge 57
#define SCNd8		__SCN8(d)
58
#define SCNi8		__SCN8(i)
59
#define SCNo8		__SCN8(o)
60
#define SCNu8		__SCN8(u)
61
#define SCNx8		__SCN8(x)
62
 
6099 serge 63
#endif /* _WANT_IO_C99_FORMATS */
4349 Serge 64
 
65
 
6099 serge 66
#define PRIdLEAST8	__PRI8LEAST(d)
67
#define PRIiLEAST8	__PRI8LEAST(i)
68
#define PRIoLEAST8	__PRI8LEAST(o)
69
#define PRIuLEAST8	__PRI8LEAST(u)
70
#define PRIxLEAST8	__PRI8LEAST(x)
71
#define PRIXLEAST8	__PRI8LEAST(X)
4349 Serge 72
 
6099 serge 73
/* Macros below are only enabled for a newlib built with C99 I/O format support. */
74
#if defined(_WANT_IO_C99_FORMATS)
4349 Serge 75
 
6099 serge 76
  #define SCNdLEAST8	__SCN8LEAST(d)
77
  #define SCNiLEAST8	__SCN8LEAST(i)
78
  #define SCNoLEAST8	__SCN8LEAST(o)
79
  #define SCNuLEAST8	__SCN8LEAST(u)
80
  #define SCNxLEAST8	__SCN8LEAST(x)
4349 Serge 81
 
6099 serge 82
#endif /* _WANT_IO_C99_FORMATS */
4349 Serge 83
 
6099 serge 84
#define PRIdFAST8	__PRI8FAST(d)
85
#define PRIiFAST8	__PRI8FAST(i)
86
#define PRIoFAST8	__PRI8FAST(o)
87
#define PRIuFAST8	__PRI8FAST(u)
88
#define PRIxFAST8	__PRI8FAST(x)
89
#define PRIXFAST8	__PRI8FAST(X)
90
 
91
/* Macros below are only enabled for a newlib built with C99 I/O format support. */
92
#if defined(_WANT_IO_C99_FORMATS)
93
 
94
  #define SCNdFAST8	__SCN8FAST(d)
95
  #define SCNiFAST8	__SCN8FAST(i)
96
  #define SCNoFAST8	__SCN8FAST(o)
97
  #define SCNuFAST8	__SCN8FAST(u)
98
  #define SCNxFAST8	__SCN8FAST(x)
99
 
100
#endif /* _WANT_IO_C99_FORMATS */
101
 
4349 Serge 102
/* 16-bit types */
6099 serge 103
#define __PRI16(x) __INT16 __STRINGIFY(x)
104
#define __PRI16LEAST(x) __LEAST16 __STRINGIFY(x)
105
#define __PRI16FAST(x) __FAST16 __STRINGIFY(x)
106
#define __SCN16(x) __INT16 __STRINGIFY(x)
107
#define __SCN16LEAST(x) __LEAST16 __STRINGIFY(x)
108
#define __SCN16FAST(x) __FAST16 __STRINGIFY(x)
4349 Serge 109
 
110
 
111
#define PRId16		__PRI16(d)
112
#define PRIi16		__PRI16(i)
113
#define PRIo16		__PRI16(o)
114
#define PRIu16		__PRI16(u)
115
#define PRIx16		__PRI16(x)
116
#define PRIX16		__PRI16(X)
117
 
118
#define SCNd16		__SCN16(d)
119
#define SCNi16		__SCN16(i)
120
#define SCNo16		__SCN16(o)
121
#define SCNu16		__SCN16(u)
122
#define SCNx16		__SCN16(x)
123
 
124
 
6099 serge 125
#define PRIdLEAST16	__PRI16LEAST(d)
126
#define PRIiLEAST16	__PRI16LEAST(i)
127
#define PRIoLEAST16	__PRI16LEAST(o)
128
#define PRIuLEAST16	__PRI16LEAST(u)
129
#define PRIxLEAST16	__PRI16LEAST(x)
130
#define PRIXLEAST16	__PRI16LEAST(X)
4349 Serge 131
 
6099 serge 132
#define SCNdLEAST16	__SCN16LEAST(d)
133
#define SCNiLEAST16	__SCN16LEAST(i)
134
#define SCNoLEAST16	__SCN16LEAST(o)
135
#define SCNuLEAST16	__SCN16LEAST(u)
136
#define SCNxLEAST16	__SCN16LEAST(x)
4349 Serge 137
 
138
 
6099 serge 139
#define PRIdFAST16	__PRI16FAST(d)
140
#define PRIiFAST16	__PRI16FAST(i)
141
#define PRIoFAST16	__PRI16FAST(o)
142
#define PRIuFAST16	__PRI16FAST(u)
143
#define PRIxFAST16	__PRI16FAST(x)
144
#define PRIXFAST16	__PRI16FAST(X)
4349 Serge 145
 
6099 serge 146
#define SCNdFAST16	__SCN16FAST(d)
147
#define SCNiFAST16	__SCN16FAST(i)
148
#define SCNoFAST16	__SCN16FAST(o)
149
#define SCNuFAST16	__SCN16FAST(u)
150
#define SCNxFAST16	__SCN16FAST(x)
4349 Serge 151
 
152
/* 32-bit types */
6099 serge 153
#define __PRI32(x) __INT32 __STRINGIFY(x)
154
#define __SCN32(x) __INT32 __STRINGIFY(x)
155
#define __PRI32LEAST(x) __LEAST32 __STRINGIFY(x)
156
#define __SCN32LEAST(x) __LEAST32 __STRINGIFY(x)
157
#define __PRI32FAST(x) __FAST32 __STRINGIFY(x)
158
#define __SCN32FAST(x) __FAST32 __STRINGIFY(x)
4349 Serge 159
 
160
#define PRId32		__PRI32(d)
161
#define PRIi32		__PRI32(i)
162
#define PRIo32		__PRI32(o)
163
#define PRIu32		__PRI32(u)
164
#define PRIx32		__PRI32(x)
165
#define PRIX32		__PRI32(X)
166
 
167
#define SCNd32		__SCN32(d)
168
#define SCNi32		__SCN32(i)
169
#define SCNo32		__SCN32(o)
170
#define SCNu32		__SCN32(u)
171
#define SCNx32		__SCN32(x)
172
 
173
 
6099 serge 174
#define PRIdLEAST32	__PRI32LEAST(d)
175
#define PRIiLEAST32	__PRI32LEAST(i)
176
#define PRIoLEAST32	__PRI32LEAST(o)
177
#define PRIuLEAST32	__PRI32LEAST(u)
178
#define PRIxLEAST32	__PRI32LEAST(x)
179
#define PRIXLEAST32	__PRI32LEAST(X)
4349 Serge 180
 
6099 serge 181
#define SCNdLEAST32	__SCN32LEAST(d)
182
#define SCNiLEAST32	__SCN32LEAST(i)
183
#define SCNoLEAST32	__SCN32LEAST(o)
184
#define SCNuLEAST32	__SCN32LEAST(u)
185
#define SCNxLEAST32	__SCN32LEAST(x)
4349 Serge 186
 
187
 
6099 serge 188
#define PRIdFAST32	__PRI32FAST(d)
189
#define PRIiFAST32	__PRI32FAST(i)
190
#define PRIoFAST32	__PRI32FAST(o)
191
#define PRIuFAST32	__PRI32FAST(u)
192
#define PRIxFAST32	__PRI32FAST(x)
193
#define PRIXFAST32	__PRI32FAST(X)
4349 Serge 194
 
6099 serge 195
#define SCNdFAST32	__SCN32FAST(d)
196
#define SCNiFAST32	__SCN32FAST(i)
197
#define SCNoFAST32	__SCN32FAST(o)
198
#define SCNuFAST32	__SCN32FAST(u)
199
#define SCNxFAST32	__SCN32FAST(x)
4349 Serge 200
 
201
 
202
/* 64-bit types */
6099 serge 203
#define __PRI64(x) __INT64 __STRINGIFY(x)
204
#define __SCN64(x) __INT64 __STRINGIFY(x)
4349 Serge 205
 
6099 serge 206
#define __PRI64LEAST(x) __LEAST64 __STRINGIFY(x)
207
#define __SCN64LEAST(x) __LEAST64 __STRINGIFY(x)
208
#define __PRI64FAST(x) __FAST64 __STRINGIFY(x)
209
#define __SCN64FAST(x) __FAST64 __STRINGIFY(x)
210
 
211
#if __int64_t_defined
4349 Serge 212
#define PRId64		__PRI64(d)
213
#define PRIi64		__PRI64(i)
214
#define PRIo64		__PRI64(o)
215
#define PRIu64		__PRI64(u)
216
#define PRIx64		__PRI64(x)
217
#define PRIX64		__PRI64(X)
218
 
219
#define SCNd64		__SCN64(d)
220
#define SCNi64		__SCN64(i)
221
#define SCNo64		__SCN64(o)
222
#define SCNu64		__SCN64(u)
223
#define SCNx64		__SCN64(x)
6099 serge 224
#endif
4349 Serge 225
 
6099 serge 226
#if __int_least64_t_defined
227
#define PRIdLEAST64	__PRI64LEAST(d)
228
#define PRIiLEAST64	__PRI64LEAST(i)
229
#define PRIoLEAST64	__PRI64LEAST(o)
230
#define PRIuLEAST64	__PRI64LEAST(u)
231
#define PRIxLEAST64	__PRI64LEAST(x)
232
#define PRIXLEAST64	__PRI64LEAST(X)
4349 Serge 233
 
6099 serge 234
#define SCNdLEAST64	__SCN64LEAST(d)
235
#define SCNiLEAST64	__SCN64LEAST(i)
236
#define SCNoLEAST64	__SCN64LEAST(o)
237
#define SCNuLEAST64	__SCN64LEAST(u)
238
#define SCNxLEAST64	__SCN64LEAST(x)
239
#endif
4349 Serge 240
 
6099 serge 241
#if __int_fast64_t_defined
242
#define PRIdFAST64	__PRI64FAST(d)
243
#define PRIiFAST64	__PRI64FAST(i)
244
#define PRIoFAST64	__PRI64FAST(o)
245
#define PRIuFAST64	__PRI64FAST(u)
246
#define PRIxFAST64	__PRI64FAST(x)
247
#define PRIXFAST64	__PRI64FAST(X)
4349 Serge 248
 
6099 serge 249
#define SCNdFAST64	__SCN64FAST(d)
250
#define SCNiFAST64	__SCN64FAST(i)
251
#define SCNoFAST64	__SCN64FAST(o)
252
#define SCNuFAST64	__SCN64FAST(u)
253
#define SCNxFAST64	__SCN64FAST(x)
4349 Serge 254
#endif
255
 
256
/* max-bit types */
257
#if __have_long64
258
#define __PRIMAX(x) __STRINGIFY(l##x)
259
#define __SCNMAX(x) __STRINGIFY(l##x)
260
#elif __have_longlong64
261
#define __PRIMAX(x) __STRINGIFY(ll##x)
262
#define __SCNMAX(x) __STRINGIFY(ll##x)
263
#else
264
#define __PRIMAX(x) __STRINGIFY(x)
265
#define __SCNMAX(x) __STRINGIFY(x)
266
#endif
267
 
268
#define PRIdMAX		__PRIMAX(d)
269
#define PRIiMAX		__PRIMAX(i)
270
#define PRIoMAX		__PRIMAX(o)
271
#define PRIuMAX		__PRIMAX(u)
272
#define PRIxMAX		__PRIMAX(x)
273
#define PRIXMAX		__PRIMAX(X)
274
 
275
#define SCNdMAX		__SCNMAX(d)
276
#define SCNiMAX		__SCNMAX(i)
277
#define SCNoMAX		__SCNMAX(o)
278
#define SCNuMAX		__SCNMAX(u)
279
#define SCNxMAX		__SCNMAX(x)
280
 
281
/* ptr types */
6099 serge 282
#if defined (_INTPTR_EQ_LONGLONG)
283
# define __PRIPTR(x) __STRINGIFY(ll##x)
284
# define __SCNPTR(x) __STRINGIFY(ll##x)
285
#elif defined (_INTPTR_EQ_LONG)
4921 Serge 286
# define __PRIPTR(x) __STRINGIFY(l##x)
287
# define __SCNPTR(x) __STRINGIFY(l##x)
4349 Serge 288
#else
6099 serge 289
# define __PRIPTR(x) __STRINGIFY(x)
290
# define __SCNPTR(x) __STRINGIFY(x)
4349 Serge 291
#endif
292
 
293
#define PRIdPTR		__PRIPTR(d)
294
#define PRIiPTR		__PRIPTR(i)
295
#define PRIoPTR		__PRIPTR(o)
296
#define PRIuPTR		__PRIPTR(u)
297
#define PRIxPTR		__PRIPTR(x)
298
#define PRIXPTR		__PRIPTR(X)
299
 
300
#define SCNdPTR		__SCNPTR(d)
301
#define SCNiPTR		__SCNPTR(i)
302
#define SCNoPTR		__SCNPTR(o)
303
#define SCNuPTR		__SCNPTR(u)
304
#define SCNxPTR		__SCNPTR(x)
305
 
306
 
307
typedef struct {
308
  intmax_t	quot;
309
  intmax_t	rem;
310
} imaxdiv_t;
311
 
312
#ifdef __cplusplus
313
extern "C" {
314
#endif
315
 
316
extern intmax_t  imaxabs(intmax_t j);
317
extern imaxdiv_t imaxdiv(intmax_t numer, intmax_t denomer);
318
extern intmax_t  strtoimax(const char *__restrict, char **__restrict, int);
319
extern uintmax_t strtoumax(const char *__restrict, char **__restrict, int);
320
extern intmax_t  wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int);
321
extern uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);
322
 
323
#ifdef __cplusplus
324
}
325
#endif
326
 
327
#endif