master
1/* <stdint.h> for the Aro C compiler */
2
3#pragma once
4
5
6#if __STDC_HOSTED__ && __has_include_next(<stdint.h>)
7
8# include_next <stdint.h>
9
10#else
11
12#define __stdint_int_c_cat(X, Y) X ## Y
13#define __stdint_int_c(V, SUFFIX) __stdint_int_c_cat(V, SUFFIX)
14#define __stdint_uint_c(V, SUFFIX) __stdint_int_c_cat(V##U, SUFFIX)
15
16#define INTPTR_MIN (-__INTPTR_MAX__-1)
17#define INTPTR_MAX __INTPTR_MAX__
18#define UINTPTR_MAX __UINTPTR_MAX__
19#define PTRDIFF_MIN (-__PTRDIFF_MAX__-1)
20#define PTRDIFF_MAX __PTRDIFF_MAX__
21#define SIZE_MAX __SIZE_MAX__
22#define INTMAX_MIN (-__INTMAX_MAX__-1)
23#define INTMAX_MAX __INTMAX_MAX__
24#define UINTMAX_MAX __UINTMAX_MAX__
25#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
26# define INTPTR_WIDTH __INTPTR_WIDTH__
27# define UINTPTR_WIDTH __UINTPTR_WIDTH__
28# define INTMAX_WIDTH __INTMAX_WIDTH__
29# define UINTMAX_WIDTH __UINTMAX_WIDTH__
30# define PTRDIFF_WIDTH __PTRDIFF_WIDTH__
31# define SIZE_WIDTH __SIZE_WIDTH__
32# define WCHAR_WIDTH __WCHAR_WIDTH__
33#endif
34
35typedef __INTMAX_TYPE__ intmax_t;
36typedef __UINTMAX_TYPE__ uintmax_t;
37
38#ifndef _INTPTR_T
39# ifndef __intptr_t_defined
40 typedef __INTPTR_TYPE__ intptr_t;
41# define __intptr_t_defined
42# define _INTPTR_T
43# endif
44#endif
45
46#ifndef _UINTPTR_T
47 typedef __UINTPTR_TYPE__ uintptr_t;
48# define _UINTPTR_T
49#endif
50
51
52#ifdef __INT64_TYPE__
53# ifndef __int8_t_defined /* glibc sys/types.h also defines int64_t*/
54 typedef __INT64_TYPE__ int64_t;
55# endif /* __int8_t_defined */
56 typedef __UINT64_TYPE__ uint64_t;
57
58# undef __int64_c_suffix
59# undef __int32_c_suffix
60# undef __int16_c_suffix
61# undef __int8_c_suffix
62# ifdef __INT64_C_SUFFIX__
63# define __int64_c_suffix __INT64_C_SUFFIX__
64# define __int32_c_suffix __INT64_C_SUFFIX__
65# define __int16_c_suffix __INT64_C_SUFFIX__
66# define __int8_c_suffix __INT64_C_SUFFIX__
67# endif /* __INT64_C_SUFFIX__ */
68
69# ifdef __int64_c_suffix
70# define INT64_C(v) (__stdint_int_c(v, __int64_c_suffix))
71# define UINT64_C(v) (__stdint_uint_c(v, __int64_c_suffix))
72# else
73# define INT64_C(v) (v)
74# define UINT64_C(v) (v ## U)
75# endif /* __int64_c_suffix */
76
77# define INT64_MAX INT64_C( 9223372036854775807)
78# define INT64_MIN (-INT64_C( 9223372036854775807)-1)
79# define UINT64_MAX UINT64_C(18446744073709551615)
80# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
81# define UINT64_WIDTH 64
82# define INT64_WIDTH UINT64_WIDTH
83# endif /* __STDC_VERSION__ */
84
85#endif /* __INT64_TYPE__ */
86
87#ifdef __INT32_TYPE__
88# ifndef __int8_t_defined /* glibc sys/types.h also defines int32_t*/
89 typedef __INT32_TYPE__ int32_t;
90# endif /* __int8_t_defined */
91 typedef __UINT32_TYPE__ uint32_t;
92
93# undef __int32_c_suffix
94# undef __int16_c_suffix
95# undef __int8_c_suffix
96# ifdef __INT32_C_SUFFIX__
97# define __int32_c_suffix __INT32_C_SUFFIX__
98# define __int16_c_suffix __INT32_C_SUFFIX__
99# define __int8_c_suffix __INT32_C_SUFFIX__
100# endif /* __INT32_C_SUFFIX__ */
101
102# ifdef __int32_c_suffix
103# define INT32_C(v) (__stdint_int_c(v, __int32_c_suffix))
104# define UINT32_C(v) (__stdint_uint_c(v, __int32_c_suffix))
105# else
106# define INT32_C(v) (v)
107# define UINT32_C(v) (v ## U)
108# endif /* __int32_c_suffix */
109
110# define INT32_MAX INT32_C( 2147483647)
111# define INT32_MIN (-INT32_C( 2147483647)-1)
112# define UINT32_MAX UINT32_C(4294967295)
113# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
114# define UINT32_WIDTH 32
115# define INT32_WIDTH UINT32_WIDTH
116# endif /* __STDC_VERSION__ */
117
118#endif /* __INT32_TYPE__ */
119
120#ifdef __INT16_TYPE__
121# ifndef __int8_t_defined /* glibc sys/types.h also defines int16_t*/
122 typedef __INT16_TYPE__ int16_t;
123# endif /* __int8_t_defined */
124 typedef __UINT16_TYPE__ uint16_t;
125
126# undef __int16_c_suffix
127# undef __int8_c_suffix
128# ifdef __INT16_C_SUFFIX__
129# define __int16_c_suffix __INT16_C_SUFFIX__
130# define __int8_c_suffix __INT16_C_SUFFIX__
131# endif /* __INT16_C_SUFFIX__ */
132
133# ifdef __int16_c_suffix
134# define INT16_C(v) (__stdint_int_c(v, __int16_c_suffix))
135# define UINT16_C(v) (__stdint_uint_c(v, __int16_c_suffix))
136# else
137# define INT16_C(v) (v)
138# define UINT16_C(v) (v ## U)
139# endif /* __int16_c_suffix */
140
141# define INT16_MAX INT16_C( 32767)
142# define INT16_MIN (-INT16_C( 32767)-1)
143# define UINT16_MAX UINT16_C(65535)
144# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
145# define UINT16_WIDTH 16
146# define INT16_WIDTH UINT16_WIDTH
147# endif /* __STDC_VERSION__ */
148
149#endif /* __INT16_TYPE__ */
150
151#ifdef __INT8_TYPE__
152# ifndef __int8_t_defined /* glibc sys/types.h also defines int8_t*/
153 typedef __INT8_TYPE__ int8_t;
154# endif /* __int8_t_defined */
155 typedef __UINT8_TYPE__ uint8_t;
156
157# undef __int8_c_suffix
158# ifdef __INT8_C_SUFFIX__
159# define __int8_c_suffix __INT8_C_SUFFIX__
160# endif /* __INT8_C_SUFFIX__ */
161
162# ifdef __int8_c_suffix
163# define INT8_C(v) (__stdint_int_c(v, __int8_c_suffix))
164# define UINT8_C(v) (__stdint_uint_c(v, __int8_c_suffix))
165# else
166# define INT8_C(v) (v)
167# define UINT8_C(v) (v ## U)
168# endif /* __int8_c_suffix */
169
170# define INT8_MAX INT8_C(127)
171# define INT8_MIN (-INT8_C(127)-1)
172# define UINT8_MAX UINT8_C(255)
173# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
174# define UINT8_WIDTH 8
175# define INT8_WIDTH UINT8_WIDTH
176# endif /* __STDC_VERSION__ */
177
178#endif /* __INT8_TYPE__ */
179
180typedef __INT_LEAST64_TYPE__ int_least64_t;
181typedef __INT_LEAST32_TYPE__ int_least32_t;
182typedef __INT_LEAST16_TYPE__ int_least16_t;
183typedef __INT_LEAST8_TYPE__ int_least8_t;
184
185typedef __UINT_LEAST64_TYPE__ uint_least64_t;
186typedef __UINT_LEAST32_TYPE__ uint_least32_t;
187typedef __UINT_LEAST16_TYPE__ uint_least16_t;
188typedef __UINT_LEAST8_TYPE__ uint_least8_t;
189
190#define INT_LEAST8_MAX __INT_LEAST8_MAX__
191#define INT_LEAST8_MIN (-__INT_LEAST8_MAX__-1)
192#define UINT_LEAST8_MAX __UINT_LEAST8_MAX__
193
194#define INT_LEAST16_MAX __INT_LEAST16_MAX__
195#define INT_LEAST16_MIN (-__INT_LEAST16_MAX__-1)
196#define UINT_LEAST16_MAX __UINT_LEAST16_MAX__
197
198#define INT_LEAST32_MAX __INT_LEAST32_MAX__
199#define INT_LEAST32_MIN (-__INT_LEAST32_MAX__-1)
200#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__
201
202#define INT_LEAST64_MAX __INT_LEAST64_MAX__
203#define INT_LEAST64_MIN (-__INT_LEAST64_MAX__-1)
204#define UINT_LEAST64_MAX __UINT_LEAST64_MAX__
205
206
207typedef __INT_FAST64_TYPE__ int_fast64_t;
208typedef __INT_FAST32_TYPE__ int_fast32_t;
209typedef __INT_FAST16_TYPE__ int_fast16_t;
210typedef __INT_FAST8_TYPE__ int_fast8_t;
211
212typedef __UINT_FAST64_TYPE__ uint_fast64_t;
213typedef __UINT_FAST32_TYPE__ uint_fast32_t;
214typedef __UINT_FAST16_TYPE__ uint_fast16_t;
215typedef __UINT_FAST8_TYPE__ uint_fast8_t;
216
217#define INT_FAST8_MAX __INT_FAST8_MAX__
218#define INT_FAST8_MIN (-__INT_FAST8_MAX__-1)
219#define UINT_FAST8_MAX __UINT_FAST8_MAX__
220
221#define INT_FAST16_MAX __INT_FAST16_MAX__
222#define INT_FAST16_MIN (-__INT_FAST16_MAX__-1)
223#define UINT_FAST16_MAX __UINT_FAST16_MAX__
224
225#define INT_FAST32_MAX __INT_FAST32_MAX__
226#define INT_FAST32_MIN (-__INT_FAST32_MAX__-1)
227#define UINT_FAST32_MAX __UINT_FAST32_MAX__
228
229#define INT_FAST64_MAX __INT_FAST64_MAX__
230#define INT_FAST64_MIN (-__INT_FAST64_MAX__-1)
231#define UINT_FAST64_MAX __UINT_FAST64_MAX__
232
233
234#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
235
236#define INT_FAST8_WIDTH __INT_FAST8_WIDTH__
237#define UINT_FAST8_WIDTH __INT_FAST8_WIDTH__
238#define INT_LEAST8_WIDTH __INT_LEAST8_WIDTH__
239#define UINT_LEAST8_WIDTH __INT_LEAST8_WIDTH__
240
241#define INT_FAST16_WIDTH __INT_FAST16_WIDTH__
242#define UINT_FAST16_WIDTH __INT_FAST16_WIDTH__
243#define INT_LEAST16_WIDTH __INT_LEAST16_WIDTH__
244#define UINT_LEAST16_WIDTH __INT_LEAST16_WIDTH__
245
246#define INT_FAST32_WIDTH __INT_FAST32_WIDTH__
247#define UINT_FAST32_WIDTH __INT_FAST32_WIDTH__
248#define INT_LEAST32_WIDTH __INT_LEAST32_WIDTH__
249#define UINT_LEAST32_WIDTH __INT_LEAST32_WIDTH__
250
251#define INT_FAST64_WIDTH __INT_FAST64_WIDTH__
252#define UINT_FAST64_WIDTH __INT_FAST64_WIDTH__
253#define INT_LEAST64_WIDTH __INT_LEAST64_WIDTH__
254#define UINT_LEAST64_WIDTH __INT_LEAST64_WIDTH__
255
256#endif
257
258#ifdef __SIZEOF_INT128__
259typedef signed __int128 int128_t;
260typedef unsigned __int128 uint128_t;
261typedef signed __int128 int_fast128_t;
262typedef unsigned __int128 uint_fast128_t;
263typedef signed __int128 int_least128_t;
264typedef unsigned __int128 uint_least128_t;
265# define UINT128_MAX ((uint128_t)-1)
266# define INT128_MAX ((int128_t)+(UINT128_MAX/2))
267# define INT128_MIN (-INT128_MAX-1)
268# define UINT_LEAST128_MAX UINT128_MAX
269# define INT_LEAST128_MAX INT128_MAX
270# define INT_LEAST128_MIN INT128_MIN
271# define UINT_FAST128_MAX UINT128_MAX
272# define INT_FAST128_MAX INT128_MAX
273# define INT_FAST128_MIN INT128_MIN
274# define INT128_WIDTH 128
275# define UINT128_WIDTH 128
276# define INT_LEAST128_WIDTH 128
277# define UINT_LEAST128_WIDTH 128
278# define INT_FAST128_WIDTH 128
279# define UINT_FAST128_WIDTH 128
280# if UINT128_WIDTH > __LLONG_WIDTH__
281# define INT128_C(N) ((int_least128_t)+N ## WB)
282# define UINT128_C(N) ((uint_least128_t)+N ## WBU)
283# else
284# define INT128_C(N) ((int_least128_t)+N ## LL)
285# define UINT128_C(N) ((uint_least128_t)+N ## LLU)
286# endif
287#endif
288
289#endif /* __STDC_HOSTED__ && __has_include_next(<stdint.h>) */