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