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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // V8_CC_MINGW - Minimalist GNU for Windows | 155 // V8_CC_MINGW - Minimalist GNU for Windows |
156 // V8_CC_MINGW32 - Minimalist GNU for Windows (mingw32) | 156 // V8_CC_MINGW32 - Minimalist GNU for Windows (mingw32) |
157 // V8_CC_MINGW64 - Minimalist GNU for Windows (mingw-w64) | 157 // V8_CC_MINGW64 - Minimalist GNU for Windows (mingw-w64) |
158 // V8_CC_MSVC - Microsoft Visual C/C++, or clang in cl.exe mode | 158 // V8_CC_MSVC - Microsoft Visual C/C++, or clang in cl.exe mode |
159 // | 159 // |
160 // C++11 feature detection | 160 // C++11 feature detection |
161 // | 161 // |
162 // V8_HAS_CXX11_ALIGNAS - alignas specifier supported | 162 // V8_HAS_CXX11_ALIGNAS - alignas specifier supported |
163 // V8_HAS_CXX11_ALIGNOF - alignof(type) operator supported | 163 // V8_HAS_CXX11_ALIGNOF - alignof(type) operator supported |
164 // V8_HAS_CXX11_STATIC_ASSERT - static_assert() supported | 164 // V8_HAS_CXX11_STATIC_ASSERT - static_assert() supported |
165 // V8_HAS_CXX11_DELETE - deleted functions supported | |
166 // | 165 // |
167 // Compiler-specific feature detection | 166 // Compiler-specific feature detection |
168 // | 167 // |
169 // V8_HAS___ALIGNOF - __alignof(type) operator supported | 168 // V8_HAS___ALIGNOF - __alignof(type) operator supported |
170 // V8_HAS___ALIGNOF__ - __alignof__(type) operator supported | 169 // V8_HAS___ALIGNOF__ - __alignof__(type) operator supported |
171 // V8_HAS_ATTRIBUTE_ALIGNED - __attribute__((aligned(n))) supported | 170 // V8_HAS_ATTRIBUTE_ALIGNED - __attribute__((aligned(n))) supported |
172 // V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline)) | 171 // V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline)) |
173 // supported | 172 // supported |
174 // V8_HAS_ATTRIBUTE_DEPRECATED - __attribute__((deprecated)) supported | 173 // V8_HAS_ATTRIBUTE_DEPRECATED - __attribute__((deprecated)) supported |
175 // V8_HAS_ATTRIBUTE_NOINLINE - __attribute__((noinline)) supported | 174 // V8_HAS_ATTRIBUTE_NOINLINE - __attribute__((noinline)) supported |
176 // V8_HAS_ATTRIBUTE_UNUSED - __attribute__((unused)) supported | 175 // V8_HAS_ATTRIBUTE_UNUSED - __attribute__((unused)) supported |
177 // V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported | 176 // V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported |
178 // V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT - __attribute__((warn_unused_result)) | 177 // V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT - __attribute__((warn_unused_result)) |
179 // supported | 178 // supported |
180 // V8_HAS_BUILTIN_CLZ - __builtin_clz() supported | 179 // V8_HAS_BUILTIN_CLZ - __builtin_clz() supported |
181 // V8_HAS_BUILTIN_CTZ - __builtin_ctz() supported | 180 // V8_HAS_BUILTIN_CTZ - __builtin_ctz() supported |
182 // V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported | 181 // V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported |
183 // V8_HAS_BUILTIN_FRAME_ADDRESS - __builtin_frame_address() supported | 182 // V8_HAS_BUILTIN_FRAME_ADDRESS - __builtin_frame_address() supported |
184 // V8_HAS_BUILTIN_POPCOUNT - __builtin_popcount() supported | 183 // V8_HAS_BUILTIN_POPCOUNT - __builtin_popcount() supported |
185 // V8_HAS_BUILTIN_SADD_OVERFLOW - __builtin_sadd_overflow() supported | 184 // V8_HAS_BUILTIN_SADD_OVERFLOW - __builtin_sadd_overflow() supported |
186 // V8_HAS_BUILTIN_SSUB_OVERFLOW - __builtin_ssub_overflow() supported | 185 // V8_HAS_BUILTIN_SSUB_OVERFLOW - __builtin_ssub_overflow() supported |
187 // V8_HAS_DECLSPEC_ALIGN - __declspec(align(n)) supported | 186 // V8_HAS_DECLSPEC_ALIGN - __declspec(align(n)) supported |
188 // V8_HAS_DECLSPEC_DEPRECATED - __declspec(deprecated) supported | 187 // V8_HAS_DECLSPEC_DEPRECATED - __declspec(deprecated) supported |
189 // V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported | 188 // V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported |
190 // V8_HAS_DECLSPEC_SELECTANY - __declspec(selectany) supported | 189 // V8_HAS_DECLSPEC_SELECTANY - __declspec(selectany) supported |
191 // V8_HAS___FINAL - __final supported in non-C++11 mode | |
192 // V8_HAS___FORCEINLINE - __forceinline supported | 190 // V8_HAS___FORCEINLINE - __forceinline supported |
193 // | 191 // |
194 // Note that testing for compilers and/or features must be done using #if | 192 // Note that testing for compilers and/or features must be done using #if |
195 // not #ifdef. For example, to test for Intel C++ Compiler, use: | 193 // not #ifdef. For example, to test for Intel C++ Compiler, use: |
196 // #if V8_CC_INTEL | 194 // #if V8_CC_INTEL |
197 // ... | 195 // ... |
198 // #endif | 196 // #endif |
199 | 197 |
200 #if defined(__clang__) | 198 #if defined(__clang__) |
201 | 199 |
(...skipping 19 matching lines...) Expand all Loading... |
221 # define V8_HAS_BUILTIN_CLZ (__has_builtin(__builtin_clz)) | 219 # define V8_HAS_BUILTIN_CLZ (__has_builtin(__builtin_clz)) |
222 # define V8_HAS_BUILTIN_CTZ (__has_builtin(__builtin_ctz)) | 220 # define V8_HAS_BUILTIN_CTZ (__has_builtin(__builtin_ctz)) |
223 # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect)) | 221 # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect)) |
224 # define V8_HAS_BUILTIN_FRAME_ADDRESS (__has_builtin(__builtin_frame_address)) | 222 # define V8_HAS_BUILTIN_FRAME_ADDRESS (__has_builtin(__builtin_frame_address)) |
225 # define V8_HAS_BUILTIN_POPCOUNT (__has_builtin(__builtin_popcount)) | 223 # define V8_HAS_BUILTIN_POPCOUNT (__has_builtin(__builtin_popcount)) |
226 # define V8_HAS_BUILTIN_SADD_OVERFLOW (__has_builtin(__builtin_sadd_overflow)) | 224 # define V8_HAS_BUILTIN_SADD_OVERFLOW (__has_builtin(__builtin_sadd_overflow)) |
227 # define V8_HAS_BUILTIN_SSUB_OVERFLOW (__has_builtin(__builtin_ssub_overflow)) | 225 # define V8_HAS_BUILTIN_SSUB_OVERFLOW (__has_builtin(__builtin_ssub_overflow)) |
228 | 226 |
229 # define V8_HAS_CXX11_ALIGNAS (__has_feature(cxx_alignas)) | 227 # define V8_HAS_CXX11_ALIGNAS (__has_feature(cxx_alignas)) |
230 # define V8_HAS_CXX11_STATIC_ASSERT (__has_feature(cxx_static_assert)) | 228 # define V8_HAS_CXX11_STATIC_ASSERT (__has_feature(cxx_static_assert)) |
231 # define V8_HAS_CXX11_DELETE (__has_feature(cxx_deleted_functions)) | |
232 | 229 |
233 #elif defined(__GNUC__) | 230 #elif defined(__GNUC__) |
234 | 231 |
235 # define V8_CC_GNU 1 | 232 # define V8_CC_GNU 1 |
236 // Intel C++ also masquerades as GCC 3.2.0 | 233 // Intel C++ also masquerades as GCC 3.2.0 |
237 # define V8_CC_INTEL (defined(__INTEL_COMPILER)) | 234 # define V8_CC_INTEL (defined(__INTEL_COMPILER)) |
238 # define V8_CC_MINGW32 (defined(__MINGW32__)) | 235 # define V8_CC_MINGW32 (defined(__MINGW32__)) |
239 # define V8_CC_MINGW64 (defined(__MINGW64__)) | 236 # define V8_CC_MINGW64 (defined(__MINGW64__)) |
240 # define V8_CC_MINGW (V8_CC_MINGW32 || V8_CC_MINGW64) | 237 # define V8_CC_MINGW (V8_CC_MINGW32 || V8_CC_MINGW64) |
241 | 238 |
(...skipping 21 matching lines...) Expand all Loading... |
263 // g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality | 260 // g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality |
264 // without warnings (functionality used by the macros below). These modes | 261 // without warnings (functionality used by the macros below). These modes |
265 // are detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, | 262 // are detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, |
266 // more standardly, by checking whether __cplusplus has a C++11 or greater | 263 // more standardly, by checking whether __cplusplus has a C++11 or greater |
267 // value. Current versions of g++ do not correctly set __cplusplus, so we check | 264 // value. Current versions of g++ do not correctly set __cplusplus, so we check |
268 // both for forward compatibility. | 265 // both for forward compatibility. |
269 # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L | 266 # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L |
270 # define V8_HAS_CXX11_ALIGNAS (V8_GNUC_PREREQ(4, 8, 0)) | 267 # define V8_HAS_CXX11_ALIGNAS (V8_GNUC_PREREQ(4, 8, 0)) |
271 # define V8_HAS_CXX11_ALIGNOF (V8_GNUC_PREREQ(4, 8, 0)) | 268 # define V8_HAS_CXX11_ALIGNOF (V8_GNUC_PREREQ(4, 8, 0)) |
272 # define V8_HAS_CXX11_STATIC_ASSERT (V8_GNUC_PREREQ(4, 3, 0)) | 269 # define V8_HAS_CXX11_STATIC_ASSERT (V8_GNUC_PREREQ(4, 3, 0)) |
273 # define V8_HAS_CXX11_DELETE (V8_GNUC_PREREQ(4, 4, 0)) | |
274 # define V8_HAS_CXX11_OVERRIDE (V8_GNUC_PREREQ(4, 7, 0)) | |
275 # define V8_HAS_CXX11_FINAL (V8_GNUC_PREREQ(4, 7, 0)) | |
276 # else | |
277 // '__final' is a non-C++11 GCC synonym for 'final', per GCC r176655. | |
278 # define V8_HAS___FINAL (V8_GNUC_PREREQ(4, 7, 0)) | |
279 # endif | 270 # endif |
280 | 271 |
281 #elif defined(_MSC_VER) | 272 #elif defined(_MSC_VER) |
282 | 273 |
283 # define V8_CC_MSVC 1 | 274 # define V8_CC_MSVC 1 |
284 | 275 |
285 # define V8_HAS___ALIGNOF 1 | 276 # define V8_HAS___ALIGNOF 1 |
286 | 277 |
287 # define V8_HAS_CXX11_FINAL 1 | |
288 # define V8_HAS_CXX11_OVERRIDE 1 | |
289 | |
290 # define V8_HAS_DECLSPEC_ALIGN 1 | 278 # define V8_HAS_DECLSPEC_ALIGN 1 |
291 # define V8_HAS_DECLSPEC_DEPRECATED 1 | 279 # define V8_HAS_DECLSPEC_DEPRECATED 1 |
292 # define V8_HAS_DECLSPEC_NOINLINE 1 | 280 # define V8_HAS_DECLSPEC_NOINLINE 1 |
293 # define V8_HAS_DECLSPEC_SELECTANY 1 | 281 # define V8_HAS_DECLSPEC_SELECTANY 1 |
294 | 282 |
295 # define V8_HAS___FORCEINLINE 1 | 283 # define V8_HAS___FORCEINLINE 1 |
296 | 284 |
297 #endif | 285 #endif |
298 | 286 |
299 | 287 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 // A macro to provide the compiler with branch prediction information. | 334 // A macro to provide the compiler with branch prediction information. |
347 #if V8_HAS_BUILTIN_EXPECT | 335 #if V8_HAS_BUILTIN_EXPECT |
348 # define V8_UNLIKELY(condition) (__builtin_expect(!!(condition), 0)) | 336 # define V8_UNLIKELY(condition) (__builtin_expect(!!(condition), 0)) |
349 # define V8_LIKELY(condition) (__builtin_expect(!!(condition), 1)) | 337 # define V8_LIKELY(condition) (__builtin_expect(!!(condition), 1)) |
350 #else | 338 #else |
351 # define V8_UNLIKELY(condition) (condition) | 339 # define V8_UNLIKELY(condition) (condition) |
352 # define V8_LIKELY(condition) (condition) | 340 # define V8_LIKELY(condition) (condition) |
353 #endif | 341 #endif |
354 | 342 |
355 | 343 |
356 // A macro to specify that a method is deleted from the corresponding class. | |
357 // Any attempt to use the method will always produce an error at compile time | |
358 // when this macro can be implemented (i.e. if the compiler supports C++11). | |
359 // If the current compiler does not support C++11, use of the annotated method | |
360 // will still cause an error, but the error will most likely occur at link time | |
361 // rather than at compile time. As a backstop, method declarations using this | |
362 // macro should be private. | |
363 // Use like: | |
364 // class A { | |
365 // private: | |
366 // A(const A& other) V8_DELETE; | |
367 // A& operator=(const A& other) V8_DELETE; | |
368 // }; | |
369 #if V8_HAS_CXX11_DELETE | |
370 # define V8_DELETE = delete | |
371 #else | |
372 # define V8_DELETE /* NOT SUPPORTED */ | |
373 #endif | |
374 | |
375 | |
376 // This macro allows to specify memory alignment for structs, classes, etc. | 344 // This macro allows to specify memory alignment for structs, classes, etc. |
377 // Use like: | 345 // Use like: |
378 // class V8_ALIGNED(16) MyClass { ... }; | 346 // class V8_ALIGNED(16) MyClass { ... }; |
379 // V8_ALIGNED(32) int array[42]; | 347 // V8_ALIGNED(32) int array[42]; |
380 #if V8_HAS_CXX11_ALIGNAS | 348 #if V8_HAS_CXX11_ALIGNAS |
381 # define V8_ALIGNED(n) alignas(n) | 349 # define V8_ALIGNED(n) alignas(n) |
382 #elif V8_HAS_ATTRIBUTE_ALIGNED | 350 #elif V8_HAS_ATTRIBUTE_ALIGNED |
383 # define V8_ALIGNED(n) __attribute__((aligned(n))) | 351 # define V8_ALIGNED(n) __attribute__((aligned(n))) |
384 #elif V8_HAS_DECLSPEC_ALIGN | 352 #elif V8_HAS_DECLSPEC_ALIGN |
385 # define V8_ALIGNED(n) __declspec(align(n)) | 353 # define V8_ALIGNED(n) __declspec(align(n)) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 // Annotate a function indicating the caller must examine the return value. | 396 // Annotate a function indicating the caller must examine the return value. |
429 // Use like: | 397 // Use like: |
430 // int foo() WARN_UNUSED_RESULT; | 398 // int foo() WARN_UNUSED_RESULT; |
431 #if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT | 399 #if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT |
432 #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) | 400 #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
433 #else | 401 #else |
434 #define V8_WARN_UNUSED_RESULT /* NOT SUPPORTED */ | 402 #define V8_WARN_UNUSED_RESULT /* NOT SUPPORTED */ |
435 #endif | 403 #endif |
436 | 404 |
437 #endif // V8CONFIG_H_ | 405 #endif // V8CONFIG_H_ |
OLD | NEW |