OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8CONFIG_H_ | 5 #ifndef V8CONFIG_H_ |
6 #define V8CONFIG_H_ | 6 #define V8CONFIG_H_ |
7 | 7 |
8 // Platform headers for feature detection below. | 8 // Platform headers for feature detection below. |
9 #if defined(__ANDROID__) | 9 #if defined(__ANDROID__) |
10 # include <sys/cdefs.h> | 10 # include <sys/cdefs.h> |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // | 164 // |
165 // Compiler-specific feature detection | 165 // Compiler-specific feature detection |
166 // | 166 // |
167 // V8_HAS___ALIGNOF - __alignof(type) operator supported | 167 // V8_HAS___ALIGNOF - __alignof(type) operator supported |
168 // V8_HAS___ALIGNOF__ - __alignof__(type) operator supported | 168 // V8_HAS___ALIGNOF__ - __alignof__(type) operator supported |
169 // V8_HAS_ATTRIBUTE_ALIGNED - __attribute__((aligned(n))) supported | 169 // V8_HAS_ATTRIBUTE_ALIGNED - __attribute__((aligned(n))) supported |
170 // V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline)) | 170 // V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline)) |
171 // supported | 171 // supported |
172 // V8_HAS_ATTRIBUTE_DEPRECATED - __attribute__((deprecated)) supported | 172 // V8_HAS_ATTRIBUTE_DEPRECATED - __attribute__((deprecated)) supported |
173 // V8_HAS_ATTRIBUTE_NOINLINE - __attribute__((noinline)) supported | 173 // V8_HAS_ATTRIBUTE_NOINLINE - __attribute__((noinline)) supported |
| 174 // V8_HAS_ATTRIBUTE_NORETURN - __attribute__((noreturn)) supported |
174 // V8_HAS_ATTRIBUTE_UNUSED - __attribute__((unused)) supported | 175 // V8_HAS_ATTRIBUTE_UNUSED - __attribute__((unused)) supported |
175 // V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported | 176 // V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported |
176 // V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT - __attribute__((warn_unused_result)) | 177 // V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT - __attribute__((warn_unused_result)) |
177 // supported | 178 // supported |
178 // V8_HAS_BUILTIN_CLZ - __builtin_clz() supported | 179 // V8_HAS_BUILTIN_CLZ - __builtin_clz() supported |
179 // V8_HAS_BUILTIN_CTZ - __builtin_ctz() supported | 180 // V8_HAS_BUILTIN_CTZ - __builtin_ctz() supported |
180 // V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported | 181 // V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported |
181 // V8_HAS_BUILTIN_FRAME_ADDRESS - __builtin_frame_address() supported | 182 // V8_HAS_BUILTIN_FRAME_ADDRESS - __builtin_frame_address() supported |
182 // V8_HAS_BUILTIN_POPCOUNT - __builtin_popcount() supported | 183 // V8_HAS_BUILTIN_POPCOUNT - __builtin_popcount() supported |
183 // V8_HAS_BUILTIN_SADD_OVERFLOW - __builtin_sadd_overflow() supported | 184 // V8_HAS_BUILTIN_SADD_OVERFLOW - __builtin_sadd_overflow() supported |
184 // V8_HAS_BUILTIN_SSUB_OVERFLOW - __builtin_ssub_overflow() supported | 185 // V8_HAS_BUILTIN_SSUB_OVERFLOW - __builtin_ssub_overflow() supported |
185 // V8_HAS_DECLSPEC_ALIGN - __declspec(align(n)) supported | 186 // V8_HAS_DECLSPEC_ALIGN - __declspec(align(n)) supported |
186 // V8_HAS_DECLSPEC_DEPRECATED - __declspec(deprecated) supported | 187 // V8_HAS_DECLSPEC_DEPRECATED - __declspec(deprecated) supported |
187 // V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported | 188 // V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported |
188 // V8_HAS_DECLSPEC_SELECTANY - __declspec(selectany) supported | 189 // V8_HAS_DECLSPEC_SELECTANY - __declspec(selectany) supported |
| 190 // V8_HAS_DECLSPEC_NORETURN - __declspec(noreturn) supported |
189 // V8_HAS___FINAL - __final supported in non-C++11 mode | 191 // V8_HAS___FINAL - __final supported in non-C++11 mode |
190 // V8_HAS___FORCEINLINE - __forceinline supported | 192 // V8_HAS___FORCEINLINE - __forceinline supported |
191 // | 193 // |
192 // Note that testing for compilers and/or features must be done using #if | 194 // Note that testing for compilers and/or features must be done using #if |
193 // not #ifdef. For example, to test for Intel C++ Compiler, use: | 195 // not #ifdef. For example, to test for Intel C++ Compiler, use: |
194 // #if V8_CC_INTEL | 196 // #if V8_CC_INTEL |
195 // ... | 197 // ... |
196 // #endif | 198 // #endif |
197 | 199 |
198 #if defined(__clang__) | 200 #if defined(__clang__) |
199 | 201 |
200 #if defined(__GNUC__) // Clang in gcc mode. | 202 #if defined(__GNUC__) // Clang in gcc mode. |
201 # define V8_CC_GNU 1 | 203 # define V8_CC_GNU 1 |
202 #elif defined(_MSC_VER) // Clang in cl mode. | 204 #elif defined(_MSC_VER) // Clang in cl mode. |
203 # define V8_CC_MSVC 1 | 205 # define V8_CC_MSVC 1 |
204 #endif | 206 #endif |
205 | 207 |
206 // Clang defines __alignof__ as alias for __alignof | 208 // Clang defines __alignof__ as alias for __alignof |
207 # define V8_HAS___ALIGNOF 1 | 209 # define V8_HAS___ALIGNOF 1 |
208 # define V8_HAS___ALIGNOF__ V8_HAS___ALIGNOF | 210 # define V8_HAS___ALIGNOF__ V8_HAS___ALIGNOF |
209 | 211 |
210 # define V8_HAS_ATTRIBUTE_ALIGNED (__has_attribute(aligned)) | 212 # define V8_HAS_ATTRIBUTE_ALIGNED (__has_attribute(aligned)) |
211 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline)) | 213 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline)) |
212 # define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated)) | 214 # define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated)) |
213 # define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline)) | 215 # define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline)) |
| 216 #define V8_HAS_ATTRIBUTE_NORETURN (__has_attribute(noreturn)) |
214 # define V8_HAS_ATTRIBUTE_UNUSED (__has_attribute(unused)) | 217 # define V8_HAS_ATTRIBUTE_UNUSED (__has_attribute(unused)) |
215 # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility)) | 218 # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility)) |
216 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ | 219 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ |
217 (__has_attribute(warn_unused_result)) | 220 (__has_attribute(warn_unused_result)) |
218 | 221 |
219 # define V8_HAS_BUILTIN_CLZ (__has_builtin(__builtin_clz)) | 222 # define V8_HAS_BUILTIN_CLZ (__has_builtin(__builtin_clz)) |
220 # define V8_HAS_BUILTIN_CTZ (__has_builtin(__builtin_ctz)) | 223 # define V8_HAS_BUILTIN_CTZ (__has_builtin(__builtin_ctz)) |
221 # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect)) | 224 # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect)) |
222 # define V8_HAS_BUILTIN_FRAME_ADDRESS (__has_builtin(__builtin_frame_address)) | 225 # define V8_HAS_BUILTIN_FRAME_ADDRESS (__has_builtin(__builtin_frame_address)) |
223 # define V8_HAS_BUILTIN_POPCOUNT (__has_builtin(__builtin_popcount)) | 226 # define V8_HAS_BUILTIN_POPCOUNT (__has_builtin(__builtin_popcount)) |
(...skipping 18 matching lines...) Expand all Loading... |
242 # define V8_HAS___ALIGNOF__ (V8_GNUC_PREREQ(4, 3, 0)) | 245 # define V8_HAS___ALIGNOF__ (V8_GNUC_PREREQ(4, 3, 0)) |
243 | 246 |
244 # define V8_HAS_ATTRIBUTE_ALIGNED (V8_GNUC_PREREQ(2, 95, 0)) | 247 # define V8_HAS_ATTRIBUTE_ALIGNED (V8_GNUC_PREREQ(2, 95, 0)) |
245 // always_inline is available in gcc 4.0 but not very reliable until 4.4. | 248 // always_inline is available in gcc 4.0 but not very reliable until 4.4. |
246 // Works around "sorry, unimplemented: inlining failed" build errors with | 249 // Works around "sorry, unimplemented: inlining failed" build errors with |
247 // older compilers. | 250 // older compilers. |
248 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (V8_GNUC_PREREQ(4, 4, 0)) | 251 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (V8_GNUC_PREREQ(4, 4, 0)) |
249 # define V8_HAS_ATTRIBUTE_DEPRECATED (V8_GNUC_PREREQ(3, 4, 0)) | 252 # define V8_HAS_ATTRIBUTE_DEPRECATED (V8_GNUC_PREREQ(3, 4, 0)) |
250 # define V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE (V8_GNUC_PREREQ(4, 5, 0)) | 253 # define V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE (V8_GNUC_PREREQ(4, 5, 0)) |
251 # define V8_HAS_ATTRIBUTE_NOINLINE (V8_GNUC_PREREQ(3, 4, 0)) | 254 # define V8_HAS_ATTRIBUTE_NOINLINE (V8_GNUC_PREREQ(3, 4, 0)) |
| 255 #define V8_HAS_ATTRIBUTE_NORETURN (V8_GNUC_PREREQ(2, 5, 0)) |
252 # define V8_HAS_ATTRIBUTE_UNUSED (V8_GNUC_PREREQ(2, 95, 0)) | 256 # define V8_HAS_ATTRIBUTE_UNUSED (V8_GNUC_PREREQ(2, 95, 0)) |
253 # define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0)) | 257 # define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0)) |
254 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ | 258 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ |
255 (!V8_CC_INTEL && V8_GNUC_PREREQ(4, 1, 0)) | 259 (!V8_CC_INTEL && V8_GNUC_PREREQ(4, 1, 0)) |
256 | 260 |
257 # define V8_HAS_BUILTIN_CLZ (V8_GNUC_PREREQ(3, 4, 0)) | 261 # define V8_HAS_BUILTIN_CLZ (V8_GNUC_PREREQ(3, 4, 0)) |
258 # define V8_HAS_BUILTIN_CTZ (V8_GNUC_PREREQ(3, 4, 0)) | 262 # define V8_HAS_BUILTIN_CTZ (V8_GNUC_PREREQ(3, 4, 0)) |
259 # define V8_HAS_BUILTIN_EXPECT (V8_GNUC_PREREQ(2, 96, 0)) | 263 # define V8_HAS_BUILTIN_EXPECT (V8_GNUC_PREREQ(2, 96, 0)) |
260 # define V8_HAS_BUILTIN_FRAME_ADDRESS (V8_GNUC_PREREQ(2, 96, 0)) | 264 # define V8_HAS_BUILTIN_FRAME_ADDRESS (V8_GNUC_PREREQ(2, 96, 0)) |
261 # define V8_HAS_BUILTIN_POPCOUNT (V8_GNUC_PREREQ(3, 4, 0)) | 265 # define V8_HAS_BUILTIN_POPCOUNT (V8_GNUC_PREREQ(3, 4, 0)) |
(...skipping 22 matching lines...) Expand all Loading... |
284 | 288 |
285 # define V8_HAS___ALIGNOF 1 | 289 # define V8_HAS___ALIGNOF 1 |
286 | 290 |
287 # define V8_HAS_CXX11_FINAL 1 | 291 # define V8_HAS_CXX11_FINAL 1 |
288 # define V8_HAS_CXX11_OVERRIDE 1 | 292 # define V8_HAS_CXX11_OVERRIDE 1 |
289 | 293 |
290 # define V8_HAS_DECLSPEC_ALIGN 1 | 294 # define V8_HAS_DECLSPEC_ALIGN 1 |
291 # define V8_HAS_DECLSPEC_DEPRECATED 1 | 295 # define V8_HAS_DECLSPEC_DEPRECATED 1 |
292 # define V8_HAS_DECLSPEC_NOINLINE 1 | 296 # define V8_HAS_DECLSPEC_NOINLINE 1 |
293 # define V8_HAS_DECLSPEC_SELECTANY 1 | 297 # define V8_HAS_DECLSPEC_SELECTANY 1 |
| 298 #define V8_HAS_DECLSPEC_NORETURN 1 |
294 | 299 |
295 # define V8_HAS___FORCEINLINE 1 | 300 # define V8_HAS___FORCEINLINE 1 |
296 | 301 |
297 #endif | 302 #endif |
298 | 303 |
299 | 304 |
300 // ----------------------------------------------------------------------------- | 305 // ----------------------------------------------------------------------------- |
301 // Helper macros | 306 // Helper macros |
302 | 307 |
303 // A macro used to make better inlining. Don't bother for debug builds. | 308 // A macro used to make better inlining. Don't bother for debug builds. |
(...skipping 14 matching lines...) Expand all Loading... |
318 // V8_NOINLINE int GetMinusOne() { return -1; } | 323 // V8_NOINLINE int GetMinusOne() { return -1; } |
319 #if !defined(DEBUG) && V8_HAS_ATTRIBUTE_NOINLINE | 324 #if !defined(DEBUG) && V8_HAS_ATTRIBUTE_NOINLINE |
320 # define V8_NOINLINE __attribute__((noinline)) | 325 # define V8_NOINLINE __attribute__((noinline)) |
321 #elif !defined(DEBUG) && V8_HAS_DECLSPEC_NOINLINE | 326 #elif !defined(DEBUG) && V8_HAS_DECLSPEC_NOINLINE |
322 # define V8_NOINLINE __declspec(noinline) | 327 # define V8_NOINLINE __declspec(noinline) |
323 #else | 328 #else |
324 # define V8_NOINLINE /* NOT SUPPORTED */ | 329 # define V8_NOINLINE /* NOT SUPPORTED */ |
325 #endif | 330 #endif |
326 | 331 |
327 | 332 |
| 333 // A macro used to tell the compiler that a particular function never returns. |
| 334 // Use like: |
| 335 // V8_NORETURN int MyAbort() { abort(); } |
| 336 #if V8_HAS_ATTRIBUTE_NORETURN |
| 337 #define V8_NORETURN __attribute__((noreturn)) |
| 338 #elif HAS_DECLSPEC_NORETURN |
| 339 #define V8_NORETURN __declspec(noreturn) |
| 340 #else |
| 341 #define V8_NORETURN /* NOT SUPPORTED */ |
| 342 #endif |
| 343 |
| 344 |
328 // A macro to mark classes or functions as deprecated. | 345 // A macro to mark classes or functions as deprecated. |
329 #if defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE | 346 #if defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE |
330 # define V8_DEPRECATED(message, declarator) \ | 347 # define V8_DEPRECATED(message, declarator) \ |
331 declarator __attribute__((deprecated(message))) | 348 declarator __attribute__((deprecated(message))) |
332 #elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED | 349 #elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED |
333 # define V8_DEPRECATED(message, declarator) \ | 350 # define V8_DEPRECATED(message, declarator) \ |
334 declarator __attribute__((deprecated)) | 351 declarator __attribute__((deprecated)) |
335 #elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_DECLSPEC_DEPRECATED | 352 #elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_DECLSPEC_DEPRECATED |
336 # define V8_DEPRECATED(message, declarator) __declspec(deprecated) declarator | 353 # define V8_DEPRECATED(message, declarator) __declspec(deprecated) declarator |
337 #else | 354 #else |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 // Annotate a function indicating the caller must examine the return value. | 445 // Annotate a function indicating the caller must examine the return value. |
429 // Use like: | 446 // Use like: |
430 // int foo() WARN_UNUSED_RESULT; | 447 // int foo() WARN_UNUSED_RESULT; |
431 #if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT | 448 #if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT |
432 #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) | 449 #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
433 #else | 450 #else |
434 #define V8_WARN_UNUSED_RESULT /* NOT SUPPORTED */ | 451 #define V8_WARN_UNUSED_RESULT /* NOT SUPPORTED */ |
435 #endif | 452 #endif |
436 | 453 |
437 #endif // V8CONFIG_H_ | 454 #endif // V8CONFIG_H_ |
OLD | NEW |