1 | /* |
---|
2 | * COPYRIGHT (c) 2004. |
---|
3 | * Ralf Corsepius, Ulm/Germany. |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.org/license/LICENSE. |
---|
8 | * |
---|
9 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | /** @file stdint.h |
---|
13 | * Newlib specific stdint.h |
---|
14 | * |
---|
15 | * @todo - Add fast<N>_t types. |
---|
16 | * @todo - Add support for wint_t types. |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef _STDINT_H |
---|
20 | #define _STDINT_H |
---|
21 | |
---|
22 | #ifdef __cplusplus |
---|
23 | extern "C" { |
---|
24 | #endif |
---|
25 | |
---|
26 | #if defined(__GNUC__) && (__GNUC__ >= 3 ) \ |
---|
27 | && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2 ) |
---|
28 | #define __EXP(x) __##x##__ |
---|
29 | #else |
---|
30 | #define __EXP(x) x |
---|
31 | #include <limits.h> |
---|
32 | #endif |
---|
33 | |
---|
34 | #if __EXP(SCHAR_MAX) == 0x7f |
---|
35 | typedef signed char int8_t ; |
---|
36 | typedef unsigned char uint8_t ; |
---|
37 | #define __int8_t_defined 1 |
---|
38 | #endif |
---|
39 | |
---|
40 | #if __int8_t_defined |
---|
41 | typedef signed char int_least8_t; |
---|
42 | typedef unsigned char uint_least8_t; |
---|
43 | #define __int_least8_t_defined 1 |
---|
44 | #endif |
---|
45 | |
---|
46 | #if __EXP(SHRT_MAX) == 0x7fff |
---|
47 | typedef signed short int16_t; |
---|
48 | typedef unsigned short uint16_t; |
---|
49 | #define __int16_t_defined 1 |
---|
50 | #elif __EXP(INT_MAX) == 0x7fff |
---|
51 | typedef signed int int16_t; |
---|
52 | typedef unsigned int uint16_t; |
---|
53 | #define __int16_t_defined 1 |
---|
54 | #elif __EXP(SCHAR_MAX) == 0x7fff |
---|
55 | typedef signed char int16_t; |
---|
56 | typedef unsigned char uint16_t; |
---|
57 | #define __int16_t_defined 1 |
---|
58 | #endif |
---|
59 | |
---|
60 | #if __int16_t_defined |
---|
61 | typedef int16_t int_least16_t; |
---|
62 | typedef uint16_t uint_least16_t; |
---|
63 | #define __int_least16_t_defined 1 |
---|
64 | |
---|
65 | #ifndef __int_least8_t_defined |
---|
66 | typedef int16_t int_least8_t; |
---|
67 | typedef uint16_t uint_least8_t; |
---|
68 | #define __int_least8_t_defined 1 |
---|
69 | #endif |
---|
70 | #endif |
---|
71 | |
---|
72 | #if __EXP(INT_MAX) == 0x7fffffffL |
---|
73 | typedef signed int int32_t; |
---|
74 | typedef unsigned int uint32_t; |
---|
75 | #define __int32_t_defined 1 |
---|
76 | #elif __EXP(LONG_MAX) == 0x7fffffffL |
---|
77 | typedef signed long int32_t; |
---|
78 | typedef unsigned long uint32_t; |
---|
79 | #define __int32_t_defined 1 |
---|
80 | #define __rtems_long32 1 |
---|
81 | #elif __EXP(SHRT_MAX) == 0x7fffffffL |
---|
82 | typedef signed short int32_t; |
---|
83 | typedef unsigned short uint32_t; |
---|
84 | #define __int32_t_defined 1 |
---|
85 | #elif __EXP(SCHAR_MAX) == 0x7fffffffL |
---|
86 | typedef signed char int32_t; |
---|
87 | typedef unsigned char uint32_t; |
---|
88 | #define __int32_t_defined 1 |
---|
89 | #endif |
---|
90 | |
---|
91 | #if __int32_t_defined |
---|
92 | typedef int32_t int_least32_t; |
---|
93 | typedef uint32_t uint_least32_t; |
---|
94 | #define __int_least32_t_defined 1 |
---|
95 | |
---|
96 | #ifndef __int_least8_t_defined |
---|
97 | typedef int32_t int_least8_t; |
---|
98 | typedef uint32_t uint_least8_t; |
---|
99 | #define __int_least8_t_defined 1 |
---|
100 | #endif |
---|
101 | |
---|
102 | #ifndef __int_least16_t_defined |
---|
103 | typedef int32_t int_least16_t; |
---|
104 | typedef uint32_t uint_least16_t; |
---|
105 | #define __int_least16_t_defined 1 |
---|
106 | #endif |
---|
107 | #endif |
---|
108 | |
---|
109 | #if __EXP(LONG_MAX) > 0x7fffffff |
---|
110 | typedef signed long int64_t; |
---|
111 | typedef unsigned long uint64_t; |
---|
112 | #define __int64_t_defined 1 |
---|
113 | #define __rtems_long64 1 |
---|
114 | #elif defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) |
---|
115 | typedef signed long long int64_t; |
---|
116 | typedef unsigned long long uint64_t; |
---|
117 | #define __int64_t_defined 1 |
---|
118 | #define __rtems_longlong64 1 |
---|
119 | #elif defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) |
---|
120 | typedef signed long long int64_t; |
---|
121 | typedef unsigned long long uint64_t; |
---|
122 | #define __int64_t_defined 1 |
---|
123 | #define __rtems_longlong64 1 |
---|
124 | #elif __EXP(INT_MAX) > 0x7fffffff |
---|
125 | typedef signed int int64_t; |
---|
126 | typedef unsigned int uint64_t; |
---|
127 | #define __int64_t_defined 1 |
---|
128 | #endif |
---|
129 | |
---|
130 | #if __int64_t_defined |
---|
131 | typedef int64_t int_least64_t; |
---|
132 | typedef uint64_t uint_least64_t; |
---|
133 | #define __int_least64_t_defined 1 |
---|
134 | |
---|
135 | #ifndef __int_least8_t_defined |
---|
136 | typedef int64_t int_least8_t; |
---|
137 | typedef uint64_t uint_least8_t; |
---|
138 | #define __int_least8_t_defined 1 |
---|
139 | #endif |
---|
140 | |
---|
141 | #ifndef __int_least16_t_defined |
---|
142 | typedef int64_t int_least16_t; |
---|
143 | typedef uint64_t uint_least16_t; |
---|
144 | #define __int_least16_t_defined 1 |
---|
145 | #endif |
---|
146 | |
---|
147 | #ifndef __int_least32_t_defined |
---|
148 | typedef int64_t int_least32_t; |
---|
149 | typedef uint64_t uint_least32_t; |
---|
150 | #define __int_least32_t_defined 1 |
---|
151 | #endif |
---|
152 | #endif |
---|
153 | |
---|
154 | #if __rtems_longlong64 |
---|
155 | typedef signed long long intmax_t; |
---|
156 | typedef unsigned long long uintmax_t; |
---|
157 | #else |
---|
158 | typedef signed long intmax_t; |
---|
159 | typedef unsigned long uintmax_t; |
---|
160 | #endif |
---|
161 | |
---|
162 | typedef signed long intptr_t; |
---|
163 | typedef unsigned long uintptr_t; |
---|
164 | |
---|
165 | /* Limits of Specified-Width Integer Types */ |
---|
166 | |
---|
167 | #if __int8_t_defined |
---|
168 | #define INT8_MIN -128 |
---|
169 | #define INT8_MAX 127 |
---|
170 | #define UINT8_MAX 255 |
---|
171 | #endif |
---|
172 | |
---|
173 | #if __int_least8_t_defined |
---|
174 | #define INTLEAST8_MIN -128 |
---|
175 | #define INTLEAST8_MAX 127 |
---|
176 | #define UINTLEAST8_MAX 255 |
---|
177 | #else |
---|
178 | #error required type int_least8_t missing |
---|
179 | #endif |
---|
180 | |
---|
181 | #if __int16_t_defined |
---|
182 | #define INT16_MIN -32768 |
---|
183 | #define INT16_MAX 32767 |
---|
184 | #define UINT16_MAX 65535 |
---|
185 | #endif |
---|
186 | |
---|
187 | #if __int_least16_t_defined |
---|
188 | #define INTLEAST16_MIN -32768 |
---|
189 | #define INTLEAST16_MAX 32767 |
---|
190 | #define UINTLEAST16_MAX 65535 |
---|
191 | #else |
---|
192 | #error required type int_least16_t missing |
---|
193 | #endif |
---|
194 | |
---|
195 | #if __int32_t_defined |
---|
196 | #define INT32_MIN -2147483648 |
---|
197 | #define INT32_MAX 2147483647 |
---|
198 | #define UINT32_MAX 4294967295 |
---|
199 | #endif |
---|
200 | |
---|
201 | #if __int_least32_t_defined |
---|
202 | #define INTLEAST32_MIN -2147483648 |
---|
203 | #define INTLEAST32_MAX 2147483647 |
---|
204 | #define UINTLEAST32_MAX 4294967295 |
---|
205 | #else |
---|
206 | #error required type int_least32_t missing |
---|
207 | #endif |
---|
208 | |
---|
209 | #if __int64_t_defined |
---|
210 | #define INT64_MIN -9223372036854775808 |
---|
211 | #define INT64_MAX 9223372036854775807 |
---|
212 | #define UINT64_MAX 18446744073709551615 |
---|
213 | #endif |
---|
214 | |
---|
215 | #if __int_least64_t_defined |
---|
216 | #define INTLEAST64_MIN -9223372036854775808 |
---|
217 | #define INTLEAST64_MAX 9223372036854775807 |
---|
218 | #define UINTLEAST64_MAX 18446744073709551615 |
---|
219 | #endif |
---|
220 | |
---|
221 | /* This must match size_t in stddef.h, currently long unsigned int */ |
---|
222 | #define SIZE_MIN (-__EXP(LONG_MAX) - 1L) |
---|
223 | #define SIZE_MAX __EXP(LONG_MAX) |
---|
224 | |
---|
225 | /* This must match sig_atomic_t in <signal.h> (currently int) */ |
---|
226 | #define SIG_ATOMIC_MIN (-__EXP(INT_MAX) - 1) |
---|
227 | #define SIG_ATOMIC_MAX __EXP(INT_MAX) |
---|
228 | |
---|
229 | /* This must match ptrdiff_t in <stddef.h> (currently long int) */ |
---|
230 | #define PTRDIFF_MIN (-__EXP(LONG_MAX) - 1L) |
---|
231 | #define PTHDIFF_MAX __EXT(LONG_MAX) |
---|
232 | |
---|
233 | #undef __EXP |
---|
234 | |
---|
235 | /* Macros for minimum-width integer constant expressions */ |
---|
236 | |
---|
237 | #define INT8_C(x) x |
---|
238 | #define UINT8_C(x) x##U |
---|
239 | |
---|
240 | #define INT16_C(x) x |
---|
241 | #define UINT16_C(x) x##U |
---|
242 | |
---|
243 | #if __rtems_long32 |
---|
244 | #define INT32_C(x) x##L |
---|
245 | #define UINT32_C(x) x##UL |
---|
246 | #else |
---|
247 | #define INT32_C(x) x |
---|
248 | #define UINT32_C(x) x##U |
---|
249 | #endif |
---|
250 | |
---|
251 | /* Macros for greatest-width integer constant expression */ |
---|
252 | #if __int64_t_defined |
---|
253 | #if __rtems_longlong64 |
---|
254 | #define INT64_C(x) x##LL |
---|
255 | #define UINT64_C(x) x##ULL |
---|
256 | #else |
---|
257 | #define INT64_C(x) x##L |
---|
258 | #define UINT64_C(x) x##UL |
---|
259 | #endif |
---|
260 | #endif |
---|
261 | |
---|
262 | #if __rtems_longlong64 |
---|
263 | #define INTMAX_C(x) x##LL |
---|
264 | #define UINTMAX_C(x) x##ULL |
---|
265 | #else |
---|
266 | #define INTMAX_C(x) x##L |
---|
267 | #define UINTMAX_C(x) x##UL |
---|
268 | #endif |
---|
269 | |
---|
270 | |
---|
271 | #ifdef __cplusplus |
---|
272 | } |
---|
273 | #endif |
---|
274 | |
---|
275 | #endif |
---|