v8
3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
Main Page
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
v8config.h
Go to the documentation of this file.
1
// Copyright 2013 the V8 project authors. All rights reserved.
2
// Redistribution and use in source and binary forms, with or without
3
// modification, are permitted provided that the following conditions are
4
// met:
5
//
6
// * Redistributions of source code must retain the above copyright
7
// notice, this list of conditions and the following disclaimer.
8
// * Redistributions in binary form must reproduce the above
9
// copyright notice, this list of conditions and the following
10
// disclaimer in the documentation and/or other materials provided
11
// with the distribution.
12
// * Neither the name of Google Inc. nor the names of its
13
// contributors may be used to endorse or promote products derived
14
// from this software without specific prior written permission.
15
//
16
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
#ifndef V8CONFIG_H_
29
#define V8CONFIG_H_
30
31
// Platform headers for feature detection below.
32
#if defined(__ANDROID__)
33
# include <sys/cdefs.h>
34
#elif defined(__APPLE__)
35
# include <TargetConditionals.h>
36
#elif defined(__linux__)
37
# include <features.h>
38
#endif
39
40
41
// This macro allows to test for the version of the GNU C library (or
42
// a compatible C library that masquerades as glibc). It evaluates to
43
// 0 if libc is not GNU libc or compatible.
44
// Use like:
45
// #if V8_GLIBC_PREREQ(2, 3)
46
// ...
47
// #endif
48
#if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
49
# define V8_GLIBC_PREREQ(major, minor) \
50
((__GLIBC__ * 100 + __GLIBC_MINOR__) >= ((major) * 100 + (minor)))
51
#else
52
# define V8_GLIBC_PREREQ(major, minor) 0
53
#endif
54
55
56
// This macro allows to test for the version of the GNU C++ compiler.
57
// Note that this also applies to compilers that masquerade as GCC,
58
// for example clang and the Intel C++ compiler for Linux.
59
// Use like:
60
// #if V8_GNUC_PREREQ(4, 3, 1)
61
// ...
62
// #endif
63
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
64
# define V8_GNUC_PREREQ(major, minor, patchlevel) \
65
((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= \
66
((major) * 10000 + (minor) * 100 + (patchlevel)))
67
#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
68
# define V8_GNUC_PREREQ(major, minor, patchlevel) \
69
((__GNUC__ * 10000 + __GNUC_MINOR__) >= \
70
((major) * 10000 + (minor) * 100 + (patchlevel)))
71
#else
72
# define V8_GNUC_PREREQ(major, minor, patchlevel) 0
73
#endif
74
75
76
77
// -----------------------------------------------------------------------------
78
// Operating system detection
79
//
80
// V8_OS_ANDROID - Android
81
// V8_OS_BSD - BSDish (Mac OS X, Net/Free/Open/DragonFlyBSD)
82
// V8_OS_CYGWIN - Cygwin
83
// V8_OS_DRAGONFLYBSD - DragonFlyBSD
84
// V8_OS_FREEBSD - FreeBSD
85
// V8_OS_LINUX - Linux
86
// V8_OS_MACOSX - Mac OS X
87
// V8_OS_NACL - Native Client
88
// V8_OS_NETBSD - NetBSD
89
// V8_OS_OPENBSD - OpenBSD
90
// V8_OS_POSIX - POSIX compatible (mostly everything except Windows)
91
// V8_OS_QNX - QNX Neutrino
92
// V8_OS_SOLARIS - Sun Solaris and OpenSolaris
93
// V8_OS_WIN - Microsoft Windows
94
95
#if defined(__ANDROID__)
96
# define V8_OS_ANDROID 1
97
# define V8_OS_LINUX 1
98
# define V8_OS_POSIX 1
99
#elif defined(__APPLE__)
100
# define V8_OS_BSD 1
101
# define V8_OS_MACOSX 1
102
# define V8_OS_POSIX 1
103
#elif defined(__native_client__)
104
# define V8_OS_NACL 1
105
# define V8_OS_POSIX 1
106
#elif defined(__CYGWIN__)
107
# define V8_OS_CYGWIN 1
108
# define V8_OS_POSIX 1
109
#elif defined(__linux__)
110
# define V8_OS_LINUX 1
111
# define V8_OS_POSIX 1
112
#elif defined(__sun)
113
# define V8_OS_POSIX 1
114
# define V8_OS_SOLARIS 1
115
#elif defined(__FreeBSD__)
116
# define V8_OS_BSD 1
117
# define V8_OS_FREEBSD 1
118
# define V8_OS_POSIX 1
119
#elif defined(__DragonFly__)
120
# define V8_OS_BSD 1
121
# define V8_OS_DRAGONFLYBSD 1
122
# define V8_OS_POSIX 1
123
#elif defined(__NetBSD__)
124
# define V8_OS_BSD 1
125
# define V8_OS_NETBSD 1
126
# define V8_OS_POSIX 1
127
#elif defined(__OpenBSD__)
128
# define V8_OS_BSD 1
129
# define V8_OS_OPENBSD 1
130
# define V8_OS_POSIX 1
131
#elif defined(__QNXNTO__)
132
# define V8_OS_POSIX 1
133
# define V8_OS_QNX 1
134
#elif defined(_WIN32)
135
# define V8_OS_WIN 1
136
#endif
137
138
139
// -----------------------------------------------------------------------------
140
// C library detection
141
//
142
// V8_LIBC_MSVCRT - MSVC libc
143
// V8_LIBC_BIONIC - Bionic libc
144
// V8_LIBC_BSD - BSD libc derivate
145
// V8_LIBC_GLIBC - GNU C library
146
// V8_LIBC_UCLIBC - uClibc
147
//
148
// Note that testing for libc must be done using #if not #ifdef. For example,
149
// to test for the GNU C library, use:
150
// #if V8_LIBC_GLIBC
151
// ...
152
// #endif
153
154
#if defined (_MSC_VER)
155
# define V8_LIBC_MSVCRT 1
156
#elif defined(__BIONIC__)
157
# define V8_LIBC_BIONIC 1
158
# define V8_LIBC_BSD 1
159
#elif defined(__UCLIBC__)
160
# define V8_LIBC_UCLIBC 1
161
#elif defined(__GLIBC__) || defined(__GNU_LIBRARY__)
162
# define V8_LIBC_GLIBC 1
163
#else
164
# define V8_LIBC_BSD V8_OS_BSD
165
#endif
166
167
168
// -----------------------------------------------------------------------------
169
// Compiler detection
170
//
171
// V8_CC_CLANG - Clang
172
// V8_CC_GNU - GNU C++
173
// V8_CC_INTEL - Intel C++
174
// V8_CC_MINGW - Minimalist GNU for Windows
175
// V8_CC_MINGW32 - Minimalist GNU for Windows (mingw32)
176
// V8_CC_MINGW64 - Minimalist GNU for Windows (mingw-w64)
177
// V8_CC_MSVC - Microsoft Visual C/C++
178
//
179
// C++11 feature detection
180
//
181
// V8_HAS_CXX11_ALIGNAS - alignas specifier supported
182
// V8_HAS_CXX11_ALIGNOF - alignof(type) operator supported
183
// V8_HAS_CXX11_STATIC_ASSERT - static_assert() supported
184
// V8_HAS_CXX11_DELETE - deleted functions supported
185
// V8_HAS_CXX11_FINAL - final marker supported
186
// V8_HAS_CXX11_OVERRIDE - override marker supported
187
//
188
// Compiler-specific feature detection
189
//
190
// V8_HAS___ALIGNOF - __alignof(type) operator supported
191
// V8_HAS___ALIGNOF__ - __alignof__(type) operator supported
192
// V8_HAS_ATTRIBUTE_ALIGNED - __attribute__((aligned(n))) supported
193
// V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline))
194
// supported
195
// V8_HAS_ATTRIBUTE_DEPRECATED - __attribute__((deprecated)) supported
196
// V8_HAS_ATTRIBUTE_NOINLINE - __attribute__((noinline)) supported
197
// V8_HAS_ATTRIBUTE_UNUSED - __attribute__((unused)) supported
198
// V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported
199
// V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT - __attribute__((warn_unused_result))
200
// supported
201
// V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported
202
// V8_HAS_DECLSPEC_ALIGN - __declspec(align(n)) supported
203
// V8_HAS_DECLSPEC_DEPRECATED - __declspec(deprecated) supported
204
// V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported
205
// V8_HAS___FINAL - __final supported in non-C++11 mode
206
// V8_HAS___FORCEINLINE - __forceinline supported
207
// V8_HAS_SEALED - MSVC style sealed marker supported
208
//
209
// Note that testing for compilers and/or features must be done using #if
210
// not #ifdef. For example, to test for Intel C++ Compiler, use:
211
// #if V8_CC_INTEL
212
// ...
213
// #endif
214
215
#if defined(__clang__)
216
217
# define V8_CC_CLANG 1
218
219
// Clang defines __alignof__ as alias for __alignof
220
# define V8_HAS___ALIGNOF 1
221
# define V8_HAS___ALIGNOF__ V8_HAS___ALIGNOF
222
223
# define V8_HAS_ATTRIBUTE_ALIGNED (__has_attribute(aligned))
224
# define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline))
225
# define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated))
226
# define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline))
227
# define V8_HAS_ATTRIBUTE_UNUSED (__has_attribute(unused))
228
# define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility))
229
# define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \
230
(__has_attribute(warn_unused_result))
231
232
# define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect))
233
234
# define V8_HAS_CXX11_ALIGNAS (__has_feature(cxx_alignas))
235
# define V8_HAS_CXX11_STATIC_ASSERT (__has_feature(cxx_static_assert))
236
# define V8_HAS_CXX11_DELETE (__has_feature(cxx_deleted_functions))
237
# define V8_HAS_CXX11_FINAL (__has_feature(cxx_override_control))
238
# define V8_HAS_CXX11_OVERRIDE (__has_feature(cxx_override_control))
239
240
#elif defined(__GNUC__)
241
242
# define V8_CC_GNU 1
243
// Intel C++ also masquerades as GCC 3.2.0
244
# define V8_CC_INTEL (defined(__INTEL_COMPILER))
245
# define V8_CC_MINGW32 (defined(__MINGW32__))
246
# define V8_CC_MINGW64 (defined(__MINGW64__))
247
# define V8_CC_MINGW (V8_CC_MINGW32 || V8_CC_MINGW64)
248
249
# define V8_HAS___ALIGNOF__ (V8_GNUC_PREREQ(4, 3, 0))
250
251
# define V8_HAS_ATTRIBUTE_ALIGNED (V8_GNUC_PREREQ(2, 95, 0))
252
// always_inline is available in gcc 4.0 but not very reliable until 4.4.
253
// Works around "sorry, unimplemented: inlining failed" build errors with
254
// older compilers.
255
# define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (V8_GNUC_PREREQ(4, 4, 0))
256
# define V8_HAS_ATTRIBUTE_DEPRECATED (V8_GNUC_PREREQ(3, 4, 0))
257
# define V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE (V8_GNUC_PREREQ(4, 5, 0))
258
# define V8_HAS_ATTRIBUTE_NOINLINE (V8_GNUC_PREREQ(3, 4, 0))
259
# define V8_HAS_ATTRIBUTE_UNUSED (V8_GNUC_PREREQ(2, 95, 0))
260
# define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0))
261
# define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \
262
(!V8_CC_INTEL && V8_GNUC_PREREQ(4, 1, 0))
263
264
# define V8_HAS_BUILTIN_EXPECT (V8_GNUC_PREREQ(2, 96, 0))
265
266
// g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality
267
// without warnings (functionality used by the macros below). These modes
268
// are detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or,
269
// more standardly, by checking whether __cplusplus has a C++11 or greater
270
// value. Current versions of g++ do not correctly set __cplusplus, so we check
271
// both for forward compatibility.
272
# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
273
# define V8_HAS_CXX11_ALIGNAS (V8_GNUC_PREREQ(4, 8, 0))
274
# define V8_HAS_CXX11_ALIGNOF (V8_GNUC_PREREQ(4, 8, 0))
275
# define V8_HAS_CXX11_STATIC_ASSERT (V8_GNUC_PREREQ(4, 3, 0))
276
# define V8_HAS_CXX11_DELETE (V8_GNUC_PREREQ(4, 4, 0))
277
# define V8_HAS_CXX11_OVERRIDE (V8_GNUC_PREREQ(4, 7, 0))
278
# define V8_HAS_CXX11_FINAL (V8_GNUC_PREREQ(4, 7, 0))
279
# else
280
// '__final' is a non-C++11 GCC synonym for 'final', per GCC r176655.
281
# define V8_HAS___FINAL (V8_GNUC_PREREQ(4, 7, 0))
282
# endif
283
284
#elif defined(_MSC_VER)
285
286
# define V8_CC_MSVC 1
287
288
# define V8_HAS___ALIGNOF 1
289
290
// Override control was added with Visual Studio 2005, but
291
// Visual Studio 2010 and earlier spell "final" as "sealed".
292
# define V8_HAS_CXX11_FINAL (_MSC_VER >= 1700)
293
# define V8_HAS_CXX11_OVERRIDE (_MSC_VER >= 1400)
294
# define V8_HAS_SEALED (_MSC_VER >= 1400)
295
296
# define V8_HAS_DECLSPEC_ALIGN 1
297
# define V8_HAS_DECLSPEC_DEPRECATED (_MSC_VER >= 1300)
298
# define V8_HAS_DECLSPEC_NOINLINE 1
299
300
# define V8_HAS___FORCEINLINE 1
301
302
#endif
303
304
305
// -----------------------------------------------------------------------------
306
// Helper macros
307
308
// A macro used to make better inlining. Don't bother for debug builds.
309
// Use like:
310
// V8_INLINE int GetZero() { return 0; }
311
#if !defined(DEBUG) && V8_HAS_ATTRIBUTE_ALWAYS_INLINE
312
# define V8_INLINE inline __attribute__((always_inline))
313
#elif !defined(DEBUG) && V8_HAS___FORCEINLINE
314
# define V8_INLINE __forceinline
315
#else
316
# define V8_INLINE inline
317
#endif
318
319
320
// A macro used to tell the compiler to never inline a particular function.
321
// Don't bother for debug builds.
322
// Use like:
323
// V8_NOINLINE int GetMinusOne() { return -1; }
324
#if !defined(DEBUG) && V8_HAS_ATTRIBUTE_NOINLINE
325
# define V8_NOINLINE __attribute__((noinline))
326
#elif !defined(DEBUG) && V8_HAS_DECLSPEC_NOINLINE
327
# define V8_NOINLINE __declspec(noinline)
328
#else
329
# define V8_NOINLINE
/* NOT SUPPORTED */
330
#endif
331
332
333
// A macro to mark classes or functions as deprecated.
334
#if defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE
335
# define V8_DEPRECATED(message, declarator) \
336
declarator __attribute__((deprecated(message)))
337
#elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED
338
# define V8_DEPRECATED(message, declarator) \
339
declarator __attribute__((deprecated))
340
#elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_DECLSPEC_DEPRECATED
341
# define V8_DEPRECATED(message, declarator) __declspec(deprecated) declarator
342
#else
343
# define V8_DEPRECATED(message, declarator) declarator
344
#endif
345
346
347
// A macro to mark variables or types as unused, avoiding compiler warnings.
348
#if V8_HAS_ATTRIBUTE_UNUSED
349
# define V8_UNUSED __attribute__((unused))
350
#else
351
# define V8_UNUSED
352
#endif
353
354
355
// Annotate a function indicating the caller must examine the return value.
356
// Use like:
357
// int foo() V8_WARN_UNUSED_RESULT;
358
#if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT
359
# define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
360
#else
361
# define V8_WARN_UNUSED_RESULT
/* NOT SUPPORTED */
362
#endif
363
364
365
// A macro to provide the compiler with branch prediction information.
366
#if V8_HAS_BUILTIN_EXPECT
367
# define V8_UNLIKELY(condition) (__builtin_expect(!!(condition), 0))
368
# define V8_LIKELY(condition) (__builtin_expect(!!(condition), 1))
369
#else
370
# define V8_UNLIKELY(condition) (condition)
371
# define V8_LIKELY(condition) (condition)
372
#endif
373
374
375
// A macro to specify that a method is deleted from the corresponding class.
376
// Any attempt to use the method will always produce an error at compile time
377
// when this macro can be implemented (i.e. if the compiler supports C++11).
378
// If the current compiler does not support C++11, use of the annotated method
379
// will still cause an error, but the error will most likely occur at link time
380
// rather than at compile time. As a backstop, method declarations using this
381
// macro should be private.
382
// Use like:
383
// class A {
384
// private:
385
// A(const A& other) V8_DELETE;
386
// A& operator=(const A& other) V8_DELETE;
387
// };
388
#if V8_HAS_CXX11_DELETE
389
# define V8_DELETE = delete
390
#else
391
# define V8_DELETE
/* NOT SUPPORTED */
392
#endif
393
394
395
// Annotate a virtual method indicating it must be overriding a virtual
396
// method in the parent class.
397
// Use like:
398
// virtual void bar() V8_OVERRIDE;
399
#if V8_HAS_CXX11_OVERRIDE
400
# define V8_OVERRIDE override
401
#else
402
# define V8_OVERRIDE
/* NOT SUPPORTED */
403
#endif
404
405
406
// Annotate a virtual method indicating that subclasses must not override it,
407
// or annotate a class to indicate that it cannot be subclassed.
408
// Use like:
409
// class B V8_FINAL : public A {};
410
// virtual void bar() V8_FINAL;
411
#if V8_HAS_CXX11_FINAL
412
# define V8_FINAL final
413
#elif V8_HAS___FINAL
414
# define V8_FINAL __final
415
#elif V8_HAS_SEALED
416
# define V8_FINAL sealed
417
#else
418
# define V8_FINAL
/* NOT SUPPORTED */
419
#endif
420
421
422
// This macro allows to specify memory alignment for structs, classes, etc.
423
// Use like:
424
// class V8_ALIGNED(16) MyClass { ... };
425
// V8_ALIGNED(32) int array[42];
426
#if V8_HAS_CXX11_ALIGNAS
427
# define V8_ALIGNED(n) alignas(n)
428
#elif V8_HAS_ATTRIBUTE_ALIGNED
429
# define V8_ALIGNED(n) __attribute__((aligned(n)))
430
#elif V8_HAS_DECLSPEC_ALIGN
431
# define V8_ALIGNED(n) __declspec(align(n))
432
#else
433
# define V8_ALIGNED(n)
/* NOT SUPPORTED */
434
#endif
435
436
437
// This macro is similar to V8_ALIGNED(), but takes a type instead of size
438
// in bytes. If the compiler does not supports using the alignment of the
439
// |type|, it will align according to the |alignment| instead. For example,
440
// Visual Studio C++ cannot combine __declspec(align) and __alignof. The
441
// |alignment| must be a literal that is used as a kind of worst-case fallback
442
// alignment.
443
// Use like:
444
// struct V8_ALIGNAS(AnotherClass, 16) NewClass { ... };
445
// V8_ALIGNAS(double, 8) int array[100];
446
#if V8_HAS_CXX11_ALIGNAS
447
# define V8_ALIGNAS(type, alignment) alignas(type)
448
#elif V8_HAS___ALIGNOF__ && V8_HAS_ATTRIBUTE_ALIGNED
449
# define V8_ALIGNAS(type, alignment) __attribute__((aligned(__alignof__(type))))
450
#else
451
# define V8_ALIGNAS(type, alignment) V8_ALIGNED(alignment)
452
#endif
453
454
455
// This macro returns alignment in bytes (an integer power of two) required for
456
// any instance of the given type, which is either complete type, an array type,
457
// or a reference type.
458
// Use like:
459
// size_t alignment = V8_ALIGNOF(double);
460
#if V8_HAS_CXX11_ALIGNOF
461
# define V8_ALIGNOF(type) alignof(type)
462
#elif V8_HAS___ALIGNOF
463
# define V8_ALIGNOF(type) __alignof(type)
464
#elif V8_HAS___ALIGNOF__
465
# define V8_ALIGNOF(type) __alignof__(type)
466
#else
467
// Note that alignment of a type within a struct can be less than the
468
// alignment of the type stand-alone (because of ancient ABIs), so this
469
// should only be used as a last resort.
470
namespace
v8 {
template
<
typename
T>
class
AlignOfHelper
{
char
c;
T
t; }; }
471
# define V8_ALIGNOF(type) (sizeof(::v8::AlignOfHelper<type>) - sizeof(type))
472
#endif
473
474
#endif // V8CONFIG_H_
v8::AlignOfHelper
Definition:
v8config.h:470
T
#define T(name, string, precedence)
Definition:
token.cc:48
include
v8config.h
Generated on Sat Jun 7 2014 23:53:57 for v8 by
1.8.6