]>
Commit | Line | Data |
---|---|---|
dff8da6b | 1 | /* Copyright (C) 1997-2024 Free Software Foundation, Inc. |
1c25bcac UD |
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 | |
41bdb6e2 AJ |
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. | |
1c25bcac UD |
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 | |
41bdb6e2 | 12 | Lesser General Public License for more details. |
1c25bcac | 13 | |
41bdb6e2 | 14 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 | 15 | License along with the GNU C Library; if not, see |
5a82c748 | 16 | <https://www.gnu.org/licenses/>. */ |
1c25bcac UD |
17 | |
18 | /* | |
63ae7b63 | 19 | * ISO C99: 7.18 Integer types <stdint.h> |
1c25bcac UD |
20 | */ |
21 | ||
22 | #ifndef _STDINT_H | |
23 | #define _STDINT_H 1 | |
24 | ||
5b17fd0d JM |
25 | #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION |
26 | #include <bits/libc-header-start.h> | |
76999889 | 27 | #include <bits/types.h> |
417bafec | 28 | #include <bits/wchar.h> |
1c25bcac UD |
29 | #include <bits/wordsize.h> |
30 | ||
31 | /* Exact integral types. */ | |
32 | ||
33 | /* Signed. */ | |
17680430 | 34 | #include <bits/stdint-intn.h> |
1c25bcac UD |
35 | |
36 | /* Unsigned. */ | |
17680430 | 37 | #include <bits/stdint-uintn.h> |
1c25bcac UD |
38 | |
39 | ||
40 | /* Small types. */ | |
b34b46b8 | 41 | #include <bits/stdint-least.h> |
1c25bcac UD |
42 | |
43 | ||
44 | /* Fast types. */ | |
45 | ||
46 | /* Signed. */ | |
47 | typedef signed char int_fast8_t; | |
48 | #if __WORDSIZE == 64 | |
49 | typedef long int int_fast16_t; | |
50 | typedef long int int_fast32_t; | |
51 | typedef long int int_fast64_t; | |
52 | #else | |
53 | typedef int int_fast16_t; | |
54 | typedef int int_fast32_t; | |
55 | __extension__ | |
56 | typedef long long int int_fast64_t; | |
57 | #endif | |
58 | ||
59 | /* Unsigned. */ | |
60 | typedef unsigned char uint_fast8_t; | |
61 | #if __WORDSIZE == 64 | |
62 | typedef unsigned long int uint_fast16_t; | |
63 | typedef unsigned long int uint_fast32_t; | |
64 | typedef unsigned long int uint_fast64_t; | |
65 | #else | |
66 | typedef unsigned int uint_fast16_t; | |
67 | typedef unsigned int uint_fast32_t; | |
68 | __extension__ | |
69 | typedef unsigned long long int uint_fast64_t; | |
70 | #endif | |
71 | ||
72 | ||
73 | /* Types for `void *' pointers. */ | |
74 | #if __WORDSIZE == 64 | |
7df789e0 | 75 | # ifndef __intptr_t_defined |
1c25bcac | 76 | typedef long int intptr_t; |
7df789e0 | 77 | # define __intptr_t_defined |
1c25bcac UD |
78 | # endif |
79 | typedef unsigned long int uintptr_t; | |
80 | #else | |
7df789e0 | 81 | # ifndef __intptr_t_defined |
1c25bcac | 82 | typedef int intptr_t; |
7df789e0 | 83 | # define __intptr_t_defined |
1c25bcac UD |
84 | # endif |
85 | typedef unsigned int uintptr_t; | |
86 | #endif | |
87 | ||
88 | ||
89 | /* Largest integral types. */ | |
76999889 JM |
90 | typedef __intmax_t intmax_t; |
91 | typedef __uintmax_t uintmax_t; | |
1c25bcac UD |
92 | |
93 | ||
1c25bcac UD |
94 | # if __WORDSIZE == 64 |
95 | # define __INT64_C(c) c ## L | |
96 | # define __UINT64_C(c) c ## UL | |
97 | # else | |
98 | # define __INT64_C(c) c ## LL | |
99 | # define __UINT64_C(c) c ## ULL | |
100 | # endif | |
101 | ||
102 | /* Limits of integral types. */ | |
103 | ||
104 | /* Minimum of signed integral types. */ | |
105 | # define INT8_MIN (-128) | |
106 | # define INT16_MIN (-32767-1) | |
107 | # define INT32_MIN (-2147483647-1) | |
108 | # define INT64_MIN (-__INT64_C(9223372036854775807)-1) | |
109 | /* Maximum of signed integral types. */ | |
110 | # define INT8_MAX (127) | |
111 | # define INT16_MAX (32767) | |
112 | # define INT32_MAX (2147483647) | |
113 | # define INT64_MAX (__INT64_C(9223372036854775807)) | |
114 | ||
115 | /* Maximum of unsigned integral types. */ | |
417bafec UD |
116 | # define UINT8_MAX (255) |
117 | # define UINT16_MAX (65535) | |
1c25bcac UD |
118 | # define UINT32_MAX (4294967295U) |
119 | # define UINT64_MAX (__UINT64_C(18446744073709551615)) | |
120 | ||
121 | ||
122 | /* Minimum of signed integral types having a minimum size. */ | |
123 | # define INT_LEAST8_MIN (-128) | |
124 | # define INT_LEAST16_MIN (-32767-1) | |
125 | # define INT_LEAST32_MIN (-2147483647-1) | |
126 | # define INT_LEAST64_MIN (-__INT64_C(9223372036854775807)-1) | |
127 | /* Maximum of signed integral types having a minimum size. */ | |
128 | # define INT_LEAST8_MAX (127) | |
129 | # define INT_LEAST16_MAX (32767) | |
130 | # define INT_LEAST32_MAX (2147483647) | |
131 | # define INT_LEAST64_MAX (__INT64_C(9223372036854775807)) | |
132 | ||
133 | /* Maximum of unsigned integral types having a minimum size. */ | |
417bafec UD |
134 | # define UINT_LEAST8_MAX (255) |
135 | # define UINT_LEAST16_MAX (65535) | |
1c25bcac UD |
136 | # define UINT_LEAST32_MAX (4294967295U) |
137 | # define UINT_LEAST64_MAX (__UINT64_C(18446744073709551615)) | |
138 | ||
139 | ||
140 | /* Minimum of fast signed integral types having a minimum size. */ | |
141 | # define INT_FAST8_MIN (-128) | |
142 | # if __WORDSIZE == 64 | |
143 | # define INT_FAST16_MIN (-9223372036854775807L-1) | |
144 | # define INT_FAST32_MIN (-9223372036854775807L-1) | |
145 | # else | |
146 | # define INT_FAST16_MIN (-2147483647-1) | |
147 | # define INT_FAST32_MIN (-2147483647-1) | |
148 | # endif | |
149 | # define INT_FAST64_MIN (-__INT64_C(9223372036854775807)-1) | |
150 | /* Maximum of fast signed integral types having a minimum size. */ | |
151 | # define INT_FAST8_MAX (127) | |
152 | # if __WORDSIZE == 64 | |
153 | # define INT_FAST16_MAX (9223372036854775807L) | |
154 | # define INT_FAST32_MAX (9223372036854775807L) | |
155 | # else | |
156 | # define INT_FAST16_MAX (2147483647) | |
157 | # define INT_FAST32_MAX (2147483647) | |
158 | # endif | |
159 | # define INT_FAST64_MAX (__INT64_C(9223372036854775807)) | |
160 | ||
161 | /* Maximum of fast unsigned integral types having a minimum size. */ | |
417bafec | 162 | # define UINT_FAST8_MAX (255) |
1c25bcac UD |
163 | # if __WORDSIZE == 64 |
164 | # define UINT_FAST16_MAX (18446744073709551615UL) | |
165 | # define UINT_FAST32_MAX (18446744073709551615UL) | |
166 | # else | |
167 | # define UINT_FAST16_MAX (4294967295U) | |
168 | # define UINT_FAST32_MAX (4294967295U) | |
169 | # endif | |
170 | # define UINT_FAST64_MAX (__UINT64_C(18446744073709551615)) | |
171 | ||
172 | ||
173 | /* Values to test for integral types holding `void *' pointer. */ | |
174 | # if __WORDSIZE == 64 | |
175 | # define INTPTR_MIN (-9223372036854775807L-1) | |
176 | # define INTPTR_MAX (9223372036854775807L) | |
177 | # define UINTPTR_MAX (18446744073709551615UL) | |
178 | # else | |
179 | # define INTPTR_MIN (-2147483647-1) | |
180 | # define INTPTR_MAX (2147483647) | |
181 | # define UINTPTR_MAX (4294967295U) | |
182 | # endif | |
183 | ||
184 | ||
185 | /* Minimum for largest signed integral type. */ | |
186 | # define INTMAX_MIN (-__INT64_C(9223372036854775807)-1) | |
187 | /* Maximum for largest signed integral type. */ | |
188 | # define INTMAX_MAX (__INT64_C(9223372036854775807)) | |
189 | ||
190 | /* Maximum for largest unsigned integral type. */ | |
191 | # define UINTMAX_MAX (__UINT64_C(18446744073709551615)) | |
192 | ||
193 | ||
194 | /* Limits of other integer types. */ | |
195 | ||
196 | /* Limits of `ptrdiff_t' type. */ | |
197 | # if __WORDSIZE == 64 | |
198 | # define PTRDIFF_MIN (-9223372036854775807L-1) | |
199 | # define PTRDIFF_MAX (9223372036854775807L) | |
200 | # else | |
d060cd00 SE |
201 | # if __WORDSIZE32_PTRDIFF_LONG |
202 | # define PTRDIFF_MIN (-2147483647L-1) | |
203 | # define PTRDIFF_MAX (2147483647L) | |
204 | # else | |
205 | # define PTRDIFF_MIN (-2147483647-1) | |
206 | # define PTRDIFF_MAX (2147483647) | |
207 | # endif | |
1c25bcac UD |
208 | # endif |
209 | ||
210 | /* Limits of `sig_atomic_t'. */ | |
211 | # define SIG_ATOMIC_MIN (-2147483647-1) | |
212 | # define SIG_ATOMIC_MAX (2147483647) | |
213 | ||
214 | /* Limit of `size_t' type. */ | |
215 | # if __WORDSIZE == 64 | |
216 | # define SIZE_MAX (18446744073709551615UL) | |
217 | # else | |
d060cd00 | 218 | # if __WORDSIZE32_SIZE_ULONG |
26011b5c SL |
219 | # define SIZE_MAX (4294967295UL) |
220 | # else | |
221 | # define SIZE_MAX (4294967295U) | |
222 | # endif | |
1c25bcac UD |
223 | # endif |
224 | ||
225 | /* Limits of `wchar_t'. */ | |
226 | # ifndef WCHAR_MIN | |
227 | /* These constants might also be defined in <wchar.h>. */ | |
417bafec UD |
228 | # define WCHAR_MIN __WCHAR_MIN |
229 | # define WCHAR_MAX __WCHAR_MAX | |
1c25bcac UD |
230 | # endif |
231 | ||
232 | /* Limits of `wint_t'. */ | |
417bafec | 233 | # define WINT_MIN (0u) |
81068e35 | 234 | # define WINT_MAX (4294967295u) |
1c25bcac | 235 | |
1c25bcac UD |
236 | /* Signed. */ |
237 | # define INT8_C(c) c | |
238 | # define INT16_C(c) c | |
239 | # define INT32_C(c) c | |
240 | # if __WORDSIZE == 64 | |
241 | # define INT64_C(c) c ## L | |
242 | # else | |
243 | # define INT64_C(c) c ## LL | |
244 | # endif | |
245 | ||
246 | /* Unsigned. */ | |
4c3f81d0 UD |
247 | # define UINT8_C(c) c |
248 | # define UINT16_C(c) c | |
1c25bcac UD |
249 | # define UINT32_C(c) c ## U |
250 | # if __WORDSIZE == 64 | |
251 | # define UINT64_C(c) c ## UL | |
252 | # else | |
253 | # define UINT64_C(c) c ## ULL | |
254 | # endif | |
255 | ||
256 | /* Maximal type. */ | |
257 | # if __WORDSIZE == 64 | |
258 | # define INTMAX_C(c) c ## L | |
259 | # define UINTMAX_C(c) c ## UL | |
260 | # else | |
261 | # define INTMAX_C(c) c ## LL | |
262 | # define UINTMAX_C(c) c ## ULL | |
263 | # endif | |
264 | ||
42cc619d | 265 | #if __GLIBC_USE (IEC_60559_BFP_EXT_C23) |
5b17fd0d JM |
266 | |
267 | # define INT8_WIDTH 8 | |
268 | # define UINT8_WIDTH 8 | |
269 | # define INT16_WIDTH 16 | |
270 | # define UINT16_WIDTH 16 | |
271 | # define INT32_WIDTH 32 | |
272 | # define UINT32_WIDTH 32 | |
273 | # define INT64_WIDTH 64 | |
274 | # define UINT64_WIDTH 64 | |
275 | ||
276 | # define INT_LEAST8_WIDTH 8 | |
277 | # define UINT_LEAST8_WIDTH 8 | |
278 | # define INT_LEAST16_WIDTH 16 | |
279 | # define UINT_LEAST16_WIDTH 16 | |
280 | # define INT_LEAST32_WIDTH 32 | |
281 | # define UINT_LEAST32_WIDTH 32 | |
282 | # define INT_LEAST64_WIDTH 64 | |
283 | # define UINT_LEAST64_WIDTH 64 | |
284 | ||
285 | # define INT_FAST8_WIDTH 8 | |
286 | # define UINT_FAST8_WIDTH 8 | |
287 | # define INT_FAST16_WIDTH __WORDSIZE | |
288 | # define UINT_FAST16_WIDTH __WORDSIZE | |
289 | # define INT_FAST32_WIDTH __WORDSIZE | |
290 | # define UINT_FAST32_WIDTH __WORDSIZE | |
291 | # define INT_FAST64_WIDTH 64 | |
292 | # define UINT_FAST64_WIDTH 64 | |
293 | ||
294 | # define INTPTR_WIDTH __WORDSIZE | |
295 | # define UINTPTR_WIDTH __WORDSIZE | |
296 | ||
297 | # define INTMAX_WIDTH 64 | |
298 | # define UINTMAX_WIDTH 64 | |
299 | ||
300 | # define PTRDIFF_WIDTH __WORDSIZE | |
301 | # define SIG_ATOMIC_WIDTH 32 | |
302 | # define SIZE_WIDTH __WORDSIZE | |
303 | # define WCHAR_WIDTH 32 | |
304 | # define WINT_WIDTH 32 | |
305 | ||
306 | #endif | |
307 | ||
1c25bcac | 308 | #endif /* stdint.h */ |