2000-10-13 Michael Fedrowitz <michael@fedrowitz.de>
[glibc.git] / include / limits.h
blobd0c3d613f50a0c239f293253b30fbc5a9afd5b2f
1 /* Copyright (C) 1991, 92, 96, 97, 98, 99, 2000 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 Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 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 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
20 * ISO C99 Standard: 7.10/5.2.4.2.1 Sizes of integer types <limits.h>
23 #ifndef _LIBC_LIMITS_H_
24 #define _LIBC_LIMITS_H_ 1
26 #include <features.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 /* We don't have #include_next.
46 Define ANSI <limits.h> for standard 32-bit words. */
48 /* These assume 8-bit `char's, 16-bit `short int's,
49 and 32-bit `int's and `long int's. */
51 /* Number of bits in a `char'. */
52 # define CHAR_BIT 8
54 /* Minimum and maximum values a `signed char' can hold. */
55 # define SCHAR_MIN (-128)
56 # define SCHAR_MAX 127
58 /* Maximum value an `unsigned char' can hold. (Minimum is 0.) */
59 # define UCHAR_MAX 255
61 /* Minimum and maximum values a `char' can hold. */
62 # ifdef __CHAR_UNSIGNED__
63 # define CHAR_MIN 0
64 # define CHAR_MAX UCHAR_MAX
65 # else
66 # define CHAR_MIN SCHAR_MIN
67 # define CHAR_MAX SCHAR_MAX
68 # endif
70 /* Minimum and maximum values a `signed short int' can hold. */
71 # define SHRT_MIN (-32768)
72 # define SHRT_MAX 32767
74 /* Maximum value an `unsigned short int' can hold. (Minimum is 0.) */
75 # define USHRT_MAX 65535
77 /* Minimum and maximum values a `signed int' can hold. */
78 # define INT_MIN (-INT_MAX - 1)
79 # define INT_MAX 2147483647
81 /* Maximum value an `unsigned int' can hold. (Minimum is 0.) */
82 # define UINT_MAX 4294967295U
84 /* Minimum and maximum values a `signed long int' can hold. */
85 # ifdef __alpha__
86 # define LONG_MAX 9223372036854775807L
87 # else
88 # define LONG_MAX 2147483647L
89 # endif
90 # define LONG_MIN (-LONG_MAX - 1L)
92 /* Maximum value an `unsigned long int' can hold. (Minimum is 0.) */
93 # ifdef __alpha__
94 # define ULONG_MAX 18446744073709551615UL
95 # else
96 # define ULONG_MAX 4294967295UL
97 # endif
99 # ifdef __USE_ISOC99
101 /* Minimum and maximum values a `signed long long int' can hold. */
102 # define LLONG_MAX 9223372036854775807LL
103 # define LLONG_MIN (-LLONG_MAX - 1LL)
105 /* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */
106 # define ULLONG_MAX 18446744073709551615ULL
108 # endif /* ISO C99 */
110 # endif /* limits.h */
111 #endif /* GCC 2. */
113 #endif /* !_LIBC_LIMITS_H_ */
115 /* Get the compiler's limits.h, which defines almost all the ISO constants.
117 We put this #include_next outside the double inclusion check because
118 it should be possible to include this file more than once and still get
119 the definitions from gcc's header. */
120 #if defined __GNUC__ && !defined _GCC_LIMITS_H_
121 /* `_GCC_LIMITS_H_' is what GCC's file defines. */
122 # include_next <limits.h>
124 /* The <limits.h> files in some gcc versions don't define LLONG_MIN,
125 LLONG_MAX, and ULLONG_MAX. Instead only the values gcc defined for
126 ages are available. */
127 # ifdef __USE_ISOC99
128 # ifndef LLONG_MIN
129 # define LLONG_MIN LONG_LONG_MIN
130 # endif
131 # ifndef LLONG_MAX
132 # define LLONG_MAX LONG_LONG_MAX
133 # endif
134 # ifndef ULLONG_MAX
135 # define ULLONG_MAX ULONG_LONG_MAX
136 # endif
137 # endif
138 #endif
140 #ifdef __USE_POSIX
141 /* POSIX adds things to <limits.h>. */
142 # include <bits/posix1_lim.h>
143 #endif
145 #ifdef __USE_POSIX2
146 # include <bits/posix2_lim.h>
147 #endif
149 #ifdef __USE_XOPEN
150 # include <bits/xopen_lim.h>
151 #endif