powerpc64le: Enforce -mabi=ibmlongdouble when -mfloat128 used
[glibc.git] / stdlib / stdint.h
blob2df07e485b402f9328c51e6cd0cabb0cf5afd6c1
1 /* Copyright (C) 1997-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
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/>. */
19 * ISO C99: 7.18 Integer types <stdint.h>
22 #ifndef _STDINT_H
23 #define _STDINT_H 1
25 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
26 #include <bits/libc-header-start.h>
27 #include <bits/types.h>
28 #include <bits/wchar.h>
29 #include <bits/wordsize.h>
31 /* Exact integral types. */
33 /* Signed. */
34 #include <bits/stdint-intn.h>
36 /* Unsigned. */
37 #include <bits/stdint-uintn.h>
40 /* Small types. */
42 /* Signed. */
43 typedef __int_least8_t int_least8_t;
44 typedef __int_least16_t int_least16_t;
45 typedef __int_least32_t int_least32_t;
46 typedef __int_least64_t int_least64_t;
48 /* Unsigned. */
49 typedef __uint_least8_t uint_least8_t;
50 typedef __uint_least16_t uint_least16_t;
51 typedef __uint_least32_t uint_least32_t;
52 typedef __uint_least64_t uint_least64_t;
55 /* Fast types. */
57 /* Signed. */
58 typedef signed char int_fast8_t;
59 #if __WORDSIZE == 64
60 typedef long int int_fast16_t;
61 typedef long int int_fast32_t;
62 typedef long int int_fast64_t;
63 #else
64 typedef int int_fast16_t;
65 typedef int int_fast32_t;
66 __extension__
67 typedef long long int int_fast64_t;
68 #endif
70 /* Unsigned. */
71 typedef unsigned char uint_fast8_t;
72 #if __WORDSIZE == 64
73 typedef unsigned long int uint_fast16_t;
74 typedef unsigned long int uint_fast32_t;
75 typedef unsigned long int uint_fast64_t;
76 #else
77 typedef unsigned int uint_fast16_t;
78 typedef unsigned int uint_fast32_t;
79 __extension__
80 typedef unsigned long long int uint_fast64_t;
81 #endif
84 /* Types for `void *' pointers. */
85 #if __WORDSIZE == 64
86 # ifndef __intptr_t_defined
87 typedef long int intptr_t;
88 # define __intptr_t_defined
89 # endif
90 typedef unsigned long int uintptr_t;
91 #else
92 # ifndef __intptr_t_defined
93 typedef int intptr_t;
94 # define __intptr_t_defined
95 # endif
96 typedef unsigned int uintptr_t;
97 #endif
100 /* Largest integral types. */
101 typedef __intmax_t intmax_t;
102 typedef __uintmax_t uintmax_t;
105 # if __WORDSIZE == 64
106 # define __INT64_C(c) c ## L
107 # define __UINT64_C(c) c ## UL
108 # else
109 # define __INT64_C(c) c ## LL
110 # define __UINT64_C(c) c ## ULL
111 # endif
113 /* Limits of integral types. */
115 /* Minimum of signed integral types. */
116 # define INT8_MIN (-128)
117 # define INT16_MIN (-32767-1)
118 # define INT32_MIN (-2147483647-1)
119 # define INT64_MIN (-__INT64_C(9223372036854775807)-1)
120 /* Maximum of signed integral types. */
121 # define INT8_MAX (127)
122 # define INT16_MAX (32767)
123 # define INT32_MAX (2147483647)
124 # define INT64_MAX (__INT64_C(9223372036854775807))
126 /* Maximum of unsigned integral types. */
127 # define UINT8_MAX (255)
128 # define UINT16_MAX (65535)
129 # define UINT32_MAX (4294967295U)
130 # define UINT64_MAX (__UINT64_C(18446744073709551615))
133 /* Minimum of signed integral types having a minimum size. */
134 # define INT_LEAST8_MIN (-128)
135 # define INT_LEAST16_MIN (-32767-1)
136 # define INT_LEAST32_MIN (-2147483647-1)
137 # define INT_LEAST64_MIN (-__INT64_C(9223372036854775807)-1)
138 /* Maximum of signed integral types having a minimum size. */
139 # define INT_LEAST8_MAX (127)
140 # define INT_LEAST16_MAX (32767)
141 # define INT_LEAST32_MAX (2147483647)
142 # define INT_LEAST64_MAX (__INT64_C(9223372036854775807))
144 /* Maximum of unsigned integral types having a minimum size. */
145 # define UINT_LEAST8_MAX (255)
146 # define UINT_LEAST16_MAX (65535)
147 # define UINT_LEAST32_MAX (4294967295U)
148 # define UINT_LEAST64_MAX (__UINT64_C(18446744073709551615))
151 /* Minimum of fast signed integral types having a minimum size. */
152 # define INT_FAST8_MIN (-128)
153 # if __WORDSIZE == 64
154 # define INT_FAST16_MIN (-9223372036854775807L-1)
155 # define INT_FAST32_MIN (-9223372036854775807L-1)
156 # else
157 # define INT_FAST16_MIN (-2147483647-1)
158 # define INT_FAST32_MIN (-2147483647-1)
159 # endif
160 # define INT_FAST64_MIN (-__INT64_C(9223372036854775807)-1)
161 /* Maximum of fast signed integral types having a minimum size. */
162 # define INT_FAST8_MAX (127)
163 # if __WORDSIZE == 64
164 # define INT_FAST16_MAX (9223372036854775807L)
165 # define INT_FAST32_MAX (9223372036854775807L)
166 # else
167 # define INT_FAST16_MAX (2147483647)
168 # define INT_FAST32_MAX (2147483647)
169 # endif
170 # define INT_FAST64_MAX (__INT64_C(9223372036854775807))
172 /* Maximum of fast unsigned integral types having a minimum size. */
173 # define UINT_FAST8_MAX (255)
174 # if __WORDSIZE == 64
175 # define UINT_FAST16_MAX (18446744073709551615UL)
176 # define UINT_FAST32_MAX (18446744073709551615UL)
177 # else
178 # define UINT_FAST16_MAX (4294967295U)
179 # define UINT_FAST32_MAX (4294967295U)
180 # endif
181 # define UINT_FAST64_MAX (__UINT64_C(18446744073709551615))
184 /* Values to test for integral types holding `void *' pointer. */
185 # if __WORDSIZE == 64
186 # define INTPTR_MIN (-9223372036854775807L-1)
187 # define INTPTR_MAX (9223372036854775807L)
188 # define UINTPTR_MAX (18446744073709551615UL)
189 # else
190 # define INTPTR_MIN (-2147483647-1)
191 # define INTPTR_MAX (2147483647)
192 # define UINTPTR_MAX (4294967295U)
193 # endif
196 /* Minimum for largest signed integral type. */
197 # define INTMAX_MIN (-__INT64_C(9223372036854775807)-1)
198 /* Maximum for largest signed integral type. */
199 # define INTMAX_MAX (__INT64_C(9223372036854775807))
201 /* Maximum for largest unsigned integral type. */
202 # define UINTMAX_MAX (__UINT64_C(18446744073709551615))
205 /* Limits of other integer types. */
207 /* Limits of `ptrdiff_t' type. */
208 # if __WORDSIZE == 64
209 # define PTRDIFF_MIN (-9223372036854775807L-1)
210 # define PTRDIFF_MAX (9223372036854775807L)
211 # else
212 # if __WORDSIZE32_PTRDIFF_LONG
213 # define PTRDIFF_MIN (-2147483647L-1)
214 # define PTRDIFF_MAX (2147483647L)
215 # else
216 # define PTRDIFF_MIN (-2147483647-1)
217 # define PTRDIFF_MAX (2147483647)
218 # endif
219 # endif
221 /* Limits of `sig_atomic_t'. */
222 # define SIG_ATOMIC_MIN (-2147483647-1)
223 # define SIG_ATOMIC_MAX (2147483647)
225 /* Limit of `size_t' type. */
226 # if __WORDSIZE == 64
227 # define SIZE_MAX (18446744073709551615UL)
228 # else
229 # if __WORDSIZE32_SIZE_ULONG
230 # define SIZE_MAX (4294967295UL)
231 # else
232 # define SIZE_MAX (4294967295U)
233 # endif
234 # endif
236 /* Limits of `wchar_t'. */
237 # ifndef WCHAR_MIN
238 /* These constants might also be defined in <wchar.h>. */
239 # define WCHAR_MIN __WCHAR_MIN
240 # define WCHAR_MAX __WCHAR_MAX
241 # endif
243 /* Limits of `wint_t'. */
244 # define WINT_MIN (0u)
245 # define WINT_MAX (4294967295u)
247 /* Signed. */
248 # define INT8_C(c) c
249 # define INT16_C(c) c
250 # define INT32_C(c) c
251 # if __WORDSIZE == 64
252 # define INT64_C(c) c ## L
253 # else
254 # define INT64_C(c) c ## LL
255 # endif
257 /* Unsigned. */
258 # define UINT8_C(c) c
259 # define UINT16_C(c) c
260 # define UINT32_C(c) c ## U
261 # if __WORDSIZE == 64
262 # define UINT64_C(c) c ## UL
263 # else
264 # define UINT64_C(c) c ## ULL
265 # endif
267 /* Maximal type. */
268 # if __WORDSIZE == 64
269 # define INTMAX_C(c) c ## L
270 # define UINTMAX_C(c) c ## UL
271 # else
272 # define INTMAX_C(c) c ## LL
273 # define UINTMAX_C(c) c ## ULL
274 # endif
276 #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X)
278 # define INT8_WIDTH 8
279 # define UINT8_WIDTH 8
280 # define INT16_WIDTH 16
281 # define UINT16_WIDTH 16
282 # define INT32_WIDTH 32
283 # define UINT32_WIDTH 32
284 # define INT64_WIDTH 64
285 # define UINT64_WIDTH 64
287 # define INT_LEAST8_WIDTH 8
288 # define UINT_LEAST8_WIDTH 8
289 # define INT_LEAST16_WIDTH 16
290 # define UINT_LEAST16_WIDTH 16
291 # define INT_LEAST32_WIDTH 32
292 # define UINT_LEAST32_WIDTH 32
293 # define INT_LEAST64_WIDTH 64
294 # define UINT_LEAST64_WIDTH 64
296 # define INT_FAST8_WIDTH 8
297 # define UINT_FAST8_WIDTH 8
298 # define INT_FAST16_WIDTH __WORDSIZE
299 # define UINT_FAST16_WIDTH __WORDSIZE
300 # define INT_FAST32_WIDTH __WORDSIZE
301 # define UINT_FAST32_WIDTH __WORDSIZE
302 # define INT_FAST64_WIDTH 64
303 # define UINT_FAST64_WIDTH 64
305 # define INTPTR_WIDTH __WORDSIZE
306 # define UINTPTR_WIDTH __WORDSIZE
308 # define INTMAX_WIDTH 64
309 # define UINTMAX_WIDTH 64
311 # define PTRDIFF_WIDTH __WORDSIZE
312 # define SIG_ATOMIC_WIDTH 32
313 # define SIZE_WIDTH __WORDSIZE
314 # define WCHAR_WIDTH 32
315 # define WINT_WIDTH 32
317 #endif
319 #endif /* stdint.h */