x86-64: Require BMI2 for AVX2 strcmp implementation
[glibc.git] / include / limits.h
blobe332be732d103972ac95589798f566bdf0b6b484
1 /* Copyright (C) 1991-2022 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 Standard: 7.10/5.2.4.2.1 Sizes of integer types <limits.h>
22 #ifndef _LIBC_LIMITS_H_
23 #define _LIBC_LIMITS_H_ 1
25 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
26 #include <bits/libc-header-start.h>
29 /* Maximum length of any multibyte character in any locale.
30 We define this value here since the gcc header does not define
31 the correct value. */
32 #define MB_LEN_MAX 16
35 /* If we are not using GNU CC we have to define all the symbols ourself.
36 Otherwise use gcc's definitions (see below). */
37 #if !defined __GNUC__ || __GNUC__ < 2
39 /* We only protect from multiple inclusion here, because all the other
40 #include's protect themselves, and in GCC 2 we may #include_next through
41 multiple copies of this file before we get to GCC's. */
42 # ifndef _LIMITS_H
43 # define _LIMITS_H 1
45 #include <bits/wordsize.h>
47 /* We don't have #include_next.
48 Define ANSI <limits.h> for standard 32-bit words. */
50 /* These assume 8-bit `char's, 16-bit `short int's,
51 and 32-bit `int's and `long int's. */
53 /* Number of bits in a `char'. */
54 # define CHAR_BIT 8
56 /* Minimum and maximum values a `signed char' can hold. */
57 # define SCHAR_MIN (-128)
58 # define SCHAR_MAX 127
60 /* Maximum value an `unsigned char' can hold. (Minimum is 0.) */
61 # define UCHAR_MAX 255
63 /* Minimum and maximum values a `char' can hold. */
64 # ifdef __CHAR_UNSIGNED__
65 # define CHAR_MIN 0
66 # define CHAR_MAX UCHAR_MAX
67 # else
68 # define CHAR_MIN SCHAR_MIN
69 # define CHAR_MAX SCHAR_MAX
70 # endif
72 /* Minimum and maximum values a `signed short int' can hold. */
73 # define SHRT_MIN (-32768)
74 # define SHRT_MAX 32767
76 /* Maximum value an `unsigned short int' can hold. (Minimum is 0.) */
77 # define USHRT_MAX 65535
79 /* Minimum and maximum values a `signed int' can hold. */
80 # define INT_MIN (-INT_MAX - 1)
81 # define INT_MAX 2147483647
83 /* Maximum value an `unsigned int' can hold. (Minimum is 0.) */
84 # define UINT_MAX 4294967295U
86 /* Minimum and maximum values a `signed long int' can hold. */
87 # if __WORDSIZE == 64
88 # define LONG_MAX 9223372036854775807L
89 # else
90 # define LONG_MAX 2147483647L
91 # endif
92 # define LONG_MIN (-LONG_MAX - 1L)
94 /* Maximum value an `unsigned long int' can hold. (Minimum is 0.) */
95 # if __WORDSIZE == 64
96 # define ULONG_MAX 18446744073709551615UL
97 # else
98 # define ULONG_MAX 4294967295UL
99 # endif
101 # ifdef __USE_ISOC99
103 /* Minimum and maximum values a `signed long long int' can hold. */
104 # define LLONG_MAX 9223372036854775807LL
105 # define LLONG_MIN (-LLONG_MAX - 1LL)
107 /* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */
108 # define ULLONG_MAX 18446744073709551615ULL
110 # endif /* ISO C99 */
112 # endif /* limits.h */
113 #endif /* GCC 2. */
115 #endif /* !_LIBC_LIMITS_H_ */
117 /* Get the compiler's limits.h, which defines almost all the ISO constants.
119 We put this #include_next outside the double inclusion check because
120 it should be possible to include this file more than once and still get
121 the definitions from gcc's header. */
122 #if defined __GNUC__ && !defined _GCC_LIMITS_H_
123 /* `_GCC_LIMITS_H_' is what GCC's file defines. */
124 # include_next <limits.h>
125 #endif
127 /* The <limits.h> files in some gcc versions don't define LLONG_MIN,
128 LLONG_MAX, and ULLONG_MAX. Instead only the values gcc defined for
129 ages are available. */
130 #if defined __USE_ISOC99 && defined __GNUC__
131 # ifndef LLONG_MIN
132 # define LLONG_MIN (-LLONG_MAX-1)
133 # endif
134 # ifndef LLONG_MAX
135 # define LLONG_MAX __LONG_LONG_MAX__
136 # endif
137 # ifndef ULLONG_MAX
138 # define ULLONG_MAX (LLONG_MAX * 2ULL + 1)
139 # endif
140 #endif
142 /* The integer width macros are not defined by GCC's <limits.h> before
143 GCC 7, or if _GNU_SOURCE rather than
144 __STDC_WANT_IEC_60559_BFP_EXT__ is used to enable this feature. */
145 #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X)
146 # ifndef CHAR_WIDTH
147 # define CHAR_WIDTH 8
148 # endif
149 # ifndef SCHAR_WIDTH
150 # define SCHAR_WIDTH 8
151 # endif
152 # ifndef UCHAR_WIDTH
153 # define UCHAR_WIDTH 8
154 # endif
155 # ifndef SHRT_WIDTH
156 # define SHRT_WIDTH 16
157 # endif
158 # ifndef USHRT_WIDTH
159 # define USHRT_WIDTH 16
160 # endif
161 # ifndef INT_WIDTH
162 # define INT_WIDTH 32
163 # endif
164 # ifndef UINT_WIDTH
165 # define UINT_WIDTH 32
166 # endif
167 # ifndef LONG_WIDTH
168 # define LONG_WIDTH __WORDSIZE
169 # endif
170 # ifndef ULONG_WIDTH
171 # define ULONG_WIDTH __WORDSIZE
172 # endif
173 # ifndef LLONG_WIDTH
174 # define LLONG_WIDTH 64
175 # endif
176 # ifndef ULLONG_WIDTH
177 # define ULLONG_WIDTH 64
178 # endif
179 #endif /* Use IEC_60559_BFP_EXT. */
181 /* The macros for _Bool are not defined by GCC's <limits.h> before GCC
182 11, or if _GNU_SOURCE is defined rather than enabling C2x support
183 with -std. */
184 #if __GLIBC_USE (ISOC2X)
185 # ifndef BOOL_MAX
186 # define BOOL_MAX 1
187 # endif
188 # ifndef BOOL_WIDTH
189 # define BOOL_WIDTH 1
190 # endif
191 #endif
193 #ifdef __USE_POSIX
194 /* POSIX adds things to <limits.h>. */
195 # include <bits/posix1_lim.h>
196 #endif
198 #ifdef __USE_POSIX2
199 # include <bits/posix2_lim.h>
200 #endif
202 #ifdef __USE_XOPEN
203 # include <bits/xopen_lim.h>
204 #endif