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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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_UNUSED - __attribute__((unused)) supported | 174 // V8_HAS_ATTRIBUTE_UNUSED - __attribute__((unused)) supported |
175 // V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported | 175 // V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported |
176 // V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT - __attribute__((warn_unused_result)) | 176 // V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT - __attribute__((warn_unused_result)) |
177 // supported | 177 // supported |
178 // V8_HAS_BUILTIN_CLZ - __builtin_clz() supported | 178 // V8_HAS_BUILTIN_CLZ - __builtin_clz() supported |
179 // V8_HAS_BUILTIN_CTZ - __builtin_ctz() supported | 179 // V8_HAS_BUILTIN_CTZ - __builtin_ctz() supported |
180 // V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported | 180 // V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported |
181 // V8_HAS_BUILTIN_FRAME_ADDRESS - __builtin_frame_address() supported | |
181 // V8_HAS_BUILTIN_POPCOUNT - __builtin_popcount() supported | 182 // V8_HAS_BUILTIN_POPCOUNT - __builtin_popcount() supported |
182 // V8_HAS_BUILTIN_SADD_OVERFLOW - __builtin_sadd_overflow() supported | 183 // V8_HAS_BUILTIN_SADD_OVERFLOW - __builtin_sadd_overflow() supported |
183 // V8_HAS_BUILTIN_SSUB_OVERFLOW - __builtin_ssub_overflow() supported | 184 // V8_HAS_BUILTIN_SSUB_OVERFLOW - __builtin_ssub_overflow() supported |
184 // V8_HAS_DECLSPEC_ALIGN - __declspec(align(n)) supported | 185 // V8_HAS_DECLSPEC_ALIGN - __declspec(align(n)) supported |
185 // V8_HAS_DECLSPEC_DEPRECATED - __declspec(deprecated) supported | 186 // V8_HAS_DECLSPEC_DEPRECATED - __declspec(deprecated) supported |
186 // V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported | 187 // V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported |
187 // V8_HAS___FINAL - __final supported in non-C++11 mode | 188 // V8_HAS___FINAL - __final supported in non-C++11 mode |
188 // V8_HAS___FORCEINLINE - __forceinline supported | 189 // V8_HAS___FORCEINLINE - __forceinline supported |
189 // V8_HAS_SEALED - MSVC style sealed marker supported | |
190 // | 190 // |
191 // Note that testing for compilers and/or features must be done using #if | 191 // Note that testing for compilers and/or features must be done using #if |
192 // not #ifdef. For example, to test for Intel C++ Compiler, use: | 192 // not #ifdef. For example, to test for Intel C++ Compiler, use: |
193 // #if V8_CC_INTEL | 193 // #if V8_CC_INTEL |
194 // ... | 194 // ... |
195 // #endif | 195 // #endif |
196 | 196 |
197 #if defined(__clang__) | 197 #if defined(__clang__) |
198 | 198 |
199 # define V8_CC_CLANG 1 | 199 # define V8_CC_CLANG 1 |
200 | 200 |
201 // Clang defines __alignof__ as alias for __alignof | 201 // Clang defines __alignof__ as alias for __alignof |
202 # define V8_HAS___ALIGNOF 1 | 202 # define V8_HAS___ALIGNOF 1 |
203 # define V8_HAS___ALIGNOF__ V8_HAS___ALIGNOF | 203 # define V8_HAS___ALIGNOF__ V8_HAS___ALIGNOF |
204 | 204 |
205 # define V8_HAS_ATTRIBUTE_ALIGNED (__has_attribute(aligned)) | 205 # define V8_HAS_ATTRIBUTE_ALIGNED (__has_attribute(aligned)) |
206 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline)) | 206 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline)) |
207 # define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated)) | 207 # define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated)) |
208 # define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline)) | 208 # define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline)) |
209 # define V8_HAS_ATTRIBUTE_UNUSED (__has_attribute(unused)) | 209 # define V8_HAS_ATTRIBUTE_UNUSED (__has_attribute(unused)) |
210 # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility)) | 210 # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility)) |
211 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ | 211 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ |
212 (__has_attribute(warn_unused_result)) | 212 (__has_attribute(warn_unused_result)) |
213 | 213 |
214 # define V8_HAS_BUILTIN_CLZ (__has_builtin(__builtin_clz)) | 214 # define V8_HAS_BUILTIN_CLZ (__has_builtin(__builtin_clz)) |
215 # define V8_HAS_BUILTIN_CTZ (__has_builtin(__builtin_ctz)) | 215 # define V8_HAS_BUILTIN_CTZ (__has_builtin(__builtin_ctz)) |
216 # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect)) | 216 # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect)) |
217 # define V8_HAS_BUILTIN_FRAME_ADDRESS (__has_builtin(__builtin_frame_address)) | |
217 # define V8_HAS_BUILTIN_POPCOUNT (__has_builtin(__builtin_popcount)) | 218 # define V8_HAS_BUILTIN_POPCOUNT (__has_builtin(__builtin_popcount)) |
218 # define V8_HAS_BUILTIN_SADD_OVERFLOW (__has_builtin(__builtin_sadd_overflow)) | 219 # define V8_HAS_BUILTIN_SADD_OVERFLOW (__has_builtin(__builtin_sadd_overflow)) |
219 # define V8_HAS_BUILTIN_SSUB_OVERFLOW (__has_builtin(__builtin_ssub_overflow)) | 220 # define V8_HAS_BUILTIN_SSUB_OVERFLOW (__has_builtin(__builtin_ssub_overflow)) |
220 | 221 |
221 # define V8_HAS_CXX11_ALIGNAS (__has_feature(cxx_alignas)) | 222 # define V8_HAS_CXX11_ALIGNAS (__has_feature(cxx_alignas)) |
222 # define V8_HAS_CXX11_STATIC_ASSERT (__has_feature(cxx_static_assert)) | 223 # define V8_HAS_CXX11_STATIC_ASSERT (__has_feature(cxx_static_assert)) |
223 # define V8_HAS_CXX11_DELETE (__has_feature(cxx_deleted_functions)) | 224 # define V8_HAS_CXX11_DELETE (__has_feature(cxx_deleted_functions)) |
224 # define V8_HAS_CXX11_FINAL (__has_feature(cxx_override_control)) | 225 # define V8_HAS_CXX11_FINAL (__has_feature(cxx_override_control)) |
225 # define V8_HAS_CXX11_OVERRIDE (__has_feature(cxx_override_control)) | 226 # define V8_HAS_CXX11_OVERRIDE (__has_feature(cxx_override_control)) |
226 | 227 |
(...skipping 17 matching lines...) Expand all Loading... | |
244 # define V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE (V8_GNUC_PREREQ(4, 5, 0)) | 245 # define V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE (V8_GNUC_PREREQ(4, 5, 0)) |
245 # define V8_HAS_ATTRIBUTE_NOINLINE (V8_GNUC_PREREQ(3, 4, 0)) | 246 # define V8_HAS_ATTRIBUTE_NOINLINE (V8_GNUC_PREREQ(3, 4, 0)) |
246 # define V8_HAS_ATTRIBUTE_UNUSED (V8_GNUC_PREREQ(2, 95, 0)) | 247 # define V8_HAS_ATTRIBUTE_UNUSED (V8_GNUC_PREREQ(2, 95, 0)) |
247 # define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0)) | 248 # define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0)) |
248 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ | 249 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ |
249 (!V8_CC_INTEL && V8_GNUC_PREREQ(4, 1, 0)) | 250 (!V8_CC_INTEL && V8_GNUC_PREREQ(4, 1, 0)) |
250 | 251 |
251 # define V8_HAS_BUILTIN_CLZ (V8_GNUC_PREREQ(3, 4, 0)) | 252 # define V8_HAS_BUILTIN_CLZ (V8_GNUC_PREREQ(3, 4, 0)) |
252 # define V8_HAS_BUILTIN_CTZ (V8_GNUC_PREREQ(3, 4, 0)) | 253 # define V8_HAS_BUILTIN_CTZ (V8_GNUC_PREREQ(3, 4, 0)) |
253 # define V8_HAS_BUILTIN_EXPECT (V8_GNUC_PREREQ(2, 96, 0)) | 254 # define V8_HAS_BUILTIN_EXPECT (V8_GNUC_PREREQ(2, 96, 0)) |
255 # define V8_HAS_BUILTIN_FRAME_ADDRESS (V8_GNUC_PREREQ(2, 96, 0)) | |
254 # define V8_HAS_BUILTIN_POPCOUNT (V8_GNUC_PREREQ(3, 4, 0)) | 256 # define V8_HAS_BUILTIN_POPCOUNT (V8_GNUC_PREREQ(3, 4, 0)) |
255 | 257 |
256 // g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality | 258 // g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality |
257 // without warnings (functionality used by the macros below). These modes | 259 // without warnings (functionality used by the macros below). These modes |
258 // are detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, | 260 // are detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, |
259 // more standardly, by checking whether __cplusplus has a C++11 or greater | 261 // more standardly, by checking whether __cplusplus has a C++11 or greater |
260 // value. Current versions of g++ do not correctly set __cplusplus, so we check | 262 // value. Current versions of g++ do not correctly set __cplusplus, so we check |
261 // both for forward compatibility. | 263 // both for forward compatibility. |
262 # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L | 264 # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L |
263 # define V8_HAS_CXX11_ALIGNAS (V8_GNUC_PREREQ(4, 8, 0)) | 265 # define V8_HAS_CXX11_ALIGNAS (V8_GNUC_PREREQ(4, 8, 0)) |
264 # define V8_HAS_CXX11_ALIGNOF (V8_GNUC_PREREQ(4, 8, 0)) | 266 # define V8_HAS_CXX11_ALIGNOF (V8_GNUC_PREREQ(4, 8, 0)) |
265 # define V8_HAS_CXX11_STATIC_ASSERT (V8_GNUC_PREREQ(4, 3, 0)) | 267 # define V8_HAS_CXX11_STATIC_ASSERT (V8_GNUC_PREREQ(4, 3, 0)) |
266 # define V8_HAS_CXX11_DELETE (V8_GNUC_PREREQ(4, 4, 0)) | 268 # define V8_HAS_CXX11_DELETE (V8_GNUC_PREREQ(4, 4, 0)) |
267 # define V8_HAS_CXX11_OVERRIDE (V8_GNUC_PREREQ(4, 7, 0)) | 269 # define V8_HAS_CXX11_OVERRIDE (V8_GNUC_PREREQ(4, 7, 0)) |
268 # define V8_HAS_CXX11_FINAL (V8_GNUC_PREREQ(4, 7, 0)) | 270 # define V8_HAS_CXX11_FINAL (V8_GNUC_PREREQ(4, 7, 0)) |
269 # else | 271 # else |
270 // '__final' is a non-C++11 GCC synonym for 'final', per GCC r176655. | 272 // '__final' is a non-C++11 GCC synonym for 'final', per GCC r176655. |
271 # define V8_HAS___FINAL (V8_GNUC_PREREQ(4, 7, 0)) | 273 # define V8_HAS___FINAL (V8_GNUC_PREREQ(4, 7, 0)) |
272 # endif | 274 # endif |
273 | 275 |
274 #elif defined(_MSC_VER) | 276 #elif defined(_MSC_VER) |
275 | 277 |
276 # define V8_CC_MSVC 1 | 278 # define V8_CC_MSVC 1 |
277 | 279 |
278 # define V8_HAS___ALIGNOF 1 | 280 # define V8_HAS___ALIGNOF 1 |
279 | 281 |
280 // Override control was added with Visual Studio 2005, but | 282 // Override control was added with Visual Studio 2005, but |
281 // Visual Studio 2010 and earlier spell "final" as "sealed". | 283 // Visual Studio 2010 and earlier spell "final" as "sealed". |
Sven Panne
2014/10/20 12:02:13
The comment above is not useful anymore => nuke it
Benedikt Meurer
2014/10/20 12:03:20
Done.
| |
282 # define V8_HAS_CXX11_FINAL (_MSC_VER >= 1700) | 284 # define V8_HAS_CXX11_FINAL 1 |
283 # define V8_HAS_CXX11_OVERRIDE (_MSC_VER >= 1400) | 285 # define V8_HAS_CXX11_OVERRIDE 1 |
284 # define V8_HAS_SEALED (_MSC_VER >= 1400) | |
285 | 286 |
286 # define V8_HAS_DECLSPEC_ALIGN 1 | 287 # define V8_HAS_DECLSPEC_ALIGN 1 |
287 # define V8_HAS_DECLSPEC_DEPRECATED (_MSC_VER >= 1300) | 288 # define V8_HAS_DECLSPEC_DEPRECATED 1 |
288 # define V8_HAS_DECLSPEC_NOINLINE 1 | 289 # define V8_HAS_DECLSPEC_NOINLINE 1 |
289 | 290 |
290 # define V8_HAS___FORCEINLINE 1 | 291 # define V8_HAS___FORCEINLINE 1 |
291 | 292 |
292 #endif | 293 #endif |
293 | 294 |
294 | 295 |
295 // ----------------------------------------------------------------------------- | 296 // ----------------------------------------------------------------------------- |
296 // Helper macros | 297 // Helper macros |
297 | 298 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
410 # define V8_ALIGNOF(type) __alignof__(type) | 411 # define V8_ALIGNOF(type) __alignof__(type) |
411 #else | 412 #else |
412 // Note that alignment of a type within a struct can be less than the | 413 // Note that alignment of a type within a struct can be less than the |
413 // alignment of the type stand-alone (because of ancient ABIs), so this | 414 // alignment of the type stand-alone (because of ancient ABIs), so this |
414 // should only be used as a last resort. | 415 // should only be used as a last resort. |
415 namespace v8 { template <typename T> class AlignOfHelper { char c; T t; }; } | 416 namespace v8 { template <typename T> class AlignOfHelper { char c; T t; }; } |
416 # define V8_ALIGNOF(type) (sizeof(::v8::AlignOfHelper<type>) - sizeof(type)) | 417 # define V8_ALIGNOF(type) (sizeof(::v8::AlignOfHelper<type>) - sizeof(type)) |
417 #endif | 418 #endif |
418 | 419 |
419 #endif // V8CONFIG_H_ | 420 #endif // V8CONFIG_H_ |
OLD | NEW |