]>
Commit | Line | Data |
---|---|---|
04277e02 | 1 | /* Copyright (C) 1991-2019 Free Software Foundation, Inc. |
ba1ffaa1 | 2 | This file is part of the GNU C Library. |
28f540f4 | 3 | |
ba1ffaa1 | 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. | |
28f540f4 | 8 | |
ba1ffaa1 UD |
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. |
28f540f4 | 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/>. */ |
28f540f4 RM |
17 | |
18 | /* | |
d1646309 | 19 | * ISO C99 Standard: 7.10/5.2.4.2.1 Sizes of integer types <limits.h> |
28f540f4 RM |
20 | */ |
21 | ||
bd355af0 UD |
22 | #ifndef _LIBC_LIMITS_H_ |
23 | #define _LIBC_LIMITS_H_ 1 | |
24 | ||
a292f45a JM |
25 | #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION |
26 | #include <bits/libc-header-start.h> | |
28f540f4 | 27 | |
28f540f4 | 28 | |
b9b49b44 UD |
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. */ | |
d64b6ad0 | 32 | #define MB_LEN_MAX 16 |
b9b49b44 UD |
33 | |
34 | ||
6c79e60c UD |
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 | |
28f540f4 RM |
38 | |
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. */ | |
2c6fe0bd UD |
42 | # ifndef _LIMITS_H |
43 | # define _LIMITS_H 1 | |
28f540f4 | 44 | |
ceb579a3 UD |
45 | #include <bits/wordsize.h> |
46 | ||
28f540f4 RM |
47 | /* We don't have #include_next. |
48 | Define ANSI <limits.h> for standard 32-bit words. */ | |
49 | ||
50 | /* These assume 8-bit `char's, 16-bit `short int's, | |
51 | and 32-bit `int's and `long int's. */ | |
52 | ||
53 | /* Number of bits in a `char'. */ | |
2c6fe0bd | 54 | # define CHAR_BIT 8 |
28f540f4 | 55 | |
28f540f4 | 56 | /* Minimum and maximum values a `signed char' can hold. */ |
2c6fe0bd UD |
57 | # define SCHAR_MIN (-128) |
58 | # define SCHAR_MAX 127 | |
28f540f4 RM |
59 | |
60 | /* Maximum value an `unsigned char' can hold. (Minimum is 0.) */ | |
2c6fe0bd | 61 | # define UCHAR_MAX 255 |
28f540f4 RM |
62 | |
63 | /* Minimum and maximum values a `char' can hold. */ | |
2c6fe0bd UD |
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 | |
28f540f4 RM |
71 | |
72 | /* Minimum and maximum values a `signed short int' can hold. */ | |
2c6fe0bd UD |
73 | # define SHRT_MIN (-32768) |
74 | # define SHRT_MAX 32767 | |
28f540f4 RM |
75 | |
76 | /* Maximum value an `unsigned short int' can hold. (Minimum is 0.) */ | |
2c6fe0bd | 77 | # define USHRT_MAX 65535 |
28f540f4 RM |
78 | |
79 | /* Minimum and maximum values a `signed int' can hold. */ | |
bd355af0 | 80 | # define INT_MIN (-INT_MAX - 1) |
2c6fe0bd | 81 | # define INT_MAX 2147483647 |
28f540f4 RM |
82 | |
83 | /* Maximum value an `unsigned int' can hold. (Minimum is 0.) */ | |
945b22ed | 84 | # define UINT_MAX 4294967295U |
b20e47cb RM |
85 | |
86 | /* Minimum and maximum values a `signed long int' can hold. */ | |
ceb579a3 | 87 | # if __WORDSIZE == 64 |
2c6fe0bd UD |
88 | # define LONG_MAX 9223372036854775807L |
89 | # else | |
90 | # define LONG_MAX 2147483647L | |
91 | # endif | |
bd355af0 | 92 | # define LONG_MIN (-LONG_MAX - 1L) |
b20e47cb RM |
93 | |
94 | /* Maximum value an `unsigned long int' can hold. (Minimum is 0.) */ | |
ceb579a3 | 95 | # if __WORDSIZE == 64 |
2c6fe0bd UD |
96 | # define ULONG_MAX 18446744073709551615UL |
97 | # else | |
945b22ed | 98 | # define ULONG_MAX 4294967295UL |
2c6fe0bd UD |
99 | # endif |
100 | ||
945b22ed UD |
101 | # ifdef __USE_ISOC99 |
102 | ||
103 | /* Minimum and maximum values a `signed long long int' can hold. */ | |
104 | # define LLONG_MAX 9223372036854775807LL | |
105 | # define LLONG_MIN (-LLONG_MAX - 1LL) | |
106 | ||
107 | /* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */ | |
108 | # define ULLONG_MAX 18446744073709551615ULL | |
109 | ||
110 | # endif /* ISO C99 */ | |
111 | ||
2c6fe0bd | 112 | # endif /* limits.h */ |
28f540f4 | 113 | #endif /* GCC 2. */ |
bd355af0 UD |
114 | |
115 | #endif /* !_LIBC_LIMITS_H_ */ | |
6c79e60c UD |
116 | |
117 | /* Get the compiler's limits.h, which defines almost all the ISO constants. | |
118 | ||
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> | |
3158a33e | 125 | #endif |
389b7049 UD |
126 | |
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. */ | |
3158a33e UD |
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) | |
389b7049 UD |
139 | # endif |
140 | #endif | |
141 | ||
a292f45a JM |
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. */ | |
0175c9e9 | 145 | #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) |
a292f45a JM |
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 | |
ff88ee7e JM |
167 | # ifndef LONG_WIDTH |
168 | # define LONG_WIDTH __WORDSIZE | |
169 | # endif | |
170 | # ifndef ULONG_WIDTH | |
171 | # define ULONG_WIDTH __WORDSIZE | |
a292f45a JM |
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. */ | |
180 | ||
389b7049 UD |
181 | #ifdef __USE_POSIX |
182 | /* POSIX adds things to <limits.h>. */ | |
183 | # include <bits/posix1_lim.h> | |
184 | #endif | |
185 | ||
186 | #ifdef __USE_POSIX2 | |
187 | # include <bits/posix2_lim.h> | |
188 | #endif | |
189 | ||
190 | #ifdef __USE_XOPEN | |
191 | # include <bits/xopen_lim.h> | |
6c79e60c | 192 | #endif |