1 /* Copyright (C) 1997-2022 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3 
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
8 
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
13 
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, see
16    <https://www.gnu.org/licenses/>.  */
17 
18 /*
19  *	ISO C99: 7.18 Integer types <stdint.h>
20  */
21 
22 #ifndef _STDINT_H
23 #define _STDINT_H	1
24 
25 
26 
27 # define __WORDSIZE	64
28 
29 /* Convenience types.  */
30 typedef unsigned char __u_char;
31 typedef unsigned short int __u_short;
32 typedef unsigned int __u_int;
33 typedef unsigned long int __u_long;
34 
35 /* Fixed-size types, underlying types depend on word size and compiler.  */
36 typedef signed char __int8_t;
37 typedef unsigned char __uint8_t;
38 typedef signed short int __int16_t;
39 typedef unsigned short int __uint16_t;
40 typedef signed int __int32_t;
41 typedef unsigned int __uint32_t;
42 #if __WORDSIZE == 64
43 typedef signed long int __int64_t;
44 typedef unsigned long int __uint64_t;
45 #else
46 __extension__ typedef signed long long int __int64_t;
47 __extension__ typedef unsigned long long int __uint64_t;
48 #endif
49 
50 /* Smallest types with at least a given width.  */
51 typedef __int8_t __int_least8_t;
52 typedef __uint8_t __uint_least8_t;
53 typedef __int16_t __int_least16_t;
54 typedef __uint16_t __uint_least16_t;
55 typedef __int32_t __int_least32_t;
56 typedef __uint32_t __uint_least32_t;
57 typedef __int64_t __int_least64_t;
58 typedef __uint64_t __uint_least64_t;
59 
60 typedef __uint8_t uint8_t;
61 typedef __uint16_t uint16_t;
62 typedef __uint32_t uint32_t;
63 typedef __uint64_t uint64_t;
64 
65 typedef __int8_t int8_t;
66 typedef __int16_t int16_t;
67 typedef __int32_t int32_t;
68 typedef __int64_t int64_t;
69 
70 /* Small types.  */
71 
72 /* Signed.  */
73 typedef __int_least8_t int_least8_t;
74 typedef __int_least16_t int_least16_t;
75 typedef __int_least32_t int_least32_t;
76 typedef __int_least64_t int_least64_t;
77 
78 /* Unsigned.  */
79 typedef __uint_least8_t uint_least8_t;
80 typedef __uint_least16_t uint_least16_t;
81 typedef __uint_least32_t uint_least32_t;
82 typedef __uint_least64_t uint_least64_t;
83 
84 
85 /* Fast types.  */
86 
87 /* Signed.  */
88 typedef signed char		int_fast8_t;
89 #if __WORDSIZE == 64
90 typedef long int		int_fast16_t;
91 typedef long int		int_fast32_t;
92 typedef long int		int_fast64_t;
93 #else
94 typedef int			int_fast16_t;
95 typedef int			int_fast32_t;
96 __extension__
97 typedef long long int		int_fast64_t;
98 #endif
99 
100 /* Unsigned.  */
101 typedef unsigned char		uint_fast8_t;
102 #if __WORDSIZE == 64
103 typedef unsigned long int	uint_fast16_t;
104 typedef unsigned long int	uint_fast32_t;
105 typedef unsigned long int	uint_fast64_t;
106 #else
107 typedef unsigned int		uint_fast16_t;
108 typedef unsigned int		uint_fast32_t;
109 __extension__
110 typedef unsigned long long int	uint_fast64_t;
111 #endif
112 
113 
114 /* Types for `void *' pointers.  */
115 #if __WORDSIZE == 64
116 # ifndef __intptr_t_defined
117 typedef long int		intptr_t;
118 #  define __intptr_t_defined
119 # endif
120 typedef unsigned long int	uintptr_t;
121 #else
122 # ifndef __intptr_t_defined
123 typedef int			intptr_t;
124 #  define __intptr_t_defined
125 # endif
126 typedef unsigned int		uintptr_t;
127 #endif
128 
129 /* Largest integral types.  */
130 #if __WORDSIZE == 64
131 typedef long int __intmax_t;
132 typedef unsigned long int __uintmax_t;
133 #else
134 __extension__ typedef long long int __intmax_t;
135 __extension__ typedef unsigned long long int __uintmax_t;
136 #endif
137 
138 
139 /* Largest integral types.  */
140 typedef __intmax_t		intmax_t;
141 typedef __uintmax_t		uintmax_t;
142 
143 
144 # if __WORDSIZE == 64
145 #  define __INT64_C(c)	c ## L
146 #  define __UINT64_C(c)	c ## UL
147 # else
148 #  define __INT64_C(c)	c ## LL
149 #  define __UINT64_C(c)	c ## ULL
150 # endif
151 
152 /* Limits of integral types.  */
153 
154 /* Minimum of signed integral types.  */
155 # define INT8_MIN		(-128)
156 # define INT16_MIN		(-32767-1)
157 # define INT32_MIN		(-2147483647-1)
158 # define INT64_MIN		(-__INT64_C(9223372036854775807)-1)
159 /* Maximum of signed integral types.  */
160 # define INT8_MAX		(127)
161 # define INT16_MAX		(32767)
162 # define INT32_MAX		(2147483647)
163 # define INT64_MAX		(__INT64_C(9223372036854775807))
164 
165 /* Maximum of unsigned integral types.  */
166 # define UINT8_MAX		(255)
167 # define UINT16_MAX		(65535)
168 # define UINT32_MAX		(4294967295U)
169 # define UINT64_MAX		(__UINT64_C(18446744073709551615))
170 
171 
172 /* Minimum of signed integral types having a minimum size.  */
173 # define INT_LEAST8_MIN		(-128)
174 # define INT_LEAST16_MIN	(-32767-1)
175 # define INT_LEAST32_MIN	(-2147483647-1)
176 # define INT_LEAST64_MIN	(-__INT64_C(9223372036854775807)-1)
177 /* Maximum of signed integral types having a minimum size.  */
178 # define INT_LEAST8_MAX		(127)
179 # define INT_LEAST16_MAX	(32767)
180 # define INT_LEAST32_MAX	(2147483647)
181 # define INT_LEAST64_MAX	(__INT64_C(9223372036854775807))
182 
183 /* Maximum of unsigned integral types having a minimum size.  */
184 # define UINT_LEAST8_MAX	(255)
185 # define UINT_LEAST16_MAX	(65535)
186 # define UINT_LEAST32_MAX	(4294967295U)
187 # define UINT_LEAST64_MAX	(__UINT64_C(18446744073709551615))
188 
189 
190 /* Minimum of fast signed integral types having a minimum size.  */
191 # define INT_FAST8_MIN		(-128)
192 # if __WORDSIZE == 64
193 #  define INT_FAST16_MIN	(-9223372036854775807L-1)
194 #  define INT_FAST32_MIN	(-9223372036854775807L-1)
195 # else
196 #  define INT_FAST16_MIN	(-2147483647-1)
197 #  define INT_FAST32_MIN	(-2147483647-1)
198 # endif
199 # define INT_FAST64_MIN		(-__INT64_C(9223372036854775807)-1)
200 /* Maximum of fast signed integral types having a minimum size.  */
201 # define INT_FAST8_MAX		(127)
202 # if __WORDSIZE == 64
203 #  define INT_FAST16_MAX	(9223372036854775807L)
204 #  define INT_FAST32_MAX	(9223372036854775807L)
205 # else
206 #  define INT_FAST16_MAX	(2147483647)
207 #  define INT_FAST32_MAX	(2147483647)
208 # endif
209 # define INT_FAST64_MAX		(__INT64_C(9223372036854775807))
210 
211 /* Maximum of fast unsigned integral types having a minimum size.  */
212 # define UINT_FAST8_MAX		(255)
213 # if __WORDSIZE == 64
214 #  define UINT_FAST16_MAX	(18446744073709551615UL)
215 #  define UINT_FAST32_MAX	(18446744073709551615UL)
216 # else
217 #  define UINT_FAST16_MAX	(4294967295U)
218 #  define UINT_FAST32_MAX	(4294967295U)
219 # endif
220 # define UINT_FAST64_MAX	(__UINT64_C(18446744073709551615))
221 
222 
223 /* Values to test for integral types holding `void *' pointer.  */
224 # if __WORDSIZE == 64
225 #  define INTPTR_MIN		(-9223372036854775807L-1)
226 #  define INTPTR_MAX		(9223372036854775807L)
227 #  define UINTPTR_MAX		(18446744073709551615UL)
228 # else
229 #  define INTPTR_MIN		(-2147483647-1)
230 #  define INTPTR_MAX		(2147483647)
231 #  define UINTPTR_MAX		(4294967295U)
232 # endif
233 
234 
235 /* Minimum for largest signed integral type.  */
236 # define INTMAX_MIN		(-__INT64_C(9223372036854775807)-1)
237 /* Maximum for largest signed integral type.  */
238 # define INTMAX_MAX		(__INT64_C(9223372036854775807))
239 
240 /* Maximum for largest unsigned integral type.  */
241 # define UINTMAX_MAX		(__UINT64_C(18446744073709551615))
242 
243 
244 /* Limits of other integer types.  */
245 
246 /* Limits of `ptrdiff_t' type.  */
247 # if __WORDSIZE == 64
248 #  define PTRDIFF_MIN		(-9223372036854775807L-1)
249 #  define PTRDIFF_MAX		(9223372036854775807L)
250 # else
251 #  if __WORDSIZE32_PTRDIFF_LONG
252 #   define PTRDIFF_MIN		(-2147483647L-1)
253 #   define PTRDIFF_MAX		(2147483647L)
254 #  else
255 #   define PTRDIFF_MIN		(-2147483647-1)
256 #   define PTRDIFF_MAX		(2147483647)
257 #  endif
258 # endif
259 
260 /* Limits of `sig_atomic_t'.  */
261 # define SIG_ATOMIC_MIN		(-2147483647-1)
262 # define SIG_ATOMIC_MAX		(2147483647)
263 
264 /* Limit of `size_t' type.  */
265 # if __WORDSIZE == 64
266 #  define SIZE_MAX		(18446744073709551615UL)
267 # else
268 #  if __WORDSIZE32_SIZE_ULONG
269 #   define SIZE_MAX		(4294967295UL)
270 #  else
271 #   define SIZE_MAX		(4294967295U)
272 #  endif
273 # endif
274 
275 /* Limits of `wchar_t'.  */
276 # ifndef WCHAR_MIN
277 /* These constants might also be defined in <wchar.h>.  */
278 #  define WCHAR_MIN		__WCHAR_MIN
279 #  define WCHAR_MAX		__WCHAR_MAX
280 # endif
281 
282 /* Limits of `wint_t'.  */
283 # define WINT_MIN		(0u)
284 # define WINT_MAX		(4294967295u)
285 
286 /* Signed.  */
287 # define INT8_C(c)	c
288 # define INT16_C(c)	c
289 # define INT32_C(c)	c
290 # if __WORDSIZE == 64
291 #  define INT64_C(c)	c ## L
292 # else
293 #  define INT64_C(c)	c ## LL
294 # endif
295 
296 /* Unsigned.  */
297 # define UINT8_C(c)	c
298 # define UINT16_C(c)	c
299 # define UINT32_C(c)	c ## U
300 # if __WORDSIZE == 64
301 #  define UINT64_C(c)	c ## UL
302 # else
303 #  define UINT64_C(c)	c ## ULL
304 # endif
305 
306 /* Maximal type.  */
307 # if __WORDSIZE == 64
308 #  define INTMAX_C(c)	c ## L
309 #  define UINTMAX_C(c)	c ## UL
310 # else
311 #  define INTMAX_C(c)	c ## LL
312 #  define UINTMAX_C(c)	c ## ULL
313 # endif
314 
315 
316 #endif /* stdint.h */