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 3 // found in the LICENSE file. 4 5 #ifndef V8CONFIG_H_ 6 #define V8CONFIG_H_ 7 8 #ifdef V8_GN_HEADER 9 #if __cplusplus >= 201703L && !__has_include("v8-gn.h") 10 #error Missing v8-gn.h. The configuration for v8 is missing from the include \ 11 path. Add it with -I<path> to the command line 12 #endif 13 #include "v8-gn.h" // NOLINT(build/include_directory) 14 #endif 15 16 // clang-format off 17 18 // Platform headers for feature detection below. 19 #if defined(__ANDROID__) 20 # include <sys/cdefs.h> 21 #elif defined(__APPLE__) 22 # include <TargetConditionals.h> 23 #elif defined(__linux__) 24 # include <features.h> 25 #endif 26 27 28 // This macro allows to test for the version of the GNU C library (or 29 // a compatible C library that masquerades as glibc). It evaluates to 30 // 0 if libc is not GNU libc or compatible. 31 // Use like: 32 // #if V8_GLIBC_PREREQ(2, 3) 33 // ... 34 // #endif 35 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__) 36 # define V8_GLIBC_PREREQ(major, minor) \ 37 ((__GLIBC__ * 100 + __GLIBC_MINOR__) >= ((major) * 100 + (minor))) 38 #else 39 # define V8_GLIBC_PREREQ(major, minor) 0 40 #endif 41 42 43 // This macro allows to test for the version of the GNU C++ compiler. 44 // Note that this also applies to compilers that masquerade as GCC, 45 // for example clang and the Intel C++ compiler for Linux. 46 // Use like: 47 // #if V8_GNUC_PREREQ(4, 3, 1) 48 // ... 49 // #endif 50 #if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) 51 # define V8_GNUC_PREREQ(major, minor, patchlevel) \ 52 ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= \ 53 ((major) * 10000 + (minor) * 100 + (patchlevel))) 54 #elif defined(__GNUC__) && defined(__GNUC_MINOR__) 55 # define V8_GNUC_PREREQ(major, minor, patchlevel) \ 56 ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= \ 57 ((major) * 10000 + (minor) * 100 + (patchlevel))) 58 #else 59 # define V8_GNUC_PREREQ(major, minor, patchlevel) 0 60 #endif 61 62 63 64 // ----------------------------------------------------------------------------- 65 // Operating system detection (host) 66 // 67 // V8_OS_ANDROID - Android 68 // V8_OS_BSD - BSDish (Mac OS X, Net/Free/Open/DragonFlyBSD) 69 // V8_OS_CYGWIN - Cygwin 70 // V8_OS_DRAGONFLYBSD - DragonFlyBSD 71 // V8_OS_FREEBSD - FreeBSD 72 // V8_OS_FUCHSIA - Fuchsia 73 // V8_OS_LINUX - Linux 74 // V8_OS_MACOSX - Mac OS X 75 // V8_OS_IOS - iOS 76 // V8_OS_NETBSD - NetBSD 77 // V8_OS_OPENBSD - OpenBSD 78 // V8_OS_POSIX - POSIX compatible (mostly everything except Windows) 79 // V8_OS_QNX - QNX Neutrino 80 // V8_OS_SOLARIS - Sun Solaris and OpenSolaris 81 // V8_OS_STARBOARD - Starboard (platform abstraction for Cobalt) 82 // V8_OS_AIX - AIX 83 // V8_OS_WIN - Microsoft Windows 84 85 #if defined(__ANDROID__) 86 # define V8_OS_ANDROID 1 87 # define V8_OS_LINUX 1 88 # define V8_OS_POSIX 1 89 # define V8_OS_STRING "android" 90 91 #elif defined(__APPLE__) 92 # define V8_OS_BSD 1 93 # define V8_OS_MACOSX 1 94 # define V8_OS_POSIX 1 95 # if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE 96 # define V8_OS_IOS 1 97 # define V8_OS_STRING "ios" 98 # else 99 # define V8_OS_STRING "macos" 100 # endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE 101 102 #elif defined(__CYGWIN__) 103 # define V8_OS_CYGWIN 1 104 # define V8_OS_POSIX 1 105 # define V8_OS_STRING "cygwin" 106 107 #elif defined(__linux__) 108 # define V8_OS_LINUX 1 109 # define V8_OS_POSIX 1 110 # define V8_OS_STRING "linux" 111 112 #elif defined(__sun) 113 # define V8_OS_POSIX 1 114 # define V8_OS_SOLARIS 1 115 # define V8_OS_STRING "sun" 116 117 #elif defined(STARBOARD) 118 # define V8_OS_STARBOARD 1 119 # define V8_OS_STRING "starboard" 120 121 #elif defined(_AIX) 122 # define V8_OS_POSIX 1 123 # define V8_OS_AIX 1 124 # define V8_OS_STRING "aix" 125 126 #elif defined(__FreeBSD__) 127 # define V8_OS_BSD 1 128 # define V8_OS_FREEBSD 1 129 # define V8_OS_POSIX 1 130 # define V8_OS_STRING "freebsd" 131 132 #elif defined(__Fuchsia__) 133 # define V8_OS_FUCHSIA 1 134 # define V8_OS_POSIX 1 135 # define V8_OS_STRING "fuchsia" 136 137 #elif defined(__DragonFly__) 138 # define V8_OS_BSD 1 139 # define V8_OS_FREEBSD 1 140 # define V8_OS_DRAGONFLYBSD 1 141 # define V8_OS_POSIX 1 142 # define V8_OS_STRING "dragonflybsd" 143 144 #elif defined(__NetBSD__) 145 # define V8_OS_BSD 1 146 # define V8_OS_NETBSD 1 147 # define V8_OS_POSIX 1 148 # define V8_OS_STRING "netbsd" 149 150 #elif defined(__OpenBSD__) 151 # define V8_OS_BSD 1 152 # define V8_OS_OPENBSD 1 153 # define V8_OS_POSIX 1 154 # define V8_OS_STRING "openbsd" 155 156 #elif defined(__QNXNTO__) 157 # define V8_OS_POSIX 1 158 # define V8_OS_QNX 1 159 # define V8_OS_STRING "qnx" 160 161 #elif defined(_WIN32) 162 # define V8_OS_WIN 1 163 # define V8_OS_STRING "windows" 164 #endif 165 166 // ----------------------------------------------------------------------------- 167 // Operating system detection (target) 168 // 169 // V8_TARGET_OS_ANDROID 170 // V8_TARGET_OS_FUCHSIA 171 // V8_TARGET_OS_IOS 172 // V8_TARGET_OS_LINUX 173 // V8_TARGET_OS_MACOSX 174 // V8_TARGET_OS_WIN 175 // 176 // If not set explicitly, these fall back to corresponding V8_OS_ values. 177 178 #ifdef V8_HAVE_TARGET_OS 179 180 // The target OS is provided, just check that at least one known value is set. 181 # if !defined(V8_TARGET_OS_ANDROID) \ 182 && !defined(V8_TARGET_OS_FUCHSIA) \ 183 && !defined(V8_TARGET_OS_IOS) \ 184 && !defined(V8_TARGET_OS_LINUX) \ 185 && !defined(V8_TARGET_OS_MACOSX) \ 186 && !defined(V8_TARGET_OS_WIN) 187 # error No known target OS defined. 188 # endif 189 190 #else // V8_HAVE_TARGET_OS 191 192 # if defined(V8_TARGET_OS_ANDROID) \ 193 || defined(V8_TARGET_OS_FUCHSIA) \ 194 || defined(V8_TARGET_OS_IOS) \ 195 || defined(V8_TARGET_OS_LINUX) \ 196 || defined(V8_TARGET_OS_MACOSX) \ 197 || defined(V8_TARGET_OS_WIN) 198 # error A target OS is defined but V8_HAVE_TARGET_OS is unset. 199 # endif 200 201 // Fall back to the detected host OS. 202 #ifdef V8_OS_ANDROID 203 # define V8_TARGET_OS_ANDROID 204 #endif 205 206 #ifdef V8_OS_FUCHSIA 207 # define V8_TARGET_OS_FUCHSIA 208 #endif 209 210 #ifdef V8_OS_IOS 211 # define V8_TARGET_OS_IOS 212 #endif 213 214 #ifdef V8_OS_LINUX 215 # define V8_TARGET_OS_LINUX 216 #endif 217 218 #ifdef V8_OS_MACOSX 219 # define V8_TARGET_OS_MACOSX 220 #endif 221 222 #ifdef V8_OS_WIN 223 # define V8_TARGET_OS_WIN 224 #endif 225 226 #endif // V8_HAVE_TARGET_OS 227 228 #if defined(V8_TARGET_OS_ANDROID) 229 # define V8_TARGET_OS_STRING "android" 230 #elif defined(V8_TARGET_OS_FUCHSIA) 231 # define V8_TARGET_OS_STRING "fuchsia" 232 #elif defined(V8_TARGET_OS_IOS) 233 # define V8_TARGET_OS_STRING "ios" 234 #elif defined(V8_TARGET_OS_LINUX) 235 # define V8_TARGET_OS_STRING "linux" 236 #elif defined(V8_TARGET_OS_MACOSX) 237 # define V8_TARGET_OS_STRING "macos" 238 #elif defined(V8_TARGET_OS_WINDOWS) 239 # define V8_TARGET_OS_STRING "windows" 240 #else 241 # define V8_TARGET_OS_STRING "unknown" 242 #endif 243 244 // ----------------------------------------------------------------------------- 245 // C library detection 246 // 247 // V8_LIBC_MSVCRT - MSVC libc 248 // V8_LIBC_BIONIC - Bionic libc 249 // V8_LIBC_BSD - BSD libc derivate 250 // V8_LIBC_GLIBC - GNU C library 251 // V8_LIBC_UCLIBC - uClibc 252 // 253 // Note that testing for libc must be done using #if not #ifdef. For example, 254 // to test for the GNU C library, use: 255 // #if V8_LIBC_GLIBC 256 // ... 257 // #endif 258 259 #if defined (_MSC_VER) 260 # define V8_LIBC_MSVCRT 1 261 #elif defined(__BIONIC__) 262 # define V8_LIBC_BIONIC 1 263 # define V8_LIBC_BSD 1 264 #elif defined(__UCLIBC__) 265 // Must test for UCLIBC before GLIBC, as UCLIBC pretends to be GLIBC. 266 # define V8_LIBC_UCLIBC 1 267 #elif defined(__GLIBC__) || defined(__GNU_LIBRARY__) 268 # define V8_LIBC_GLIBC 1 269 #else 270 # define V8_LIBC_BSD V8_OS_BSD 271 #endif 272 273 274 // ----------------------------------------------------------------------------- 275 // Compiler detection 276 // 277 // V8_CC_GNU - GCC, or clang in gcc mode 278 // V8_CC_INTEL - Intel C++ 279 // V8_CC_MINGW - Minimalist GNU for Windows 280 // V8_CC_MINGW32 - Minimalist GNU for Windows (mingw32) 281 // V8_CC_MINGW64 - Minimalist GNU for Windows (mingw-w64) 282 // V8_CC_MSVC - Microsoft Visual C/C++, or clang in cl.exe mode 283 // 284 // C++11 feature detection 285 // 286 // Compiler-specific feature detection 287 // 288 // V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline)) 289 // supported 290 // V8_HAS_ATTRIBUTE_NONNULL - __attribute__((nonnull)) supported 291 // V8_HAS_ATTRIBUTE_NOINLINE - __attribute__((noinline)) supported 292 // V8_HAS_ATTRIBUTE_UNUSED - __attribute__((unused)) supported 293 // V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported 294 // V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT - __attribute__((warn_unused_result)) 295 // supported 296 // V8_HAS_CPP_ATTRIBUTE_NODISCARD - [[nodiscard]] supported 297 // V8_HAS_BUILTIN_BSWAP16 - __builtin_bswap16() supported 298 // V8_HAS_BUILTIN_BSWAP32 - __builtin_bswap32() supported 299 // V8_HAS_BUILTIN_BSWAP64 - __builtin_bswap64() supported 300 // V8_HAS_BUILTIN_CLZ - __builtin_clz() supported 301 // V8_HAS_BUILTIN_CTZ - __builtin_ctz() supported 302 // V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported 303 // V8_HAS_BUILTIN_FRAME_ADDRESS - __builtin_frame_address() supported 304 // V8_HAS_BUILTIN_POPCOUNT - __builtin_popcount() supported 305 // V8_HAS_BUILTIN_SADD_OVERFLOW - __builtin_sadd_overflow() supported 306 // V8_HAS_BUILTIN_SSUB_OVERFLOW - __builtin_ssub_overflow() supported 307 // V8_HAS_BUILTIN_UADD_OVERFLOW - __builtin_uadd_overflow() supported 308 // V8_HAS_COMPUTED_GOTO - computed goto/labels as values 309 // supported 310 // V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported 311 // V8_HAS_DECLSPEC_SELECTANY - __declspec(selectany) supported 312 // V8_HAS___FORCEINLINE - __forceinline supported 313 // 314 // Note that testing for compilers and/or features must be done using #if 315 // not #ifdef. For example, to test for Intel C++ Compiler, use: 316 // #if V8_CC_INTEL 317 // ... 318 // #endif 319 320 #if defined(__has_cpp_attribute) 321 #define V8_HAS_CPP_ATTRIBUTE(FEATURE) __has_cpp_attribute(FEATURE) 322 #else 323 #define V8_HAS_CPP_ATTRIBUTE(FEATURE) 0 324 #endif 325 326 #if defined(__clang__) 327 328 #if defined(__GNUC__) // Clang in gcc mode. 329 # define V8_CC_GNU 1 330 #endif 331 332 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline)) 333 # define V8_HAS_ATTRIBUTE_NONNULL (__has_attribute(nonnull)) 334 # define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline)) 335 # define V8_HAS_ATTRIBUTE_UNUSED (__has_attribute(unused)) 336 # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility)) 337 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ 338 (__has_attribute(warn_unused_result)) 339 340 # define V8_HAS_CPP_ATTRIBUTE_NODISCARD (V8_HAS_CPP_ATTRIBUTE(nodiscard)) 341 342 // Work around Clang bug present in 9.0.1, at least. 343 // 344 // Clang stores alignment as a 32-bit unsigned integer, but V8 only uses 345 // V8_ASSUME_ALIGNED() for a 4GB (2^32) alignment 346 // (kPtrComprIsolateRootAlignment). As such, the alignment overflows and 347 // becomes zero, triggering an internal Clang assertion that alignment must not 348 // be zero. 349 #if 0 350 # define V8_HAS_BUILTIN_ASSUME_ALIGNED (__has_builtin(__builtin_assume_aligned)) 351 #else 352 # define V8_HAS_BUILTIN_ASSUME_ALIGNED 0 353 #endif 354 # define V8_HAS_BUILTIN_BSWAP16 (__has_builtin(__builtin_bswap16)) 355 # define V8_HAS_BUILTIN_BSWAP32 (__has_builtin(__builtin_bswap32)) 356 # define V8_HAS_BUILTIN_BSWAP64 (__has_builtin(__builtin_bswap64)) 357 # define V8_HAS_BUILTIN_CLZ (__has_builtin(__builtin_clz)) 358 # define V8_HAS_BUILTIN_CTZ (__has_builtin(__builtin_ctz)) 359 # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect)) 360 # define V8_HAS_BUILTIN_FRAME_ADDRESS (__has_builtin(__builtin_frame_address)) 361 # define V8_HAS_BUILTIN_POPCOUNT (__has_builtin(__builtin_popcount)) 362 # define V8_HAS_BUILTIN_SADD_OVERFLOW (__has_builtin(__builtin_sadd_overflow)) 363 # define V8_HAS_BUILTIN_SSUB_OVERFLOW (__has_builtin(__builtin_ssub_overflow)) 364 # define V8_HAS_BUILTIN_UADD_OVERFLOW (__has_builtin(__builtin_uadd_overflow)) 365 366 // Clang has no __has_feature for computed gotos. 367 // GCC doc: https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html 368 # define V8_HAS_COMPUTED_GOTO 1 369 370 #elif defined(__GNUC__) 371 372 # define V8_CC_GNU 1 373 # if defined(__INTEL_COMPILER) // Intel C++ also masquerades as GCC 3.2.0 374 # define V8_CC_INTEL 1 375 # endif 376 # if defined(__MINGW32__) 377 # define V8_CC_MINGW32 1 378 # endif 379 # if defined(__MINGW64__) 380 # define V8_CC_MINGW64 1 381 # endif 382 # define V8_CC_MINGW (V8_CC_MINGW32 || V8_CC_MINGW64) 383 384 // always_inline is available in gcc 4.0 but not very reliable until 4.4. 385 // Works around "sorry, unimplemented: inlining failed" build errors with 386 // older compilers. 387 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE 1 388 # define V8_HAS_ATTRIBUTE_NOINLINE 1 389 # define V8_HAS_ATTRIBUTE_UNUSED 1 390 # define V8_HAS_ATTRIBUTE_VISIBILITY 1 391 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT (!V8_CC_INTEL) 392 393 // [[nodiscard]] does not work together with with 394 // __attribute__((visibility(""))) on GCC 7.4 which is why there is no define 395 // for V8_HAS_CPP_ATTRIBUTE_NODISCARD. See https://crbug.com/v8/11707. 396 397 # define V8_HAS_BUILTIN_ASSUME_ALIGNED 1 398 # define V8_HAS_BUILTIN_CLZ 1 399 # define V8_HAS_BUILTIN_CTZ 1 400 # define V8_HAS_BUILTIN_EXPECT 1 401 # define V8_HAS_BUILTIN_FRAME_ADDRESS 1 402 # define V8_HAS_BUILTIN_POPCOUNT 1 403 404 // GCC doc: https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html 405 #define V8_HAS_COMPUTED_GOTO 1 406 407 #endif 408 409 #if defined(_MSC_VER) 410 # define V8_CC_MSVC 1 411 412 # define V8_HAS_DECLSPEC_NOINLINE 1 413 # define V8_HAS_DECLSPEC_SELECTANY 1 414 415 # define V8_HAS___FORCEINLINE 1 416 417 #endif 418 419 420 // ----------------------------------------------------------------------------- 421 // Helper macros 422 423 // A macro used to make better inlining. Don't bother for debug builds. 424 // Use like: 425 // V8_INLINE int GetZero() { return 0; } 426 #if !defined(DEBUG) && V8_HAS_ATTRIBUTE_ALWAYS_INLINE 427 # define V8_INLINE inline __attribute__((always_inline)) 428 #elif !defined(DEBUG) && V8_HAS___FORCEINLINE 429 # define V8_INLINE __forceinline 430 #else 431 # define V8_INLINE inline 432 #endif 433 434 #if V8_HAS_BUILTIN_ASSUME_ALIGNED 435 # define V8_ASSUME_ALIGNED(ptr, alignment) \ 436 __builtin_assume_aligned((ptr), (alignment)) 437 #else 438 # define V8_ASSUME_ALIGNED(ptr, alignment) (ptr) 439 #endif 440 441 442 // A macro to mark specific arguments as non-null. 443 // Use like: 444 // int add(int* x, int y, int* z) V8_NONNULL(1, 3) { return *x + y + *z; } 445 #if V8_HAS_ATTRIBUTE_NONNULL 446 # define V8_NONNULL(...) __attribute__((nonnull(__VA_ARGS__))) 447 #else 448 # define V8_NONNULL(...) /* NOT SUPPORTED */ 449 #endif 450 451 452 // A macro used to tell the compiler to never inline a particular function. 453 // Use like: 454 // V8_NOINLINE int GetMinusOne() { return -1; } 455 #if V8_HAS_ATTRIBUTE_NOINLINE 456 # define V8_NOINLINE __attribute__((noinline)) 457 #elif V8_HAS_DECLSPEC_NOINLINE 458 # define V8_NOINLINE __declspec(noinline) 459 #else 460 # define V8_NOINLINE /* NOT SUPPORTED */ 461 #endif 462 463 464 // A macro (V8_DEPRECATED) to mark classes or functions as deprecated. 465 #if defined(V8_DEPRECATION_WARNINGS) 466 # define V8_DEPRECATED(message) [[deprecated(message)]] 467 #else 468 # define V8_DEPRECATED(message) 469 #endif 470 471 472 // A macro (V8_DEPRECATE_SOON) to make it easier to see what will be deprecated. 473 #if defined(V8_IMMINENT_DEPRECATION_WARNINGS) 474 # define V8_DEPRECATE_SOON(message) [[deprecated(message)]] 475 #else 476 # define V8_DEPRECATE_SOON(message) 477 #endif 478 479 480 #if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ < 6) 481 # define V8_ENUM_DEPRECATED(message) 482 # define V8_ENUM_DEPRECATE_SOON(message) 483 #else 484 # define V8_ENUM_DEPRECATED(message) V8_DEPRECATED(message) 485 # define V8_ENUM_DEPRECATE_SOON(message) V8_DEPRECATE_SOON(message) 486 #endif 487 488 489 // A macro to provide the compiler with branch prediction information. 490 #if V8_HAS_BUILTIN_EXPECT 491 # define V8_UNLIKELY(condition) (__builtin_expect(!!(condition), 0)) 492 # define V8_LIKELY(condition) (__builtin_expect(!!(condition), 1)) 493 #else 494 # define V8_UNLIKELY(condition) (condition) 495 # define V8_LIKELY(condition) (condition) 496 #endif 497 498 499 // Annotate a function indicating the caller must examine the return value. 500 // Use like: 501 // int foo() V8_WARN_UNUSED_RESULT; 502 #if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT 503 #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) 504 #else 505 #define V8_WARN_UNUSED_RESULT /* NOT SUPPORTED */ 506 #endif 507 508 509 // Annotate a class or constructor indicating the caller must assign the 510 // constructed instances. 511 // Apply to the whole class like: 512 // class V8_NODISCARD Foo() { ... }; 513 // or apply to just one constructor like: 514 // V8_NODISCARD Foo() { ... }; 515 // [[nodiscard]] comes in C++17 but supported in clang with -std >= c++11. 516 #define V8_NODISCARD /* NOT SUPPORTED */ 517 518 // Helper macro to define no_sanitize attributes only with clang. 519 #if defined(__clang__) && defined(__has_attribute) 520 #if __has_attribute(no_sanitize) 521 #define V8_CLANG_NO_SANITIZE(what) __attribute__((no_sanitize(what))) 522 #endif 523 #endif 524 #if !defined(V8_CLANG_NO_SANITIZE) 525 #define V8_CLANG_NO_SANITIZE(what) 526 #endif 527 528 #if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED) 529 #error Inconsistent build configuration: To build the V8 shared library \ 530 set BUILDING_V8_SHARED, to include its headers for linking against the \ 531 V8 shared library set USING_V8_SHARED. 532 #endif 533 534 #ifdef V8_OS_WIN 535 536 // Setup for Windows DLL export/import. When building the V8 DLL the 537 // BUILDING_V8_SHARED needs to be defined. When building a program which uses 538 // the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8 539 // static library or building a program which uses the V8 static library neither 540 // BUILDING_V8_SHARED nor USING_V8_SHARED should be defined. 541 #ifdef BUILDING_V8_SHARED 542 # define V8_EXPORT __declspec(dllexport) 543 #elif USING_V8_SHARED 544 # define V8_EXPORT __declspec(dllimport) 545 #else 546 # define V8_EXPORT 547 #endif // BUILDING_V8_SHARED 548 549 #else // V8_OS_WIN 550 551 // Setup for Linux shared library export. 552 #if V8_HAS_ATTRIBUTE_VISIBILITY 553 # ifdef BUILDING_V8_SHARED 554 # define V8_EXPORT __attribute__ ((visibility("default"))) 555 # else 556 # define V8_EXPORT 557 # endif 558 #else 559 # define V8_EXPORT 560 #endif 561 562 #endif // V8_OS_WIN 563 564 // clang-format on 565 566 #undef V8_HAS_CPP_ATTRIBUTE 567 568 #endif // V8CONFIG_H_ 569