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

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

Make some libc and libposix headers usable in C++

These headers either get included from standard C++ headers,
or are standard themselves, which means any unnamespaced nonstandard
identifiers are a problem. This commit attempts to fix those
issues, and removes hacks previously used in libcpp to work around it.

  • Property mode set to 100644
File size: 7.9 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#include <_bits/decls.h>
46
47/*
48 * We assume the -helenos target is in use, which means the following assignment:
49 *
50 * 32b 64b
51 * int8_t unsigned char unsigned char
52 * int16_t short short
53 * int32_t int int
54 * int64_t long long long
55 * intptr_t int long
56 * size_t unsigned int unsigned long
57 * ptrdiff_t int long
58 * intmax_t long long long long
59 *
60 * intleast*_t same as int*_t
61 * intfast*_t at least int, otherwise same as int*_t
62 */
63
64#define PRId8 "hhd"
65#define PRIdLEAST8 "hhd"
66#define PRIdFAST8 "d"
67
68#define PRIi8 "hhi"
69#define PRIiLEAST8 "hhi"
70#define PRIiFAST8 "i"
71
72#define PRIo8 "hho"
73#define PRIoLEAST8 "hho"
74#define PRIoFAST8 "o"
75
76#define PRIu8 "hhu"
77#define PRIuLEAST8 "hhu"
78#define PRIuFAST8 "u"
79
80#define PRIx8 "hhx"
81#define PRIxLEAST8 "hhx"
82#define PRIxFAST8 "x"
83
84#define PRIX8 "hhX"
85#define PRIXLEAST8 "hhX"
86#define PRIXFAST8 "X"
87
88#define SCNd8 "hhd"
89#define SCNdLEAST8 "hhd"
90#define SCNdFAST8 "d"
91
92#define SCNi8 "hhi"
93#define SCNiLEAST8 "hhi"
94#define SCNiFAST8 "i"
95
96#define SCNo8 "hho"
97#define SCNoLEAST8 "hho"
98#define SCNoFAST8 "o"
99
100#define SCNu8 "hhu"
101#define SCNuLEAST8 "hhu"
102#define SCNuFAST8 "u"
103
104#define SCNx8 "hhx"
105#define SCNxLEAST8 "hhx"
106#define SCNxFAST8 "x"
107
108#define PRId16 "hd"
109#define PRIdLEAST16 "hd"
110#define PRIdFAST16 "d"
111
112#define PRIi16 "hi"
113#define PRIiLEAST16 "hi"
114#define PRIiFAST16 "i"
115
116#define PRIo16 "ho"
117#define PRIoLEAST16 "ho"
118#define PRIoFAST16 "o"
119
120#define PRIu16 "hu"
121#define PRIuLEAST16 "hu"
122#define PRIuFAST16 "u"
123
124#define PRIx16 "hx"
125#define PRIxLEAST16 "hx"
126#define PRIxFAST16 "x"
127
128#define PRIX16 "hX"
129#define PRIXLEAST16 "hX"
130#define PRIXFAST16 "X"
131
132#define SCNd16 "hd"
133#define SCNdLEAST16 "hd"
134#define SCNdFAST16 "d"
135
136#define SCNi16 "hi"
137#define SCNiLEAST16 "hi"
138#define SCNiFAST16 "i"
139
140#define SCNo16 "ho"
141#define SCNoLEAST16 "ho"
142#define SCNoFAST16 "o"
143
144#define SCNu16 "hu"
145#define SCNuLEAST16 "hu"
146#define SCNuFAST16 "u"
147
148#define SCNx16 "hx"
149#define SCNxLEAST16 "hx"
150#define SCNxFAST16 "x"
151
152#define PRId32 "d"
153#define PRIdLEAST32 "d"
154#define PRIdFAST32 "d"
155
156#define PRIi32 "i"
157#define PRIiLEAST32 "i"
158#define PRIiFAST32 "i"
159
160#define PRIo32 "o"
161#define PRIoLEAST32 "o"
162#define PRIoFAST32 "o"
163
164#define PRIu32 "u"
165#define PRIuLEAST32 "u"
166#define PRIuFAST32 "u"
167
168#define PRIx32 "x"
169#define PRIxLEAST32 "x"
170#define PRIxFAST32 "x"
171
172#define PRIX32 "X"
173#define PRIXLEAST32 "X"
174#define PRIXFAST32 "X"
175
176#define SCNd32 "d"
177#define SCNdLEAST32 "d"
178#define SCNdFAST32 "d"
179
180#define SCNi32 "i"
181#define SCNiLEAST32 "i"
182#define SCNiFAST32 "i"
183
184#define SCNo32 "o"
185#define SCNoLEAST32 "o"
186#define SCNoFAST32 "o"
187
188#define SCNu32 "u"
189#define SCNuLEAST32 "u"
190#define SCNuFAST32 "u"
191
192#define SCNx32 "x"
193#define SCNxLEAST32 "x"
194#define SCNxFAST32 "x"
195
196#if INTPTR_MAX == 0x7fffffff
197
198#define PRIdPTR "d"
199#define PRIiPTR "i"
200#define PRIoPTR "o"
201#define PRIuPTR "u"
202#define PRIxPTR "x"
203#define PRIXPTR "X"
204#define SCNdPTR "d"
205#define SCNiPTR "i"
206#define SCNoPTR "o"
207#define SCNuPTR "u"
208#define SCNxPTR "x"
209
210#define PRId64 "lld"
211#define PRIdLEAST64 "lld"
212#define PRIdFAST64 "lld"
213
214#define PRIi64 "lli"
215#define PRIiLEAST64 "lli"
216#define PRIiFAST64 "lli"
217
218#define PRIo64 "llo"
219#define PRIoLEAST64 "llo"
220#define PRIoFAST64 "llo"
221
222#define PRIu64 "llu"
223#define PRIuLEAST64 "llu"
224#define PRIuFAST64 "llu"
225
226#define PRIx64 "llx"
227#define PRIxLEAST64 "llx"
228#define PRIxFAST64 "llx"
229
230#define PRIX64 "llX"
231#define PRIXLEAST64 "llX"
232#define PRIXFAST64 "llX"
233
234#define SCNd64 "lld"
235#define SCNdLEAST64 "lld"
236#define SCNdFAST64 "lld"
237
238#define SCNi64 "lli"
239#define SCNiLEAST64 "lli"
240#define SCNiFAST64 "lli"
241
242#define SCNo64 "llo"
243#define SCNoLEAST64 "llo"
244#define SCNoFAST64 "llo"
245
246#define SCNu64 "llu"
247#define SCNuLEAST64 "llu"
248#define SCNuFAST64 "llu"
249
250#define SCNx64 "llx"
251#define SCNxLEAST64 "llx"
252#define SCNxFAST64 "llx"
253
254#else
255
256#define PRIdPTR "ld"
257#define PRIiPTR "li"
258#define PRIoPTR "lo"
259#define PRIuPTR "lu"
260#define PRIxPTR "lx"
261#define PRIXPTR "lX"
262#define SCNdPTR "ld"
263#define SCNiPTR "li"
264#define SCNoPTR "lo"
265#define SCNuPTR "lu"
266#define SCNxPTR "lx"
267
268#define PRId64 "ld"
269#define PRIdLEAST64 "ld"
270#define PRIdFAST64 "ld"
271
272#define PRIi64 "li"
273#define PRIiLEAST64 "li"
274#define PRIiFAST64 "li"
275
276#define PRIo64 "lo"
277#define PRIoLEAST64 "lo"
278#define PRIoFAST64 "lo"
279
280#define PRIu64 "lu"
281#define PRIuLEAST64 "lu"
282#define PRIuFAST64 "lu"
283
284#define PRIx64 "lx"
285#define PRIxLEAST64 "lx"
286#define PRIxFAST64 "lx"
287
288#define PRIX64 "lX"
289#define PRIXLEAST64 "lX"
290#define PRIXFAST64 "lX"
291
292#define SCNd64 "ld"
293#define SCNdLEAST64 "ld"
294#define SCNdFAST64 "ld"
295
296#define SCNi64 "li"
297#define SCNiLEAST64 "li"
298#define SCNiFAST64 "li"
299
300#define SCNo64 "lo"
301#define SCNoLEAST64 "lo"
302#define SCNoFAST64 "lo"
303
304#define SCNu64 "lu"
305#define SCNuLEAST64 "lu"
306#define SCNuFAST64 "lu"
307
308#define SCNx64 "lx"
309#define SCNxLEAST64 "lx"
310#define SCNxFAST64 "lx"
311
312#endif
313
314#define PRIdMAX "lld"
315#define PRIiMAX "lli"
316#define PRIoMAX "llo"
317#define PRIuMAX "llu"
318#define PRIxMAX "llx"
319#define PRIXMAX "llX"
320#define SCNdMAX "lld"
321#define SCNiMAX "lli"
322#define SCNoMAX "llo"
323#define SCNuMAX "llu"
324#define SCNxMAX "llx"
325
326#if defined(_HELENOS_SOURCE) && !defined(__cplusplus)
327#define PRIdn PRIdPTR /**< Format for native_t. */
328#define PRIun PRIuPTR /**< Format for sysarg_t. */
329#define PRIxn PRIxPTR /**< Format for hexadecimal sysarg_t. */
330#endif
331
332__C_DECLS_BEGIN;
333
334typedef struct {
335 intmax_t quot;
336 intmax_t rem;
337} imaxdiv_t;
338
339intmax_t imaxabs(intmax_t);
340imaxdiv_t imaxdiv(intmax_t, intmax_t);
341intmax_t strtoimax(const char *__restrict__, char **__restrict__, int);
342uintmax_t strtoumax(const char *__restrict__, char **__restrict__, int);
343intmax_t wcstoimax(const wchar_t *__restrict__, wchar_t **__restrict__, int);
344uintmax_t wcstoumax(const wchar_t *__restrict__, wchar_t **__restrict__, int);
345
346__C_DECLS_END;
347
348#endif
349
350/** @}
351 */
Note: See TracBrowser for help on using the repository browser.