stdint.h revision 1d13a609
1/*
2 * Copyright 2003-2012 Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _STDINT_H_
6#define _STDINT_H_
7
8
9#include <config/types.h>
10
11
12/* Exact-width integer types */
13typedef __haiku_std_int8	int8_t;
14typedef __haiku_std_uint8	uint8_t;
15
16typedef __haiku_std_int16	int16_t;
17typedef __haiku_std_uint16	uint16_t;
18
19typedef __haiku_std_int32	int32_t;
20typedef __haiku_std_uint32	uint32_t;
21
22typedef __haiku_std_int64	int64_t;
23typedef __haiku_std_uint64	uint64_t;
24
25/* Minimum-width integer types */
26typedef int8_t int_least8_t;
27typedef uint8_t uint_least8_t;
28
29typedef int16_t int_least16_t;
30typedef uint16_t uint_least16_t;
31
32typedef int32_t int_least32_t;
33typedef uint32_t uint_least32_t;
34
35typedef int64_t int_least64_t;
36typedef uint64_t uint_least64_t;
37
38/* Fastest minimum-width integer types */
39typedef int32_t int_fast8_t;
40typedef uint32_t uint_fast8_t;
41
42typedef int32_t int_fast16_t;
43typedef uint32_t uint_fast16_t;
44
45typedef int32_t int_fast32_t;
46typedef uint32_t uint_fast32_t;
47
48typedef int64_t int_fast64_t;
49typedef uint64_t uint_fast64_t;
50
51/* Integer types capable of holding object pointers */
52typedef __haiku_saddr_t intptr_t;
53typedef __haiku_addr_t uintptr_t;
54
55/* Greatest-width integer types */
56typedef int64_t intmax_t;
57typedef uint64_t uintmax_t;
58
59/* Limits of exact-width integer types */
60#define INT8_MIN 	(-128)
61#define INT8_MAX 	(127)
62#define UINT8_MAX	(255U)
63
64#define INT16_MIN 	(-32768)
65#define INT16_MAX 	(32767)
66#define UINT16_MAX	(65535U)
67
68#define INT32_MAX	(2147483647)
69#define INT32_MIN 	(-INT32_MAX-1)
70#define UINT32_MAX	(4294967295U)
71
72#if defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ > 4
73#define INT64_MAX	(9223372036854775807UL)
74#define UINT64_MAX	(18446744073709551615UL)
75#else
76#define INT64_MAX	(9223372036854775807ULL)
77#define UINT64_MAX	(18446744073709551615ULL)
78#endif
79#define INT64_MIN	(-INT64_MAX-1)
80
81/* Limits of minimum-width integer types */
82#define INT_LEAST8_MIN  	INT8_MIN
83#define INT_LEAST8_MAX  	INT8_MAX
84#define UINT_LEAST8_MAX 	UINT8_MAX
85
86#define INT_LEAST16_MIN 	INT16_MIN
87#define INT_LEAST16_MAX 	INT16_MAX
88#define UINT_LEAST16_MAX	UINT16_MAX
89
90#define INT_LEAST32_MIN 	INT32_MIN
91#define INT_LEAST32_MAX 	INT32_MAX
92#define UINT_LEAST32_MAX	UINT32_MAX
93
94#define INT_LEAST64_MIN 	INT64_MIN
95#define INT_LEAST64_MAX 	INT64_MAX
96#define UINT_LEAST64_MAX	UINT64_MAX
97
98/* Limits of fastest minimum-width integer types */
99#define INT_FAST8_MIN  	INT8_MIN
100#define INT_FAST8_MAX  	INT8_MAX
101#define UINT_FAST8_MAX 	UINT8_MAX
102
103#define INT_FAST16_MIN 	INT16_MIN
104#define INT_FAST16_MAX 	INT16_MAX
105#define UINT_FAST16_MAX	UINT16_MAX
106
107#define INT_FAST32_MIN 	INT32_MIN
108#define INT_FAST32_MAX 	INT32_MAX
109#define UINT_FAST32_MAX	UINT32_MAX
110
111#define INT_FAST64_MIN 	INT64_MIN
112#define INT_FAST64_MAX 	INT64_MAX
113#define UINT_FAST64_MAX	UINT64_MAX
114
115/* Limits of Integer types capable of holding object pointers */
116#define INTPTR_MIN	__HAIKU_SADDR_MIN
117#define INTPTR_MAX	__HAIKU_SADDR_MAX
118#define UINTPTR_MAX	__HAIKU_ADDR_MAX
119
120/* Limits of Greatest-width integer types */
121#define INTMAX_MIN	INT64_MIN
122#define INTMAX_MAX	INT64_MAX
123#define UINTMAX_MAX	UINT64_MAX
124
125/* Limits of other integer types */
126#define PTRDIFF_MIN __HAIKU_SADDR_MIN
127#define PTRDIFF_MAX __HAIKU_SADDR_MAX
128
129#define SIG_ATOMIC_MIN INT32_MIN
130#define SIG_ATOMIC_MAX INT32_MAX
131
132#define SIZE_MAX 	__HAIKU_ADDR_MAX
133
134#define WINT_MIN 	0
135#define WINT_MAX 	((wint_t)-1)
136
137
138#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
139
140/* Macros of Integer Constant Expressions */
141#define INT8_C(value) 	value
142#define INT16_C(value) 	value
143#define INT32_C(value) 	value
144
145#define UINT8_C(value) 	value ## U
146#define UINT16_C(value) value ## U
147#define UINT32_C(value) value ## U
148
149#if defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ > 4
150#define INT64_C(value)		value ## L
151#define UINT64_C(value) 	value ## UL
152#define INTMAX_C(value) 	value ## L
153#define UINTMAX_C(value)	value ## UL
154#else
155#define INT64_C(value) 		value ## LL
156#define UINT64_C(value) 	value ## ULL
157#define INTMAX_C(value) 	value ## LL
158#define UINTMAX_C(value)	value ## ULL
159#endif
160
161#endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */
162
163
164/* BSD compatibility */
165typedef uint8_t u_int8_t;
166typedef uint16_t u_int16_t;
167typedef uint32_t u_int32_t;
168typedef uint64_t u_int64_t;
169
170
171#endif	/* _STDINT_H_ */
172