source: mainline/abi/include/inttypes.h

Last change on this file was 28a5ebd, checked in by Martin Decky <martin@…>, 5 years ago

Use char32_t instead of wchat_t to represent UTF-32 strings

The intention of the native HelenOS string API has been always to
support Unicode in the UTF-8 and UTF-32 encodings as the sole character
representations and ignore the obsolete mess of older single-byte and
multibyte character encodings. Before C11, the wchar_t type has been
slightly misused for the purpose of the UTF-32 strings. The newer
char32_t type is obviously a much more suitable option. The standard
defines char32_t as uint_least32_t, thus we can take the liberty to fix
it to uint32_t.

To maintain compatilibity with the C Standard, the putwchar(wchar_t)
functions has been replaced by our custom putuchar(char32_t) functions
where appropriate.

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