GCC Middle and Back End API Reference
glimits.h
Go to the documentation of this file.
1 /* Copyright (C) 1991-2013 Free Software Foundation, Inc.
2 
3 This file is part of GCC.
4 
5 GCC is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 3, or (at your option) any later
8 version.
9 
10 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 for more details.
14 
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
18 
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
23 
24 #ifndef _LIMITS_H___
25 #define _LIMITS_H___
26 
27 /* Number of bits in a `char'. */
28 #undef CHAR_BIT
29 #define CHAR_BIT __CHAR_BIT__
30 
31 /* Maximum length of a multibyte character. */
32 #ifndef MB_LEN_MAX
33 #define MB_LEN_MAX 1
34 #endif
35 
36 /* Minimum and maximum values a `signed char' can hold. */
37 #undef SCHAR_MIN
38 #define SCHAR_MIN (-SCHAR_MAX - 1)
39 #undef SCHAR_MAX
40 #define SCHAR_MAX __SCHAR_MAX__
41 
42 /* Maximum value an `unsigned char' can hold. (Minimum is 0). */
43 #undef UCHAR_MAX
44 #if __SCHAR_MAX__ == __INT_MAX__
45 # define UCHAR_MAX (SCHAR_MAX * 2U + 1U)
46 #else
47 # define UCHAR_MAX (SCHAR_MAX * 2 + 1)
48 #endif
49 
50 /* Minimum and maximum values a `char' can hold. */
51 #ifdef __CHAR_UNSIGNED__
52 # undef CHAR_MIN
53 # if __SCHAR_MAX__ == __INT_MAX__
54 # define CHAR_MIN 0U
55 # else
56 # define CHAR_MIN 0
57 # endif
58 # undef CHAR_MAX
59 # define CHAR_MAX UCHAR_MAX
60 #else
61 # undef CHAR_MIN
62 # define CHAR_MIN SCHAR_MIN
63 # undef CHAR_MAX
64 # define CHAR_MAX SCHAR_MAX
65 #endif
66 
67 /* Minimum and maximum values a `signed short int' can hold. */
68 #undef SHRT_MIN
69 #define SHRT_MIN (-SHRT_MAX - 1)
70 #undef SHRT_MAX
71 #define SHRT_MAX __SHRT_MAX__
72 
73 /* Maximum value an `unsigned short int' can hold. (Minimum is 0). */
74 #undef USHRT_MAX
75 #if __SHRT_MAX__ == __INT_MAX__
76 # define USHRT_MAX (SHRT_MAX * 2U + 1U)
77 #else
78 # define USHRT_MAX (SHRT_MAX * 2 + 1)
79 #endif
80 
81 /* Minimum and maximum values a `signed int' can hold. */
82 #undef INT_MIN
83 #define INT_MIN (-INT_MAX - 1)
84 #undef INT_MAX
85 #define INT_MAX __INT_MAX__
86 
87 /* Maximum value an `unsigned int' can hold. (Minimum is 0). */
88 #undef UINT_MAX
89 #define UINT_MAX (INT_MAX * 2U + 1U)
90 
91 /* Minimum and maximum values a `signed long int' can hold.
92  (Same as `int'). */
93 #undef LONG_MIN
94 #define LONG_MIN (-LONG_MAX - 1L)
95 #undef LONG_MAX
96 #define LONG_MAX __LONG_MAX__
97 
98 /* Maximum value an `unsigned long int' can hold. (Minimum is 0). */
99 #undef ULONG_MAX
100 #define ULONG_MAX (LONG_MAX * 2UL + 1UL)
101 
102 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
103 /* Minimum and maximum values a `signed long long int' can hold. */
104 # undef LLONG_MIN
105 # define LLONG_MIN (-LLONG_MAX - 1LL)
106 # undef LLONG_MAX
107 # define LLONG_MAX __LONG_LONG_MAX__
108 
109 /* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */
110 # undef ULLONG_MAX
111 # define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
112 #endif
113 
114 #if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__)
115 /* Minimum and maximum values a `signed long long int' can hold. */
116 # undef LONG_LONG_MIN
117 # define LONG_LONG_MIN (-LONG_LONG_MAX - 1LL)
118 # undef LONG_LONG_MAX
119 # define LONG_LONG_MAX __LONG_LONG_MAX__
120 
121 /* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */
122 # undef ULONG_LONG_MAX
123 # define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1ULL)
124 #endif
125 
126 #endif /* _LIMITS_H___ */