1 | /** |
---|
2 | * @file sys/_stdint.h |
---|
3 | */ |
---|
4 | |
---|
5 | /* |
---|
6 | * COPYRIGHT (c) 2004. |
---|
7 | * Ralf Corsepius, Ulm/Germany. |
---|
8 | * |
---|
9 | * The license and distribution terms for this file may be |
---|
10 | * found in the file LICENSE in this distribution or at |
---|
11 | * http://www.rtems.org/license/LICENSE. |
---|
12 | * |
---|
13 | * $Id$ |
---|
14 | */ |
---|
15 | |
---|
16 | #ifndef __sys_stdint_h |
---|
17 | #define __sys_stdint_h |
---|
18 | |
---|
19 | #ifdef __cplusplus |
---|
20 | extern "C" { |
---|
21 | #endif |
---|
22 | |
---|
23 | #if defined(__GNUC__) && (__GNUC__ >= 3 ) \ |
---|
24 | && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2 ) |
---|
25 | #define __EXP(x) __##x##__ |
---|
26 | #else |
---|
27 | #define __EXP(x) x |
---|
28 | #include <limits.h> |
---|
29 | #endif |
---|
30 | |
---|
31 | #if __EXP(SCHAR_MAX) == 0x7f |
---|
32 | typedef signed char int8_t ; |
---|
33 | typedef unsigned char uint8_t ; |
---|
34 | #define __int8_t_defined 1 |
---|
35 | #endif |
---|
36 | |
---|
37 | #if __int8_t_defined |
---|
38 | typedef signed char int_least8_t; |
---|
39 | typedef unsigned char uint_least8_t; |
---|
40 | #define __int_least8_t_defined 1 |
---|
41 | #endif |
---|
42 | |
---|
43 | #if __EXP(SHRT_MAX) == 0x7fff |
---|
44 | typedef signed short int16_t; |
---|
45 | typedef unsigned short uint16_t; |
---|
46 | #define __int16_t_defined 1 |
---|
47 | #elif __EXP(INT_MAX) == 0x7fff |
---|
48 | typedef signed int int16_t; |
---|
49 | typedef unsigned int uint16_t; |
---|
50 | #define __int16_t_defined 1 |
---|
51 | #elif __EXP(SCHAR_MAX) == 0x7fff |
---|
52 | typedef signed char int16_t; |
---|
53 | typedef unsigned char uint16_t; |
---|
54 | #define __int16_t_defined 1 |
---|
55 | #endif |
---|
56 | |
---|
57 | #if __int16_t_defined |
---|
58 | typedef int16_t int_least16_t; |
---|
59 | typedef uint16_t uint_least16_t; |
---|
60 | #define __int_least16_t_defined 1 |
---|
61 | |
---|
62 | #ifndef __int_least8_t_defined |
---|
63 | typedef int16_t int_least8_t; |
---|
64 | typedef uint16_t uint_least8_t; |
---|
65 | #define __int_least8_t_defined 1 |
---|
66 | #endif |
---|
67 | #endif |
---|
68 | |
---|
69 | #if __EXP(INT_MAX) == 0x7fffffffL |
---|
70 | typedef signed int int32_t; |
---|
71 | typedef unsigned int uint32_t; |
---|
72 | #define __int32_t_defined 1 |
---|
73 | #elif __EXP(LONG_MAX) == 0x7fffffffL |
---|
74 | typedef signed long int32_t; |
---|
75 | typedef unsigned long uint32_t; |
---|
76 | #define __int32_t_defined 1 |
---|
77 | #define __rtems_long32 1 |
---|
78 | #elif __EXP(SHRT_MAX) == 0x7fffffffL |
---|
79 | typedef signed short int32_t; |
---|
80 | typedef unsigned short uint32_t; |
---|
81 | #define __int32_t_defined 1 |
---|
82 | #elif __EXP(SCHAR_MAX) == 0x7fffffffL |
---|
83 | typedef signed char int32_t; |
---|
84 | typedef unsigned char uint32_t; |
---|
85 | #define INT32_C(x) x |
---|
86 | #define __int32_t_defined 1 |
---|
87 | #endif |
---|
88 | |
---|
89 | #if __int32_t_defined |
---|
90 | typedef int32_t int_least32_t; |
---|
91 | typedef uint32_t uint_least32_t; |
---|
92 | #define __int_least32_t_defined 1 |
---|
93 | |
---|
94 | #ifndef __int_least8_t_defined |
---|
95 | typedef int32_t int_least8_t; |
---|
96 | typedef uint32_t uint_least8_t; |
---|
97 | #define __int_least8_t_defined 1 |
---|
98 | #endif |
---|
99 | |
---|
100 | #ifndef __int_least16_t_defined |
---|
101 | typedef int32_t int_least16_t; |
---|
102 | typedef uint32_t uint_least16_t; |
---|
103 | #define __int_least16_t_defined 1 |
---|
104 | #endif |
---|
105 | #endif |
---|
106 | |
---|
107 | #if __EXP(LONG_MAX) > 0x7fffffff |
---|
108 | typedef signed long int64_t; |
---|
109 | typedef unsigned long uint64_t; |
---|
110 | #define __int64_t_defined 1 |
---|
111 | #define __rtems_long64 1 |
---|
112 | #elif __EXP(LONG_LONG_MAX) > 0x7fffffff |
---|
113 | typedef signed long long int64_t; |
---|
114 | typedef unsigned long long uint64_t; |
---|
115 | #define __int64_t_defined 1 |
---|
116 | #define __rtems_longlong64 1 |
---|
117 | #elif __EXP(INT_MAX) > 0x7fffffff |
---|
118 | typedef signed int int64_t; |
---|
119 | typedef unsigned int uint64_t; |
---|
120 | #define __int64_t_defined 1 |
---|
121 | #endif |
---|
122 | |
---|
123 | #if __int64_t_defined |
---|
124 | typedef int64_t int_least64_t; |
---|
125 | typedef uint64_t uint_least64_t; |
---|
126 | #define __int_least64_t_defined 1 |
---|
127 | |
---|
128 | #ifndef __int_least8_t_defined |
---|
129 | typedef int64_t int_least8_t; |
---|
130 | typedef uint64_t uint_least8_t; |
---|
131 | #define __int_least8_t_defined 1 |
---|
132 | #endif |
---|
133 | |
---|
134 | #ifndef __int_least16_t_defined |
---|
135 | typedef int64_t int_least16_t; |
---|
136 | typedef uint64_t uint_least16_t; |
---|
137 | #define __int_least16_t_defined 1 |
---|
138 | #endif |
---|
139 | |
---|
140 | #ifndef __int_least32_t_defined |
---|
141 | typedef int64_t int_least32_t; |
---|
142 | typedef uint64_t uint_least32_t; |
---|
143 | #define __int_least32_t_defined 1 |
---|
144 | #endif |
---|
145 | #endif |
---|
146 | |
---|
147 | #if __rtems_longlong64 |
---|
148 | typedef signed long long intmax_t; |
---|
149 | typedef unsigned long long uintmax_t; |
---|
150 | #else |
---|
151 | typedef signed long intmax_t; |
---|
152 | typedef unsigned long uintmax_t; |
---|
153 | #endif |
---|
154 | |
---|
155 | typedef signed long intptr_t; |
---|
156 | typedef unsigned long uintptr_t; |
---|
157 | |
---|
158 | /* Limits of Specified-Width Integer Types */ |
---|
159 | |
---|
160 | #if __int8_t_defined |
---|
161 | #define INT8_MIN -128 |
---|
162 | #define INT8_MAX 127 |
---|
163 | #define UINT8_MAX 255 |
---|
164 | #endif |
---|
165 | |
---|
166 | #if __int_least8_t_defined |
---|
167 | #define INTLEAST8_MIN -128 |
---|
168 | #define INTLEAST8_MAX 127 |
---|
169 | #define UINTLEAST8_MAX 255 |
---|
170 | #else |
---|
171 | #error required type int_least8_t missing |
---|
172 | #endif |
---|
173 | |
---|
174 | #if __int16_t_defined |
---|
175 | #define INT16_MIN -32768 |
---|
176 | #define INT16_MAX 32767 |
---|
177 | #define UINT16_MAX 65535 |
---|
178 | #endif |
---|
179 | |
---|
180 | #if __int_least16_t_defined |
---|
181 | #define INTLEAST16_MIN -32768 |
---|
182 | #define INTLEAST16_MAX 32767 |
---|
183 | #define UINTLEAST16_MAX 65535 |
---|
184 | #else |
---|
185 | #error required type int_least16_t missing |
---|
186 | #endif |
---|
187 | |
---|
188 | #if __int32_t_defined |
---|
189 | #define INT32_MIN -2147483648 |
---|
190 | #define INT32_MAX 2147483647 |
---|
191 | #define UINT32_MAX 4294967295 |
---|
192 | #endif |
---|
193 | |
---|
194 | #if __int_least32_t_defined |
---|
195 | #define INTLEAST32_MIN -2147483648 |
---|
196 | #define INTLEAST32_MAX 2147483647 |
---|
197 | #define UINTLEAST32_MAX 4294967295 |
---|
198 | #else |
---|
199 | #error required type int_least32_t missing |
---|
200 | #endif |
---|
201 | |
---|
202 | #if __int64_t_defined |
---|
203 | #define INT64_MIN -9223372036854775808 |
---|
204 | #define INT64_MAX 9223372036854775807 |
---|
205 | #define UINT64_MAX 18446744073709551615 |
---|
206 | #endif |
---|
207 | |
---|
208 | #if __int_least64_t_defined |
---|
209 | #define INTLEAST64_MIN -9223372036854775808 |
---|
210 | #define INTLEAST64_MAX 9223372036854775807 |
---|
211 | #define UINTLEAST64_MAX 18446744073709551615 |
---|
212 | #endif |
---|
213 | |
---|
214 | #undef __EXP |
---|
215 | |
---|
216 | #ifdef __cplusplus |
---|
217 | } |
---|
218 | #endif |
---|
219 | |
---|
220 | #endif /*__sys_stdint_h */ |
---|