xref: /nrf52832-nimble/rt-thread/components/libc/compilers/minilibc/stdint.h (revision 042d53a763ad75cb1465103098bb88c245d95138)
1 /*
2  * Copyright (c) 2006-2018, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  */
9 /*
10  * ISO C Standard:  7.18  Integer types  <stdint.h>
11  */
12 
13 #ifndef __STDINT_H__
14 #define __STDINT_H__
15 
16 /* 7.8.1.1 Exact-width integer types */
17 
18 #ifdef __INT8_TYPE__
19 typedef __INT8_TYPE__ int8_t;
20 #endif
21 #ifdef __INT16_TYPE__
22 typedef __INT16_TYPE__ int16_t;
23 #endif
24 #ifdef __INT32_TYPE__
25 typedef __INT32_TYPE__ int32_t;
26 #endif
27 #ifdef __INT64_TYPE__
28 typedef __INT64_TYPE__ int64_t;
29 #endif
30 #ifdef __UINT8_TYPE__
31 typedef __UINT8_TYPE__ uint8_t;
32 #endif
33 #ifdef __UINT16_TYPE__
34 typedef __UINT16_TYPE__ uint16_t;
35 #endif
36 #ifdef __UINT32_TYPE__
37 typedef __UINT32_TYPE__ uint32_t;
38 #endif
39 #ifdef __UINT64_TYPE__
40 typedef __UINT64_TYPE__ uint64_t;
41 #endif
42 
43 /* 7.8.1.2 Minimum-width integer types */
44 
45 typedef __INT_LEAST8_TYPE__ int_least8_t;
46 typedef __INT_LEAST16_TYPE__ int_least16_t;
47 typedef __INT_LEAST32_TYPE__ int_least32_t;
48 typedef __INT_LEAST64_TYPE__ int_least64_t;
49 typedef __UINT_LEAST8_TYPE__ uint_least8_t;
50 typedef __UINT_LEAST16_TYPE__ uint_least16_t;
51 typedef __UINT_LEAST32_TYPE__ uint_least32_t;
52 typedef __UINT_LEAST64_TYPE__ uint_least64_t;
53 
54 /* 7.8.1.3 Fastest minimum-width integer types */
55 
56 typedef __INT_FAST8_TYPE__ int_fast8_t;
57 typedef __INT_FAST16_TYPE__ int_fast16_t;
58 typedef __INT_FAST32_TYPE__ int_fast32_t;
59 typedef __INT_FAST64_TYPE__ int_fast64_t;
60 typedef __UINT_FAST8_TYPE__ uint_fast8_t;
61 typedef __UINT_FAST16_TYPE__ uint_fast16_t;
62 typedef __UINT_FAST32_TYPE__ uint_fast32_t;
63 typedef __UINT_FAST64_TYPE__ uint_fast64_t;
64 
65 /* 7.8.1.4 Integer types capable of holding object pointers */
66 
67 #ifdef __INTPTR_TYPE__
68 typedef __INTPTR_TYPE__ intptr_t;
69 #endif
70 #ifdef __UINTPTR_TYPE__
71 typedef __UINTPTR_TYPE__ uintptr_t;
72 #endif
73 
74 /* 7.8.1.5 Greatest-width integer types */
75 
76 typedef __INTMAX_TYPE__ intmax_t;
77 typedef __UINTMAX_TYPE__ uintmax_t;
78 
79 #if (!defined __cplusplus || __cplusplus >= 201103L \
80      || defined __STDC_LIMIT_MACROS)
81 
82 /*
83  * 7.18.2 Limits of specified-width integer types.
84  *
85  * The following object-like macros specify the minimum and maximum limits
86  * of integer types corresponding to the typedef names defined above.
87  */
88 
89 /* 7.18.2.1 Limits of exact-width integer types */
90 
91 #ifdef __INT8_MAX__
92 # undef INT8_MAX
93 # define INT8_MAX __INT8_MAX__
94 # undef INT8_MIN
95 # define INT8_MIN (-INT8_MAX - 1)
96 #endif
97 #ifdef __UINT8_MAX__
98 # undef UINT8_MAX
99 # define UINT8_MAX __UINT8_MAX__
100 #endif
101 #ifdef __INT16_MAX__
102 # undef INT16_MAX
103 # define INT16_MAX __INT16_MAX__
104 # undef INT16_MIN
105 # define INT16_MIN (-INT16_MAX - 1)
106 #endif
107 #ifdef __UINT16_MAX__
108 # undef UINT16_MAX
109 # define UINT16_MAX __UINT16_MAX__
110 #endif
111 #ifdef __INT32_MAX__
112 # undef INT32_MAX
113 # define INT32_MAX __INT32_MAX__
114 # undef INT32_MIN
115 # define INT32_MIN (-INT32_MAX - 1)
116 #endif
117 #ifdef __UINT32_MAX__
118 # undef UINT32_MAX
119 # define UINT32_MAX __UINT32_MAX__
120 #endif
121 #ifdef __INT64_MAX__
122 # undef INT64_MAX
123 # define INT64_MAX __INT64_MAX__
124 # undef INT64_MIN
125 # define INT64_MIN (-INT64_MAX - 1)
126 #endif
127 #ifdef __UINT64_MAX__
128 # undef UINT64_MAX
129 # define UINT64_MAX __UINT64_MAX__
130 #endif
131 
132 #undef INT_LEAST8_MAX
133 #define INT_LEAST8_MAX __INT_LEAST8_MAX__
134 #undef INT_LEAST8_MIN
135 #define INT_LEAST8_MIN (-INT_LEAST8_MAX - 1)
136 #undef UINT_LEAST8_MAX
137 #define UINT_LEAST8_MAX __UINT_LEAST8_MAX__
138 #undef INT_LEAST16_MAX
139 #define INT_LEAST16_MAX __INT_LEAST16_MAX__
140 #undef INT_LEAST16_MIN
141 #define INT_LEAST16_MIN (-INT_LEAST16_MAX - 1)
142 #undef UINT_LEAST16_MAX
143 #define UINT_LEAST16_MAX __UINT_LEAST16_MAX__
144 #undef INT_LEAST32_MAX
145 #define INT_LEAST32_MAX __INT_LEAST32_MAX__
146 #undef INT_LEAST32_MIN
147 #define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)
148 #undef UINT_LEAST32_MAX
149 #define UINT_LEAST32_MAX __UINT_LEAST32_MAX__
150 #undef INT_LEAST64_MAX
151 #define INT_LEAST64_MAX __INT_LEAST64_MAX__
152 #undef INT_LEAST64_MIN
153 #define INT_LEAST64_MIN (-INT_LEAST64_MAX - 1)
154 #undef UINT_LEAST64_MAX
155 #define UINT_LEAST64_MAX __UINT_LEAST64_MAX__
156 
157 #undef INT_FAST8_MAX
158 #define INT_FAST8_MAX __INT_FAST8_MAX__
159 #undef INT_FAST8_MIN
160 #define INT_FAST8_MIN (-INT_FAST8_MAX - 1)
161 #undef UINT_FAST8_MAX
162 #define UINT_FAST8_MAX __UINT_FAST8_MAX__
163 #undef INT_FAST16_MAX
164 #define INT_FAST16_MAX __INT_FAST16_MAX__
165 #undef INT_FAST16_MIN
166 #define INT_FAST16_MIN (-INT_FAST16_MAX - 1)
167 #undef UINT_FAST16_MAX
168 #define UINT_FAST16_MAX __UINT_FAST16_MAX__
169 #undef INT_FAST32_MAX
170 #define INT_FAST32_MAX __INT_FAST32_MAX__
171 #undef INT_FAST32_MIN
172 #define INT_FAST32_MIN (-INT_FAST32_MAX - 1)
173 #undef UINT_FAST32_MAX
174 #define UINT_FAST32_MAX __UINT_FAST32_MAX__
175 #undef INT_FAST64_MAX
176 #define INT_FAST64_MAX __INT_FAST64_MAX__
177 #undef INT_FAST64_MIN
178 #define INT_FAST64_MIN (-INT_FAST64_MAX - 1)
179 #undef UINT_FAST64_MAX
180 #define UINT_FAST64_MAX __UINT_FAST64_MAX__
181 
182 #ifdef __INTPTR_MAX__
183 # undef INTPTR_MAX
184 # define INTPTR_MAX __INTPTR_MAX__
185 # undef INTPTR_MIN
186 # define INTPTR_MIN (-INTPTR_MAX - 1)
187 #endif
188 #ifdef __UINTPTR_MAX__
189 # undef UINTPTR_MAX
190 # define UINTPTR_MAX __UINTPTR_MAX__
191 #endif
192 
193 #undef INTMAX_MAX
194 #define INTMAX_MAX __INTMAX_MAX__
195 #undef INTMAX_MIN
196 #define INTMAX_MIN (-INTMAX_MAX - 1)
197 #undef UINTMAX_MAX
198 #define UINTMAX_MAX __UINTMAX_MAX__
199 
200 /* 7.18.3 Limits of other integer types */
201 
202 #undef PTRDIFF_MAX
203 #define PTRDIFF_MAX __PTRDIFF_MAX__
204 #undef PTRDIFF_MIN
205 #define PTRDIFF_MIN (-PTRDIFF_MAX - 1)
206 
207 #undef SIG_ATOMIC_MAX
208 #define SIG_ATOMIC_MAX __SIG_ATOMIC_MAX__
209 #undef SIG_ATOMIC_MIN
210 #define SIG_ATOMIC_MIN __SIG_ATOMIC_MIN__
211 
212 #undef SIZE_MAX
213 #define SIZE_MAX __SIZE_MAX__
214 
215 #undef WCHAR_MAX
216 #define WCHAR_MAX __WCHAR_MAX__
217 #undef WCHAR_MIN
218 #define WCHAR_MIN __WCHAR_MIN__
219 
220 #undef WINT_MAX
221 #define WINT_MAX __WINT_MAX__
222 #undef WINT_MIN
223 #define WINT_MIN __WINT_MIN__
224 
225 #endif /* (!defined __cplusplus || __cplusplus >= 201103L
226 	   || defined __STDC_LIMIT_MACROS)  */
227 
228 #if (!defined __cplusplus || __cplusplus >= 201103L \
229      || defined __STDC_CONSTANT_MACROS)
230 
231 #undef INT8_C
232 #define INT8_C(c) __INT8_C(c)
233 #undef INT16_C
234 #define INT16_C(c) __INT16_C(c)
235 #undef INT32_C
236 #define INT32_C(c) __INT32_C(c)
237 #undef INT64_C
238 #define INT64_C(c) __INT64_C(c)
239 #undef UINT8_C
240 #define UINT8_C(c) __UINT8_C(c)
241 #undef UINT16_C
242 #define UINT16_C(c) __UINT16_C(c)
243 #undef UINT32_C
244 #define UINT32_C(c) __UINT32_C(c)
245 #undef UINT64_C
246 #define UINT64_C(c) __UINT64_C(c)
247 #undef INTMAX_C
248 #define INTMAX_C(c) __INTMAX_C(c)
249 #undef UINTMAX_C
250 #define UINTMAX_C(c) __UINTMAX_C(c)
251 
252 #endif /* (!defined __cplusplus || __cplusplus >= 201103L
253 	   || defined __STDC_CONSTANT_MACROS) */
254 
255 #ifndef __INT_MAX__
256 #define __INT_MAX__     2147483647
257 #endif
258 #define INT_MIN         (-1 - INT_MAX)
259 #define INT_MAX         (__INT_MAX__)
260 #define UINT_MAX        (INT_MAX * 2U + 1U)
261 
262 #define LONG_MAX	((long)(~0UL>>1))
263 #define LONG_MIN	(-LONG_MAX - 1)
264 #define ULONG_MAX	(~0UL)
265 
266 #endif
267