11 #if defined(__ANDROID__)
12 # include <sys/cdefs.h>
13 #elif defined(__APPLE__)
14 # include <TargetConditionals.h>
15 #elif defined(__linux__
)
16 # include <features.h>
27 #if defined(__GLIBC__
) && defined(__GLIBC_MINOR__
)
28 # define V8_GLIBC_PREREQ(major, minor)
29 ((__GLIBC__
* 100
+ __GLIBC_MINOR__
) >= ((major) * 100
+ (minor)))
31 # define V8_GLIBC_PREREQ(major, minor) 0
42 #if defined(__GNUC__
) && defined(__GNUC_MINOR__
) && defined(__GNUC_PATCHLEVEL__
)
43 # define V8_GNUC_PREREQ(major, minor, patchlevel)
44 ((__GNUC__
* 10000
+ __GNUC_MINOR__
* 100
+ __GNUC_PATCHLEVEL__
) >=
45 ((major) * 10000
+ (minor) * 100
+ (patchlevel)))
46 #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
47 # define V8_GNUC_PREREQ(major, minor, patchlevel)
48 ((__GNUC__ * 10000
+ __GNUC_MINOR__ * 100
) >=
49 ((major) * 10000
+ (minor) * 100
+ (patchlevel)))
51 # define V8_GNUC_PREREQ(major, minor, patchlevel) 0
74 #if defined(__ANDROID__)
75 # define V8_OS_ANDROID 1
76 # define V8_OS_LINUX 1
77 # define V8_OS_POSIX 1
78 #elif defined(__APPLE__)
80 # define V8_OS_MACOSX 1
81 # define V8_OS_POSIX 1
82 #elif defined(__CYGWIN__)
83 # define V8_OS_CYGWIN 1
84 # define V8_OS_POSIX 1
85 #elif defined(__linux__
)
86 # define V8_OS_LINUX 1
87 # define V8_OS_POSIX 1
89 # define V8_OS_POSIX 1
90 # define V8_OS_SOLARIS 1
94 #elif defined(__FreeBSD__)
96 # define V8_OS_FREEBSD 1
97 # define V8_OS_POSIX 1
98 #elif defined(__DragonFly__)
100 # define V8_OS_DRAGONFLYBSD 1
101 # define V8_OS_POSIX 1
102 #elif defined(__NetBSD__)
104 # define V8_OS_NETBSD 1
105 # define V8_OS_POSIX 1
106 #elif defined(__OpenBSD__)
108 # define V8_OS_OPENBSD 1
109 # define V8_OS_POSIX 1
110 #elif defined(__QNXNTO__)
111 # define V8_OS_POSIX 1
113 #elif defined(_WIN32)
133 #if defined (_MSC_VER)
134 # define V8_LIBC_MSVCRT 1
135 #elif defined(__BIONIC__)
136 # define V8_LIBC_BIONIC 1
137 # define V8_LIBC_BSD 1
138 #elif defined(__UCLIBC__)
140 # define V8_LIBC_UCLIBC 1
141 #elif defined(__GLIBC__
) || defined(__GNU_LIBRARY__
)
142 # define V8_LIBC_GLIBC 1
144 # define V8_LIBC_BSD V8_OS_BSD
198 #if defined(__clang__
)
200 #if defined(__GNUC__
)
205 # define V8_HAS___ALIGNOF 1
206 # define V8_HAS___ALIGNOF__ V8_HAS___ALIGNOF
208 # define V8_HAS_ATTRIBUTE_ALIGNED (__has_attribute(aligned))
209 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline))
210 # define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated))
211 # define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline))
212 # define V8_HAS_ATTRIBUTE_NORETURN (__has_attribute(noreturn))
213 # define V8_HAS_ATTRIBUTE_UNUSED (__has_attribute(unused))
214 # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility))
215 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT
216 (__has_attribute(warn_unused_result))
218 # define V8_HAS_BUILTIN_CLZ (__has_builtin(__builtin_clz))
219 # define V8_HAS_BUILTIN_CTZ (__has_builtin(__builtin_ctz))
220 # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect))
221 # define V8_HAS_BUILTIN_FRAME_ADDRESS (__has_builtin(__builtin_frame_address))
222 # define V8_HAS_BUILTIN_POPCOUNT (__has_builtin(__builtin_popcount))
223 # define V8_HAS_BUILTIN_SADD_OVERFLOW (__has_builtin(__builtin_sadd_overflow))
224 # define V8_HAS_BUILTIN_SSUB_OVERFLOW (__has_builtin(__builtin_ssub_overflow))
225 # define V8_HAS_BUILTIN_UADD_OVERFLOW (__has_builtin(__builtin_uadd_overflow))
227 # define V8_HAS_CXX11_ALIGNAS (__has_feature(cxx_alignas))
229 #elif defined(__GNUC__)
232 # if defined(__INTEL_COMPILER)
233 # define V8_CC_INTEL 1
235 # if defined(__MINGW32__)
236 # define V8_CC_MINGW32 1
238 # if defined(__MINGW64__)
239 # define V8_CC_MINGW64 1
241 # define V8_CC_MINGW (V8_CC_MINGW32 || V8_CC_MINGW64)
243 # define V8_HAS___ALIGNOF__ (V8_GNUC_PREREQ(4
, 3
, 0
))
245 # define V8_HAS_ATTRIBUTE_ALIGNED (V8_GNUC_PREREQ(2
, 95
, 0
))
249 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (V8_GNUC_PREREQ(4
, 4
, 0
))
250 # define V8_HAS_ATTRIBUTE_DEPRECATED (V8_GNUC_PREREQ(3
, 4
, 0
))
251 # define V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE (V8_GNUC_PREREQ(4
, 5
, 0
))
252 # define V8_HAS_ATTRIBUTE_NOINLINE (V8_GNUC_PREREQ(3
, 4
, 0
))
253 # define V8_HAS_ATTRIBUTE_NORETURN (V8_GNUC_PREREQ(2
, 5
, 0
))
254 # define V8_HAS_ATTRIBUTE_UNUSED (V8_GNUC_PREREQ(2
, 95
, 0
))
255 # define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4
, 3
, 0
))
256 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT
257 (!V8_CC_INTEL && V8_GNUC_PREREQ(4
, 1
, 0
))
259 # define V8_HAS_BUILTIN_CLZ (V8_GNUC_PREREQ(3
, 4
, 0
))
260 # define V8_HAS_BUILTIN_CTZ (V8_GNUC_PREREQ(3
, 4
, 0
))
261 # define V8_HAS_BUILTIN_EXPECT (V8_GNUC_PREREQ(2
, 96
, 0
))
262 # define V8_HAS_BUILTIN_FRAME_ADDRESS (V8_GNUC_PREREQ(2
, 96
, 0
))
263 # define V8_HAS_BUILTIN_POPCOUNT (V8_GNUC_PREREQ(3
, 4
, 0
))
265 # if __cplusplus >= 201103L
266 # define V8_HAS_CXX11_ALIGNAS (V8_GNUC_PREREQ(4
, 8
, 0
))
267 # define V8_HAS_CXX11_ALIGNOF (V8_GNUC_PREREQ(4
, 8
, 0
))
271 #if defined(_MSC_VER)
272 # define V8_CC_MSVC 1
273 # define V8_HAS___ALIGNOF 1
275 # define V8_HAS_DECLSPEC_ALIGN 1
276 # define V8_HAS_DECLSPEC_DEPRECATED 1
277 # define V8_HAS_DECLSPEC_NOINLINE 1
278 # define V8_HAS_DECLSPEC_SELECTANY 1
279 # define V8_HAS_DECLSPEC_NORETURN 1
281 # define V8_HAS___FORCEINLINE 1
292 #if !defined(DEBUG) && V8_HAS_ATTRIBUTE_ALWAYS_INLINE
293 # define V8_INLINE inline __attribute__((always_inline))
294 #elif !defined(DEBUG) && V8_HAS___FORCEINLINE
295 # define V8_INLINE __forceinline
297 # define V8_INLINE inline
305 #if !defined(DEBUG) && V8_HAS_ATTRIBUTE_NOINLINE
306 # define V8_NOINLINE __attribute__((noinline))
307 #elif !defined(DEBUG) && V8_HAS_DECLSPEC_NOINLINE
308 # define V8_NOINLINE __declspec(noinline)
317 #if V8_HAS_ATTRIBUTE_NORETURN
318 # define V8_NORETURN __attribute__((noreturn))
319 #elif HAS_DECLSPEC_NORETURN
320 # define V8_NORETURN __declspec(noreturn)
327 #if defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE
328 #define V8_DEPRECATED(message, declarator)
329 declarator __attribute__((deprecated(message)))
330 #elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED
331 #define V8_DEPRECATED(message, declarator)
332 declarator __attribute__((deprecated))
333 #elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_DECLSPEC_DEPRECATED
334 #define V8_DEPRECATED(message, declarator) __declspec(deprecated) declarator
336 #define V8_DEPRECATED(message, declarator) declarator
341 #if defined(V8_IMMINENT_DEPRECATION_WARNINGS) &&
342 V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE
343 #define V8_DEPRECATE_SOON(message, declarator)
344 declarator __attribute__((deprecated(message)))
345 #elif defined(V8_IMMINENT_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED
346 #define V8_DEPRECATE_SOON(message, declarator)
347 declarator __attribute__((deprecated))
348 #elif defined(V8_IMMINENT_DEPRECATION_WARNINGS) && V8_HAS_DECLSPEC_DEPRECATED
349 #define V8_DEPRECATE_SOON(message, declarator) __declspec(deprecated) declarator
351 #define V8_DEPRECATE_SOON(message, declarator) declarator
356 #if V8_HAS_BUILTIN_EXPECT
357 # define V8_UNLIKELY(condition) (__builtin_expect(!!(condition), 0
))
358 # define V8_LIKELY(condition) (__builtin_expect(!!(condition), 1
))
360 # define V8_UNLIKELY(condition) (condition)
361 # define V8_LIKELY(condition) (condition)
369 #if V8_HAS_CXX11_ALIGNAS
370 # define V8_ALIGNED(n) alignas(n)
371 #elif V8_HAS_ATTRIBUTE_ALIGNED
372 # define V8_ALIGNED(n) __attribute__((aligned(n)))
373 #elif V8_HAS_DECLSPEC_ALIGN
374 # define V8_ALIGNED(n) __declspec(align(n))
376 # define V8_ALIGNED(n)
389 #if V8_HAS_CXX11_ALIGNAS
390 # define V8_ALIGNAS(type, alignment) alignas(type)
391 #elif V8_HAS___ALIGNOF__ && V8_HAS_ATTRIBUTE_ALIGNED
392 # define V8_ALIGNAS(type, alignment) __attribute__((aligned(__alignof__(type))))
394 # define V8_ALIGNAS(type, alignment) V8_ALIGNED(alignment)
403 #if V8_HAS_CXX11_ALIGNOF
404 # define V8_ALIGNOF(type) alignof(type)
405 #elif V8_HAS___ALIGNOF
406 # define V8_ALIGNOF(type) __alignof(type)
407 #elif V8_HAS___ALIGNOF__
408 # define V8_ALIGNOF(type) __alignof__(type)
413 namespace v8 {
template <
typename T>
class AlignOfHelper {
char c; T t; }; }
414 # define V8_ALIGNOF(type) (sizeof(::v8::AlignOfHelper<type>) - sizeof(type))
420 #if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT
421 #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
423 #define V8_WARN_UNUSED_RESULT