source: mainline/abi/include/inttypes.h@ 9286475

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 9286475 was 3f7fe9e, checked in by Jiří Zárevúcky <jiri.zarevucky@…>, 7 years ago

Clean up headers

Depends on <limits.h> and <stdint.h> being provided, which is a step up from
depending on mostly undocumented predefined macros.
In principle, <limits.h> and <stdint.h> mostly describe properties of
the compiler, so even though we depend on certain values for their contents,
actually defining them in the library is kind of reversal of concerns.

  • Property mode set to 100644
File size: 7.6 KB
Line 
1/*
2 * Copyright (c) 2017 CZ.NIC, z.s.p.o.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/*
30 * Authors:
31 * Jiří Zárevúcky (jzr) <zarevucky.jiri@gmail.com>
32 */
33
34/** @addtogroup bits
35 * @{
36 */
37/** @file
38 */
39
40#ifndef _BITS_INTTYPES_H_
41#define _BITS_INTTYPES_H_
42
43#include <stdint.h>
44#include <_bits/wchar_t.h>
45
46/*
47 * We assume the -helenos target is in use, which means the following assignment:
48 *
49 * 32b 64b
50 * int8_t unsigned char unsigned char
51 * int16_t short short
52 * int32_t int int
53 * int64_t long long long
54 * intptr_t int long
55 * size_t unsigned int unsigned long
56 * ptrdiff_t int long
57 * intmax_t long long long long
58 *
59 * intleast*_t same as int*_t
60 * intfast*_t at least int, otherwise same as int*_t
61 */
62
63#define PRId8 "hhd"
64#define PRIdLEAST8 "hhd"
65#define PRIdFAST8 "d"
66
67#define PRIi8 "hhi"
68#define PRIiLEAST8 "hhi"
69#define PRIiFAST8 "i"
70
71#define PRIo8 "hho"
72#define PRIoLEAST8 "hho"
73#define PRIoFAST8 "o"
74
75#define PRIu8 "hhu"
76#define PRIuLEAST8 "hhu"
77#define PRIuFAST8 "u"
78
79#define PRIx8 "hhx"
80#define PRIxLEAST8 "hhx"
81#define PRIxFAST8 "x"
82
83#define PRIX8 "hhX"
84#define PRIXLEAST8 "hhX"
85#define PRIXFAST8 "X"
86
87#define SCNd8 "hhd"
88#define SCNdLEAST8 "hhd"
89#define SCNdFAST8 "d"
90
91#define SCNi8 "hhi"
92#define SCNiLEAST8 "hhi"
93#define SCNiFAST8 "i"
94
95#define SCNo8 "hho"
96#define SCNoLEAST8 "hho"
97#define SCNoFAST8 "o"
98
99#define SCNu8 "hhu"
100#define SCNuLEAST8 "hhu"
101#define SCNuFAST8 "u"
102
103#define SCNx8 "hhx"
104#define SCNxLEAST8 "hhx"
105#define SCNxFAST8 "x"
106
107#define PRId16 "hd"
108#define PRIdLEAST16 "hd"
109#define PRIdFAST16 "d"
110
111#define PRIi16 "hi"
112#define PRIiLEAST16 "hi"
113#define PRIiFAST16 "i"
114
115#define PRIo16 "ho"
116#define PRIoLEAST16 "ho"
117#define PRIoFAST16 "o"
118
119#define PRIu16 "hu"
120#define PRIuLEAST16 "hu"
121#define PRIuFAST16 "u"
122
123#define PRIx16 "hx"
124#define PRIxLEAST16 "hx"
125#define PRIxFAST16 "x"
126
127#define PRIX16 "hX"
128#define PRIXLEAST16 "hX"
129#define PRIXFAST16 "X"
130
131#define SCNd16 "hd"
132#define SCNdLEAST16 "hd"
133#define SCNdFAST16 "d"
134
135#define SCNi16 "hi"
136#define SCNiLEAST16 "hi"
137#define SCNiFAST16 "i"
138
139#define SCNo16 "ho"
140#define SCNoLEAST16 "ho"
141#define SCNoFAST16 "o"
142
143#define SCNu16 "hu"
144#define SCNuLEAST16 "hu"
145#define SCNuFAST16 "u"
146
147#define SCNx16 "hx"
148#define SCNxLEAST16 "hx"
149#define SCNxFAST16 "x"
150
151#define PRId32 "d"
152#define PRIdLEAST32 "d"
153#define PRIdFAST32 "d"
154
155#define PRIi32 "i"
156#define PRIiLEAST32 "i"
157#define PRIiFAST32 "i"
158
159#define PRIo32 "o"
160#define PRIoLEAST32 "o"
161#define PRIoFAST32 "o"
162
163#define PRIu32 "u"
164#define PRIuLEAST32 "u"
165#define PRIuFAST32 "u"
166
167#define PRIx32 "x"
168#define PRIxLEAST32 "x"
169#define PRIxFAST32 "x"
170
171#define PRIX32 "X"
172#define PRIXLEAST32 "X"
173#define PRIXFAST32 "X"
174
175#define SCNd32 "d"
176#define SCNdLEAST32 "d"
177#define SCNdFAST32 "d"
178
179#define SCNi32 "i"
180#define SCNiLEAST32 "i"
181#define SCNiFAST32 "i"
182
183#define SCNo32 "o"
184#define SCNoLEAST32 "o"
185#define SCNoFAST32 "o"
186
187#define SCNu32 "u"
188#define SCNuLEAST32 "u"
189#define SCNuFAST32 "u"
190
191#define SCNx32 "x"
192#define SCNxLEAST32 "x"
193#define SCNxFAST32 "x"
194
195#if INTPTR_MAX == 0x7fffffff
196
197#define PRIdPTR "d"
198#define PRIiPTR "i"
199#define PRIoPTR "o"
200#define PRIuPTR "u"
201#define PRIxPTR "x"
202#define PRIXPTR "X"
203#define SCNdPTR "d"
204#define SCNiPTR "i"
205#define SCNoPTR "o"
206#define SCNuPTR "u"
207#define SCNxPTR "x"
208
209#define PRId64 "lld"
210#define PRIdLEAST64 "lld"
211#define PRIdFAST64 "lld"
212
213#define PRIi64 "lli"
214#define PRIiLEAST64 "lli"
215#define PRIiFAST64 "lli"
216
217#define PRIo64 "llo"
218#define PRIoLEAST64 "llo"
219#define PRIoFAST64 "llo"
220
221#define PRIu64 "llu"
222#define PRIuLEAST64 "llu"
223#define PRIuFAST64 "llu"
224
225#define PRIx64 "llx"
226#define PRIxLEAST64 "llx"
227#define PRIxFAST64 "llx"
228
229#define PRIX64 "llX"
230#define PRIXLEAST64 "llX"
231#define PRIXFAST64 "llX"
232
233#define SCNd64 "lld"
234#define SCNdLEAST64 "lld"
235#define SCNdFAST64 "lld"
236
237#define SCNi64 "lli"
238#define SCNiLEAST64 "lli"
239#define SCNiFAST64 "lli"
240
241#define SCNo64 "llo"
242#define SCNoLEAST64 "llo"
243#define SCNoFAST64 "llo"
244
245#define SCNu64 "llu"
246#define SCNuLEAST64 "llu"
247#define SCNuFAST64 "llu"
248
249#define SCNx64 "llx"
250#define SCNxLEAST64 "llx"
251#define SCNxFAST64 "llx"
252
253#else
254
255#define PRIdPTR "ld"
256#define PRIiPTR "li"
257#define PRIoPTR "lo"
258#define PRIuPTR "lu"
259#define PRIxPTR "lx"
260#define PRIXPTR "lX"
261#define SCNdPTR "ld"
262#define SCNiPTR "li"
263#define SCNoPTR "lo"
264#define SCNuPTR "lu"
265#define SCNxPTR "lx"
266
267#define PRId64 "ld"
268#define PRIdLEAST64 "ld"
269#define PRIdFAST64 "ld"
270
271#define PRIi64 "li"
272#define PRIiLEAST64 "li"
273#define PRIiFAST64 "li"
274
275#define PRIo64 "lo"
276#define PRIoLEAST64 "lo"
277#define PRIoFAST64 "lo"
278
279#define PRIu64 "lu"
280#define PRIuLEAST64 "lu"
281#define PRIuFAST64 "lu"
282
283#define PRIx64 "lx"
284#define PRIxLEAST64 "lx"
285#define PRIxFAST64 "lx"
286
287#define PRIX64 "lX"
288#define PRIXLEAST64 "lX"
289#define PRIXFAST64 "lX"
290
291#define SCNd64 "ld"
292#define SCNdLEAST64 "ld"
293#define SCNdFAST64 "ld"
294
295#define SCNi64 "li"
296#define SCNiLEAST64 "li"
297#define SCNiFAST64 "li"
298
299#define SCNo64 "lo"
300#define SCNoLEAST64 "lo"
301#define SCNoFAST64 "lo"
302
303#define SCNu64 "lu"
304#define SCNuLEAST64 "lu"
305#define SCNuFAST64 "lu"
306
307#define SCNx64 "lx"
308#define SCNxLEAST64 "lx"
309#define SCNxFAST64 "lx"
310
311#endif
312
313#ifdef _HELENOS_SOURCE
314#define UINT8_MIN 0
315#define UINT16_MIN 0
316#define UINT32_MIN 0
317#define UINT64_MIN 0
318#endif
319
320#define PRIdMAX "lld"
321#define PRIiMAX "lli"
322#define PRIoMAX "llo"
323#define PRIuMAX "llu"
324#define PRIxMAX "llx"
325#define PRIXMAX "llX"
326#define SCNdMAX "lld"
327#define SCNiMAX "lli"
328#define SCNoMAX "llo"
329#define SCNuMAX "llu"
330#define SCNxMAX "llx"
331
332#ifdef __cplusplus
333extern "C" {
334#endif
335
336typedef struct {
337 intmax_t quot;
338 intmax_t rem;
339} imaxdiv_t;
340
341intmax_t imaxabs(intmax_t);
342imaxdiv_t imaxdiv(intmax_t, intmax_t);
343intmax_t strtoimax(const char *__restrict__, char **__restrict__, int);
344uintmax_t strtoumax(const char *__restrict__, char **__restrict__, int);
345
346#ifdef __cplusplus
347}
348#endif
349
350#endif
351
352/** @}
353 */
Note: See TracBrowser for help on using the repository browser.