Skip to content

Commit d437d3b

Browse files
authored
Create limits.h
1 parent 6a2d5e1 commit d437d3b

File tree

1 file changed

+166
-0
lines changed

1 file changed

+166
-0
lines changed

src/limits.h

+166
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
/* Copyright (C) 1991-2022 Free Software Foundation, Inc.
2+
This file is part of the GNU C Library.
3+
The GNU C Library is free software; you can redistribute it and/or
4+
modify it under the terms of the GNU Lesser General Public
5+
License as published by the Free Software Foundation; either
6+
version 2.1 of the License, or (at your option) any later version.
7+
The GNU C Library is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10+
Lesser General Public License for more details.
11+
You should have received a copy of the GNU Lesser General Public
12+
License along with the GNU C Library; if not, see
13+
<https://www.gnu.org/licenses/>. */
14+
/*
15+
* ISO C99 Standard: 7.10/5.2.4.2.1 Sizes of integer types <limits.h>
16+
*/
17+
#ifndef _LIBC_LIMITS_H_
18+
#define _LIBC_LIMITS_H_ 1
19+
#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
20+
#include <bits/libc-header-start.h>
21+
/* Maximum length of any multibyte character in any locale.
22+
We define this value here since the gcc header does not define
23+
the correct value. */
24+
#define MB_LEN_MAX 16
25+
/* If we are not using GNU CC we have to define all the symbols ourself.
26+
Otherwise use gcc's definitions (see below). */
27+
#if !defined __GNUC__ || __GNUC__ < 2
28+
/* We only protect from multiple inclusion here, because all the other
29+
#include's protect themselves, and in GCC 2 we may #include_next through
30+
multiple copies of this file before we get to GCC's. */
31+
# ifndef _LIMITS_H
32+
# define _LIMITS_H 1
33+
#include <bits/wordsize.h>
34+
/* We don't have #include_next.
35+
Define ANSI <limits.h> for standard 32-bit words. */
36+
/* These assume 8-bit `char's, 16-bit `short int's,
37+
and 32-bit `int's and `long int's. */
38+
/* Number of bits in a `char'. */
39+
# define CHAR_BIT 8
40+
/* Minimum and maximum values a `signed char' can hold. */
41+
# define SCHAR_MIN (-128)
42+
# define SCHAR_MAX 127
43+
/* Maximum value an `unsigned char' can hold. (Minimum is 0.) */
44+
# define UCHAR_MAX 255
45+
/* Minimum and maximum values a `char' can hold. */
46+
# ifdef __CHAR_UNSIGNED__
47+
# define CHAR_MIN 0
48+
# define CHAR_MAX UCHAR_MAX
49+
# else
50+
# define CHAR_MIN SCHAR_MIN
51+
# define CHAR_MAX SCHAR_MAX
52+
# endif
53+
/* Minimum and maximum values a `signed short int' can hold. */
54+
# define SHRT_MIN (-32768)
55+
# define SHRT_MAX 32767
56+
/* Maximum value an `unsigned short int' can hold. (Minimum is 0.) */
57+
# define USHRT_MAX 65535
58+
/* Minimum and maximum values a `signed int' can hold. */
59+
# define INT_MIN (-INT_MAX - 1)
60+
# define INT_MAX 2147483647
61+
/* Maximum value an `unsigned int' can hold. (Minimum is 0.) */
62+
# define UINT_MAX 4294967295U
63+
/* Minimum and maximum values a `signed long int' can hold. */
64+
# if __WORDSIZE == 64
65+
# define LONG_MAX 9223372036854775807L
66+
# else
67+
# define LONG_MAX 2147483647L
68+
# endif
69+
# define LONG_MIN (-LONG_MAX - 1L)
70+
/* Maximum value an `unsigned long int' can hold. (Minimum is 0.) */
71+
# if __WORDSIZE == 64
72+
# define ULONG_MAX 18446744073709551615UL
73+
# else
74+
# define ULONG_MAX 4294967295UL
75+
# endif
76+
# ifdef __USE_ISOC99
77+
/* Minimum and maximum values a `signed long long int' can hold. */
78+
# define LLONG_MAX 9223372036854775807LL
79+
# define LLONG_MIN (-LLONG_MAX - 1LL)
80+
/* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */
81+
# define ULLONG_MAX 18446744073709551615ULL
82+
# endif /* ISO C99 */
83+
# endif /* limits.h */
84+
#endif /* GCC 2. */
85+
#endif /* !_LIBC_LIMITS_H_ */
86+
/* Get the compiler's limits.h, which defines almost all the ISO constants.
87+
We put this #include_next outside the double inclusion check because
88+
it should be possible to include this file more than once and still get
89+
the definitions from gcc's header. */
90+
#if defined __GNUC__ && !defined _GCC_LIMITS_H_
91+
/* `_GCC_LIMITS_H_' is what GCC's file defines. */
92+
# include_next <limits.h>
93+
#endif
94+
/* The <limits.h> files in some gcc versions don't define LLONG_MIN,
95+
LLONG_MAX, and ULLONG_MAX. Instead only the values gcc defined for
96+
ages are available. */
97+
#if defined __USE_ISOC99 && defined __GNUC__
98+
# ifndef LLONG_MIN
99+
# define LLONG_MIN (-LLONG_MAX-1)
100+
# endif
101+
# ifndef LLONG_MAX
102+
# define LLONG_MAX __LONG_LONG_MAX__
103+
# endif
104+
# ifndef ULLONG_MAX
105+
# define ULLONG_MAX (LLONG_MAX * 2ULL + 1)
106+
# endif
107+
#endif
108+
/* The integer width macros are not defined by GCC's <limits.h> before
109+
GCC 7, or if _GNU_SOURCE rather than
110+
__STDC_WANT_IEC_60559_BFP_EXT__ is used to enable this feature. */
111+
#if __GLIBC_USE (IEC_60559_BFP_EXT_C2X)
112+
# ifndef CHAR_WIDTH
113+
# define CHAR_WIDTH 8
114+
# endif
115+
# ifndef SCHAR_WIDTH
116+
# define SCHAR_WIDTH 8
117+
# endif
118+
# ifndef UCHAR_WIDTH
119+
# define UCHAR_WIDTH 8
120+
# endif
121+
# ifndef SHRT_WIDTH
122+
# define SHRT_WIDTH 16
123+
# endif
124+
# ifndef USHRT_WIDTH
125+
# define USHRT_WIDTH 16
126+
# endif
127+
# ifndef INT_WIDTH
128+
# define INT_WIDTH 32
129+
# endif
130+
# ifndef UINT_WIDTH
131+
# define UINT_WIDTH 32
132+
# endif
133+
# ifndef LONG_WIDTH
134+
# define LONG_WIDTH __WORDSIZE
135+
# endif
136+
# ifndef ULONG_WIDTH
137+
# define ULONG_WIDTH __WORDSIZE
138+
# endif
139+
# ifndef LLONG_WIDTH
140+
# define LLONG_WIDTH 64
141+
# endif
142+
# ifndef ULLONG_WIDTH
143+
# define ULLONG_WIDTH 64
144+
# endif
145+
#endif /* Use IEC_60559_BFP_EXT. */
146+
/* The macros for _Bool are not defined by GCC's <limits.h> before GCC
147+
11, or if _GNU_SOURCE is defined rather than enabling C2x support
148+
with -std. */
149+
#if __GLIBC_USE (ISOC2X)
150+
# ifndef BOOL_MAX
151+
# define BOOL_MAX 1
152+
# endif
153+
# ifndef BOOL_WIDTH
154+
# define BOOL_WIDTH 1
155+
# endif
156+
#endif
157+
#ifdef __USE_POSIX
158+
/* POSIX adds things to <limits.h>. */
159+
# include <bits/posix1_lim.h>
160+
#endif
161+
#ifdef __USE_POSIX2
162+
# include <bits/posix2_lim.h>
163+
#endif
164+
#ifdef __USE_XOPEN
165+
# include <bits/xopen_lim.h>
166+
#endif

0 commit comments

Comments
 (0)