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