Clang Project

include/limits.h
1/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
2   This file is part of the GNU C Library.
3
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.
8
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.
13
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   <http://www.gnu.org/licenses/>.  */
17
18/*
19 * ISO C99 Standard: 7.10/5.2.4.2.1 Sizes of integer types <limits.h>
20 */
21
22#ifndef _LIBC_LIMITS_H_
23#define _LIBC_LIMITS_H_ 1
24
25#include <features.h>
26
27
28/* Maximum length of any multibyte character in any locale.
29   We define this value here since the gcc header does not define
30   the correct value.  */
31#define MB_LEN_MAX 16
32
33
34/* If we are not using GNU CC we have to define all the symbols ourself.
35   Otherwise use gcc's definitions (see below).  */
36#if !defined __GNUC__ || __GNUC__ < 2
37
38/* We only protect from multiple inclusion here, because all the other
39   #include's protect themselves, and in GCC 2 we may #include_next through
40   multiple copies of this file before we get to GCC's.  */
41# ifndef _LIMITS_H
42#  define _LIMITS_H 1
43
44#include <bits/wordsize.h>
45
46/* We don't have #include_next.
47   Define ANSI <limits.h> for standard 32-bit words.  */
48
49/* These assume 8-bit `char's, 16-bit `short int's,
50   and 32-bit `int's and `long int's.  */
51
52/* Number of bits in a `char'. */
53#  define CHAR_BIT 8
54
55/* Minimum and maximum values a `signed char' can hold.  */
56#  define SCHAR_MIN (-128)
57#  define SCHAR_MAX 127
58
59/* Maximum value an `unsigned char' can hold.  (Minimum is 0.)  */
60#  define UCHAR_MAX 255
61
62/* Minimum and maximum values a `char' can hold.  */
63#  ifdef __CHAR_UNSIGNED__
64#   define CHAR_MIN 0
65#   define CHAR_MAX UCHAR_MAX
66#  else
67#   define CHAR_MIN SCHAR_MIN
68#   define CHAR_MAX SCHAR_MAX
69#  endif
70
71/* Minimum and maximum values a `signed short int' can hold.  */
72#  define SHRT_MIN (-32768)
73#  define SHRT_MAX 32767
74
75/* Maximum value an `unsigned short int' can hold.  (Minimum is 0.)  */
76#  define USHRT_MAX 65535
77
78/* Minimum and maximum values a `signed int' can hold.  */
79#  define INT_MIN (-INT_MAX - 1)
80#  define INT_MAX 2147483647
81
82/* Maximum value an `unsigned int' can hold.  (Minimum is 0.)  */
83#  define UINT_MAX 4294967295U
84
85/* Minimum and maximum values a `signed long int' can hold.  */
86#  if __WORDSIZE == 64
87#   define LONG_MAX 9223372036854775807L
88#  else
89#   define LONG_MAX 2147483647L
90#  endif
91#  define LONG_MIN (-LONG_MAX - 1L)
92
93/* Maximum value an `unsigned long int' can hold.  (Minimum is 0.)  */
94#  if __WORDSIZE == 64
95#   define ULONG_MAX 18446744073709551615UL
96#  else
97#   define ULONG_MAX 4294967295UL
98#  endif
99
100#  ifdef __USE_ISOC99
101
102/* Minimum and maximum values a `signed long long int' can hold.  */
103#   define LLONG_MAX 9223372036854775807LL
104#   define LLONG_MIN (-LLONG_MAX - 1LL)
105
106/* Maximum value an `unsigned long long int' can hold.  (Minimum is 0.)  */
107#   define ULLONG_MAX 18446744073709551615ULL
108
109#  endif /* ISO C99 */
110
111# endif /* limits.h  */
112#endif /* GCC 2.  */
113
114#endif /* !_LIBC_LIMITS_H_ */
115
116 /* Get the compiler's limits.h, which defines almost all the ISO constants.
117
118    We put this #include_next outside the double inclusion check because
119    it should be possible to include this file more than once and still get
120    the definitions from gcc's header.  */
121#if defined __GNUC__ && !defined _GCC_LIMITS_H_
122/* `_GCC_LIMITS_H_' is what GCC's file defines.  */
123# include_next <limits.h>
124#endif
125
126/* The <limits.h> files in some gcc versions don't define LLONG_MIN,
127   LLONG_MAX, and ULLONG_MAX.  Instead only the values gcc defined for
128   ages are available.  */
129#if defined __USE_ISOC99 && defined __GNUC__
130ifndef LLONG_MIN
131#  define LLONG_MIN (-LLONG_MAX-1)
132endif
133ifndef LLONG_MAX
134#  define LLONG_MAX __LONG_LONG_MAX__
135endif
136ifndef ULLONG_MAX
137#  define ULLONG_MAX (LLONG_MAX * 2ULL + 1)
138endif
139#endif
140
141#ifdef __USE_POSIX
142/* POSIX adds things to <limits.h>.  */
143# include <bits/posix1_lim.h>
144#endif
145
146#ifdef __USE_POSIX2
147# include <bits/posix2_lim.h>
148#endif
149
150#ifdef __USE_XOPEN
151# include <bits/xopen_lim.h>
152#endif
153