1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #if __GNUC__ >= 3
19 @PRAGMA_SYSTEM_HEADER@
20 #endif
21 @PRAGMA_COLUMNS@
22
23 #if defined _GL_ALREADY_INCLUDING_LIMITS_H
24
25
26
27
28
29
30 #@INCLUDE_NEXT@ @NEXT_LIMITS_H@
31
32 #else
33
34
35 #ifndef _@GUARD_PREFIX@_LIMITS_H
36
37 # define _GL_ALREADY_INCLUDING_LIMITS_H
38
39
40 # @INCLUDE_NEXT@ @NEXT_LIMITS_H@
41
42 # undef _GL_ALREADY_INCLUDING_LIMITS_H
43
44 #ifndef _@GUARD_PREFIX@_LIMITS_H
45 #define _@GUARD_PREFIX@_LIMITS_H
46
47 #ifndef LLONG_MIN
48 # if defined LONG_LONG_MIN
49 # define LLONG_MIN LONG_LONG_MIN
50 # elif defined LONGLONG_MIN
51 # define LLONG_MIN LONGLONG_MIN
52 # elif defined __GNUC__
53 # define LLONG_MIN (- __LONG_LONG_MAX__ - 1LL)
54 # endif
55 #endif
56 #ifndef LLONG_MAX
57 # if defined LONG_LONG_MAX
58 # define LLONG_MAX LONG_LONG_MAX
59 # elif defined LONGLONG_MAX
60 # define LLONG_MAX LONGLONG_MAX
61 # elif defined __GNUC__
62 # define LLONG_MAX __LONG_LONG_MAX__
63 # endif
64 #endif
65 #ifndef ULLONG_MAX
66 # if defined ULONG_LONG_MAX
67 # define ULLONG_MAX ULONG_LONG_MAX
68 # elif defined ULONGLONG_MAX
69 # define ULLONG_MAX ULONGLONG_MAX
70 # elif defined __GNUC__
71 # define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1ULL)
72 # endif
73 #endif
74
75
76
77
78
79
80
81 #define _GL_INTEGER_WIDTH(min, max) (((min) < 0) + _GL_COB128 (max))
82 #define _GL_COB128(n) (_GL_COB64 ((n) >> 31 >> 31 >> 2) + _GL_COB64 (n))
83 #define _GL_COB64(n) (_GL_COB32 ((n) >> 31 >> 1) + _GL_COB32 (n))
84 #define _GL_COB32(n) (_GL_COB16 ((n) >> 16) + _GL_COB16 (n))
85 #define _GL_COB16(n) (_GL_COB8 ((n) >> 8) + _GL_COB8 (n))
86 #define _GL_COB8(n) (_GL_COB4 ((n) >> 4) + _GL_COB4 (n))
87 #define _GL_COB4(n) (!!((n) & 8) + !!((n) & 4) + !!((n) & 2) + !!((n) & 1))
88
89 #ifndef WORD_BIT
90
91 # define WORD_BIT 32
92 #endif
93 #ifndef LONG_BIT
94
95 # if LONG_MAX == INT_MAX
96 # define LONG_BIT 32
97 # else
98 # define LONG_BIT 64
99 # endif
100 #endif
101
102
103 #ifndef MB_LEN_MAX
104 # define MB_LEN_MAX 16
105 #endif
106
107
108
109 #if (! defined ULLONG_WIDTH \
110 && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__ \
111 || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__)))
112 # define CHAR_WIDTH _GL_INTEGER_WIDTH (CHAR_MIN, CHAR_MAX)
113 # define SCHAR_WIDTH _GL_INTEGER_WIDTH (SCHAR_MIN, SCHAR_MAX)
114 # define UCHAR_WIDTH _GL_INTEGER_WIDTH (0, UCHAR_MAX)
115 # define SHRT_WIDTH _GL_INTEGER_WIDTH (SHRT_MIN, SHRT_MAX)
116 # define USHRT_WIDTH _GL_INTEGER_WIDTH (0, USHRT_MAX)
117 # define INT_WIDTH _GL_INTEGER_WIDTH (INT_MIN, INT_MAX)
118 # define UINT_WIDTH _GL_INTEGER_WIDTH (0, UINT_MAX)
119 # define LONG_WIDTH _GL_INTEGER_WIDTH (LONG_MIN, LONG_MAX)
120 # define ULONG_WIDTH _GL_INTEGER_WIDTH (0, ULONG_MAX)
121 # define LLONG_WIDTH _GL_INTEGER_WIDTH (LLONG_MIN, LLONG_MAX)
122 # define ULLONG_WIDTH _GL_INTEGER_WIDTH (0, ULLONG_MAX)
123 #endif
124
125
126
127 #if (defined _GNU_SOURCE \
128 || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__))
129 # if ! defined BOOL_WIDTH
130 # define BOOL_WIDTH 1
131 # define BOOL_MAX 1
132 # elif ! defined BOOL_MAX
133 # define BOOL_MAX ((((1U << (BOOL_WIDTH - 1)) - 1) << 1) + 1)
134 # endif
135 #endif
136
137
138
139
140
141 #ifndef SSIZE_MAX
142 # ifdef _WIN64
143 # define SSIZE_MAX LLONG_MAX
144 # else
145 # define SSIZE_MAX LONG_MAX
146 # endif
147 #endif
148
149 #endif
150 #endif
151 #endif