xref: /haiku/headers/posix/stdint.h (revision 32a71a00aab29e272bd85e29061e1cf6431cdc77)
1 /*
2  * Copyright 2003-2017 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 */
13 typedef __haiku_std_int8	int8_t;
14 typedef __haiku_std_uint8	uint8_t;
15 
16 typedef __haiku_std_int16	int16_t;
17 typedef __haiku_std_uint16	uint16_t;
18 
19 typedef __haiku_std_int32	int32_t;
20 typedef __haiku_std_uint32	uint32_t;
21 
22 typedef __haiku_std_int64	int64_t;
23 typedef __haiku_std_uint64	uint64_t;
24 
25 /* Minimum-width integer types */
26 typedef int8_t int_least8_t;
27 typedef uint8_t uint_least8_t;
28 
29 typedef int16_t int_least16_t;
30 typedef uint16_t uint_least16_t;
31 
32 typedef int32_t int_least32_t;
33 typedef uint32_t uint_least32_t;
34 
35 typedef int64_t int_least64_t;
36 typedef uint64_t uint_least64_t;
37 
38 /* Fastest minimum-width integer types */
39 typedef int32_t int_fast8_t;
40 typedef uint32_t uint_fast8_t;
41 
42 typedef int32_t int_fast16_t;
43 typedef uint32_t uint_fast16_t;
44 
45 typedef int32_t int_fast32_t;
46 typedef uint32_t uint_fast32_t;
47 
48 typedef int64_t int_fast64_t;
49 typedef uint64_t uint_fast64_t;
50 
51 /* Integer types capable of holding object pointers */
52 typedef __haiku_saddr_t intptr_t;
53 typedef __haiku_addr_t uintptr_t;
54 
55 /* Greatest-width integer types */
56 typedef int64_t intmax_t;
57 typedef 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	(255)
63 
64 #define INT16_MIN 	(-32768)
65 #define INT16_MAX 	(32767)
66 #define UINT16_MAX	(65535)
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	(9223372036854775807L)
74 #define UINT64_MAX	(18446744073709551615UL)
75 #else
76 #define INT64_MAX	(9223372036854775807LL)
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 /* Macros of Integer Constant Expressions */
139 #define INT8_C(value) 	value
140 #define INT16_C(value) 	value
141 #define INT32_C(value) 	value
142 
143 #define UINT8_C(value) 	value
144 #define UINT16_C(value) value
145 #define UINT32_C(value) value ## U
146 
147 #if defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ > 4
148 #define INT64_C(value)		value ## L
149 #define UINT64_C(value) 	value ## UL
150 #define INTMAX_C(value) 	value ## L
151 #define UINTMAX_C(value)	value ## UL
152 #else
153 #define INT64_C(value) 		value ## LL
154 #define UINT64_C(value) 	value ## ULL
155 #define INTMAX_C(value) 	value ## LL
156 #define UINTMAX_C(value)	value ## ULL
157 #endif
158 
159 
160 /* BSD compatibility */
161 typedef uint8_t u_int8_t;
162 typedef uint16_t u_int16_t;
163 typedef uint32_t u_int32_t;
164 typedef uint64_t u_int64_t;
165 
166 
167 #endif	/* _STDINT_H_ */
168