13 #define HOST_BITS_PER_CHAR CHAR_BIT
14 #define HOST_BITS_PER_SHORT (CHAR_BIT * SIZEOF_SHORT)
15 #define HOST_BITS_PER_INT (CHAR_BIT * SIZEOF_INT)
16 #define HOST_BITS_PER_LONG (CHAR_BIT * SIZEOF_LONG)
20 #ifndef HOST_LONG_FORMAT
21 #define HOST_LONG_FORMAT "l"
26 #ifndef HOST_LONG_LONG_FORMAT
27 #define HOST_LONG_LONG_FORMAT "ll"
36 #if !defined HAVE_LONG_LONG
37 # if GCC_VERSION >= 3000
38 # define HAVE_LONG_LONG 1
39 # define SIZEOF_LONG_LONG 8
40 extern char sizeof_long_long_must_be_8[
sizeof (
long long) == 8 ? 1 : -1];
45 # define HOST_BITS_PER_LONGLONG (CHAR_BIT * SIZEOF_LONG_LONG)
48 # define HOST_BITS_PER___INT64 (CHAR_BIT * SIZEOF___INT64)
59 #if HOST_BITS_PER_LONG >= 64 || !defined NEED_64BIT_HOST_WIDE_INT
60 # define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG
61 # define HOST_WIDE_INT long
62 # define HOST_WIDE_INT_C(X) X ## L
64 # if HOST_BITS_PER_LONGLONG >= 64
65 # define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONGLONG
66 # define HOST_WIDE_INT long long
67 # define HOST_WIDE_INT_C(X) X ## LL
69 # if HOST_BITS_PER___INT64 >= 64
70 # define HOST_BITS_PER_WIDE_INT HOST_BITS_PER___INT64
71 # define HOST_WIDE_INT __int64
72 # define HOST_WIDE_INT_C(X) X ## i64
74 #error "Unable to find a suitable type for HOST_WIDE_INT"
80 #define HOST_BITS_PER_HALF_WIDE_INT (HOST_BITS_PER_WIDE_INT / 2)
81 #if HOST_BITS_PER_HALF_WIDE_INT == HOST_BITS_PER_LONG
82 # define HOST_HALF_WIDE_INT long
83 # define HOST_HALF_WIDE_INT_PRINT HOST_LONG_FORMAT
84 # define HOST_HALF_WIDE_INT_PRINT_C "L"
85 # define HOST_HALF_WIDE_INT_PRINT_DEC "%" HOST_HALF_WIDE_INT_PRINT "d"
86 # define HOST_HALF_WIDE_INT_PRINT_DEC_C HOST_HALF_WIDE_INT_PRINT_DEC HOST_HALF_WIDE_INT_PRINT_C
87 # define HOST_HALF_WIDE_INT_PRINT_UNSIGNED "%" HOST_HALF_WIDE_INT_PRINT "u"
88 # define HOST_HALF_WIDE_INT_PRINT_HEX "%#" HOST_HALF_WIDE_INT_PRINT "x"
89 # define HOST_HALF_WIDE_INT_PRINT_HEX_PURE "%" HOST_HALF_WIDE_INT_PRINT "x"
90 #elif HOST_BITS_PER_HALF_WIDE_INT == HOST_BITS_PER_INT
91 # define HOST_HALF_WIDE_INT int
92 # define HOST_HALF_WIDE_INT_PRINT ""
93 # define HOST_HALF_WIDE_INT_PRINT_C ""
94 # define HOST_HALF_WIDE_INT_PRINT_DEC "%" HOST_HALF_WIDE_INT_PRINT "d"
95 # define HOST_HALF_WIDE_INT_PRINT_DEC_C HOST_HALF_WIDE_INT_PRINT_DEC HOST_HALF_WIDE_INT_PRINT_C
96 # define HOST_HALF_WIDE_INT_PRINT_UNSIGNED "%" HOST_HALF_WIDE_INT_PRINT "u"
97 # define HOST_HALF_WIDE_INT_PRINT_HEX "%#" HOST_HALF_WIDE_INT_PRINT "x"
98 # define HOST_HALF_WIDE_INT_PRINT_HEX_PURE "%" HOST_HALF_WIDE_INT_PRINT "x"
99 #elif HOST_BITS_PER_HALF_WIDE_INT == HOST_BITS_PER_SHORT
100 # define HOST_HALF_WIDE_INT short
101 # define HOST_HALF_WIDE_INT_PRINT ""
102 # define HOST_HALF_WIDE_INT_PRINT_C ""
103 # define HOST_HALF_WIDE_INT_PRINT_DEC "%" HOST_HALF_WIDE_INT_PRINT "d"
104 # define HOST_HALF_WIDE_INT_PRINT_DEC_C HOST_HALF_WIDE_INT_PRINT_DEC HOST_HALF_WIDE_INT_PRINT_C
105 # define HOST_HALF_WIDE_INT_PRINT_UNSIGNED "%" HOST_HALF_WIDE_INT_PRINT "u"
106 # define HOST_HALF_WIDE_INT_PRINT_HEX "%#" HOST_HALF_WIDE_INT_PRINT "x"
107 # define HOST_HALF_WIDE_INT_PRINT_HEX_PURE "%" HOST_HALF_WIDE_INT_PRINT "x"
109 #error Please add support for HOST_HALF_WIDE_INT
113 #define HOST_WIDE_INT_UC(X) HOST_WIDE_INT_C (X ## U)
114 #define HOST_WIDE_INT_1 HOST_WIDE_INT_C (1)
115 #define HOST_WIDE_INT_1U HOST_WIDE_INT_UC (1)
116 #define HOST_WIDE_INT_M1 HOST_WIDE_INT_C (-1)
117 #define HOST_WIDE_INT_M1U HOST_WIDE_INT_UC (-1)
126 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
127 # define HOST_WIDE_INT_PRINT HOST_LONG_FORMAT
128 # define HOST_WIDE_INT_PRINT_C "L"
131 # if HOST_BITS_PER_WIDE_INT == 64
132 # define HOST_WIDE_INT_PRINT_DOUBLE_HEX \
133 "0x%" HOST_LONG_FORMAT "x%016" HOST_LONG_FORMAT "x"
134 # define HOST_WIDE_INT_PRINT_PADDED_HEX \
135 "%016" HOST_LONG_FORMAT "x"
137 # define HOST_WIDE_INT_PRINT_DOUBLE_HEX \
138 "0x%" HOST_LONG_FORMAT "x%08" HOST_LONG_FORMAT "x"
139 # define HOST_WIDE_INT_PRINT_PADDED_HEX \
140 "%08" HOST_LONG_FORMAT "x"
143 # define HOST_WIDE_INT_PRINT HOST_LONG_LONG_FORMAT
144 # define HOST_WIDE_INT_PRINT_C "LL"
146 # define HOST_WIDE_INT_PRINT_DOUBLE_HEX \
147 "0x%" HOST_LONG_LONG_FORMAT "x%016" HOST_LONG_LONG_FORMAT "x"
148 # define HOST_WIDE_INT_PRINT_PADDED_HEX \
149 "%016" HOST_LONG_LONG_FORMAT "x"
152 #define HOST_WIDE_INT_PRINT_DEC "%" HOST_WIDE_INT_PRINT "d"
153 #define HOST_WIDE_INT_PRINT_DEC_C HOST_WIDE_INT_PRINT_DEC HOST_WIDE_INT_PRINT_C
154 #define HOST_WIDE_INT_PRINT_UNSIGNED "%" HOST_WIDE_INT_PRINT "u"
155 #define HOST_WIDE_INT_PRINT_HEX "%#" HOST_WIDE_INT_PRINT "x"
156 #define HOST_WIDE_INT_PRINT_HEX_PURE "%" HOST_WIDE_INT_PRINT "x"
161 #if HOST_BITS_PER_WIDE_INT >= 64 \
162 || (HOST_BITS_PER_LONGLONG < 64 && HOST_BITS_PER___INT64 < 64)
163 # define HOST_WIDEST_INT HOST_WIDE_INT
164 # define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_WIDE_INT
165 # define HOST_WIDEST_INT_PRINT HOST_WIDE_INT_PRINT
166 # define HOST_WIDEST_INT_PRINT_DEC HOST_WIDE_INT_PRINT_DEC
167 # define HOST_WIDEST_INT_PRINT_DEC_C HOST_WIDE_INT_PRINT_DEC_C
168 # define HOST_WIDEST_INT_PRINT_UNSIGNED HOST_WIDE_INT_PRINT_UNSIGNED
169 # define HOST_WIDEST_INT_PRINT_HEX HOST_WIDE_INT_PRINT_HEX
170 # define HOST_WIDEST_INT_PRINT_DOUBLE_HEX HOST_WIDE_INT_PRINT_DOUBLE_HEX
171 # define HOST_WIDEST_INT_C(X) HOST_WIDE_INT (X)
173 # if HOST_BITS_PER_LONGLONG >= 64
174 # define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONGLONG
175 # define HOST_WIDEST_INT long long
176 # define HOST_WIDEST_INT_C(X) X ## LL
178 # if HOST_BITS_PER___INT64 >= 64
179 # define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER___INT64
180 # define HOST_WIDEST_INT __int64
181 # define HOST_WIDEST_INT_C(X) X ## i64
183 #error "This line should be impossible to reach"
186 # define HOST_WIDEST_INT_PRINT HOST_LONG_LONG_FORMAT
187 # define HOST_WIDEST_INT_PRINT_DEC "%" HOST_LONG_LONG_FORMAT "d"
188 # define HOST_WIDEST_INT_PRINT_DEC_C "%" HOST_LONG_LONG_FORMAT "dLL"
189 # define HOST_WIDEST_INT_PRINT_UNSIGNED "%" HOST_LONG_LONG_FORMAT "u"
190 # define HOST_WIDEST_INT_PRINT_HEX "%#" HOST_LONG_LONG_FORMAT "x"
191 # define HOST_WIDEST_INT_PRINT_DOUBLE_HEX \
192 "0x%" HOST_LONG_LONG_FORMAT "x%016" HOST_LONG_LONG_FORMAT "x"
202 #ifdef USE_LONG_LONG_FOR_WIDEST_FAST_INT
203 # ifdef HAVE_LONG_LONG
204 # define HOST_WIDEST_FAST_INT long long
205 # define HOST_BITS_PER_WIDEST_FAST_INT HOST_BITS_PER_LONGLONG
206 # elif defined (HAVE___INT64)
207 # define HOST_WIDEST_FAST_INT __int64
208 # define HOST_BITS_PER_WIDEST_FAST_INT HOST_BITS_PER___INT64
210 # error "Your host said it wanted to use long long or __int64 but neither"
214 # define HOST_WIDEST_FAST_INT long
215 # define HOST_BITS_PER_WIDEST_FAST_INT HOST_BITS_PER_LONG
219 #if GCC_VERSION < 3004
245 # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
246 return __builtin_clzl (x);
247 # elif HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONGLONG
248 return __builtin_clzll (x);
250 return __builtin_clz (x);
259 # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
260 return __builtin_ctzl (x);
261 # elif HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONGLONG
262 return __builtin_ctzll (x);
264 return __builtin_ctz (x);
271 # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
272 return __builtin_ffsl (x);
273 # elif HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONGLONG
274 return __builtin_ffsll (x);
276 return __builtin_ffs (x);
283 # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
284 return __builtin_popcountl (x);
285 # elif HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONGLONG
286 return __builtin_popcountll (x);
288 return __builtin_popcount (x);
307 return x == (x & -x) && x ?
ctz_hwi (x) : -1;
312 #define HOST_WIDE_INT_MIN (HOST_WIDE_INT) \
313 ((unsigned HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT - 1))
314 #define HOST_WIDE_INT_MAX (~(HOST_WIDE_INT_MIN))
334 return (src << shift) >>
shift;