Turn audio into a shareable video. forked from nypublicradio/audiogram

v8config.h 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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. #ifndef V8CONFIG_H_
  5. #define V8CONFIG_H_
  6. // clang-format off
  7. // Platform headers for feature detection below.
  8. #if defined(__ANDROID__)
  9. # include <sys/cdefs.h>
  10. #elif defined(__APPLE__)
  11. # include <TargetConditionals.h>
  12. #elif defined(__linux__)
  13. # include <features.h>
  14. #endif
  15. // This macro allows to test for the version of the GNU C library (or
  16. // a compatible C library that masquerades as glibc). It evaluates to
  17. // 0 if libc is not GNU libc or compatible.
  18. // Use like:
  19. // #if V8_GLIBC_PREREQ(2, 3)
  20. // ...
  21. // #endif
  22. #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
  23. # define V8_GLIBC_PREREQ(major, minor) \
  24. ((__GLIBC__ * 100 + __GLIBC_MINOR__) >= ((major) * 100 + (minor)))
  25. #else
  26. # define V8_GLIBC_PREREQ(major, minor) 0
  27. #endif
  28. // This macro allows to test for the version of the GNU C++ compiler.
  29. // Note that this also applies to compilers that masquerade as GCC,
  30. // for example clang and the Intel C++ compiler for Linux.
  31. // Use like:
  32. // #if V8_GNUC_PREREQ(4, 3, 1)
  33. // ...
  34. // #endif
  35. #if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
  36. # define V8_GNUC_PREREQ(major, minor, patchlevel) \
  37. ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= \
  38. ((major) * 10000 + (minor) * 100 + (patchlevel)))
  39. #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
  40. # define V8_GNUC_PREREQ(major, minor, patchlevel) \
  41. ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= \
  42. ((major) * 10000 + (minor) * 100 + (patchlevel)))
  43. #else
  44. # define V8_GNUC_PREREQ(major, minor, patchlevel) 0
  45. #endif
  46. // -----------------------------------------------------------------------------
  47. // Operating system detection
  48. //
  49. // V8_OS_ANDROID - Android
  50. // V8_OS_BSD - BSDish (Mac OS X, Net/Free/Open/DragonFlyBSD)
  51. // V8_OS_CYGWIN - Cygwin
  52. // V8_OS_DRAGONFLYBSD - DragonFlyBSD
  53. // V8_OS_FREEBSD - FreeBSD
  54. // V8_OS_FUCHSIA - Fuchsia
  55. // V8_OS_LINUX - Linux
  56. // V8_OS_MACOSX - Mac OS X
  57. // V8_OS_IOS - iOS
  58. // V8_OS_NETBSD - NetBSD
  59. // V8_OS_OPENBSD - OpenBSD
  60. // V8_OS_POSIX - POSIX compatible (mostly everything except Windows)
  61. // V8_OS_QNX - QNX Neutrino
  62. // V8_OS_SOLARIS - Sun Solaris and OpenSolaris
  63. // V8_OS_AIX - AIX
  64. // V8_OS_WIN - Microsoft Windows
  65. #if defined(__ANDROID__)
  66. # define V8_OS_ANDROID 1
  67. # define V8_OS_LINUX 1
  68. # define V8_OS_POSIX 1
  69. #elif defined(__APPLE__)
  70. # define V8_OS_BSD 1
  71. # define V8_OS_MACOSX 1
  72. # define V8_OS_POSIX 1
  73. # if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
  74. # define V8_OS_IOS 1
  75. # endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
  76. #elif defined(__CYGWIN__)
  77. # define V8_OS_CYGWIN 1
  78. # define V8_OS_POSIX 1
  79. #elif defined(__linux__)
  80. # define V8_OS_LINUX 1
  81. # define V8_OS_POSIX 1
  82. #elif defined(__sun)
  83. # define V8_OS_POSIX 1
  84. # define V8_OS_SOLARIS 1
  85. #elif defined(_AIX)
  86. #define V8_OS_POSIX 1
  87. #define V8_OS_AIX 1
  88. #elif defined(__FreeBSD__)
  89. # define V8_OS_BSD 1
  90. # define V8_OS_FREEBSD 1
  91. # define V8_OS_POSIX 1
  92. #elif defined(__Fuchsia__)
  93. # define V8_OS_FUCHSIA 1
  94. # define V8_OS_POSIX 1
  95. #elif defined(__DragonFly__)
  96. # define V8_OS_BSD 1
  97. # define V8_OS_DRAGONFLYBSD 1
  98. # define V8_OS_POSIX 1
  99. #elif defined(__NetBSD__)
  100. # define V8_OS_BSD 1
  101. # define V8_OS_NETBSD 1
  102. # define V8_OS_POSIX 1
  103. #elif defined(__OpenBSD__)
  104. # define V8_OS_BSD 1
  105. # define V8_OS_OPENBSD 1
  106. # define V8_OS_POSIX 1
  107. #elif defined(__QNXNTO__)
  108. # define V8_OS_POSIX 1
  109. # define V8_OS_QNX 1
  110. #elif defined(_WIN32)
  111. # define V8_OS_WIN 1
  112. #endif
  113. // -----------------------------------------------------------------------------
  114. // C library detection
  115. //
  116. // V8_LIBC_MSVCRT - MSVC libc
  117. // V8_LIBC_BIONIC - Bionic libc
  118. // V8_LIBC_BSD - BSD libc derivate
  119. // V8_LIBC_GLIBC - GNU C library
  120. // V8_LIBC_UCLIBC - uClibc
  121. //
  122. // Note that testing for libc must be done using #if not #ifdef. For example,
  123. // to test for the GNU C library, use:
  124. // #if V8_LIBC_GLIBC
  125. // ...
  126. // #endif
  127. #if defined (_MSC_VER)
  128. # define V8_LIBC_MSVCRT 1
  129. #elif defined(__BIONIC__)
  130. # define V8_LIBC_BIONIC 1
  131. # define V8_LIBC_BSD 1
  132. #elif defined(__UCLIBC__)
  133. // Must test for UCLIBC before GLIBC, as UCLIBC pretends to be GLIBC.
  134. # define V8_LIBC_UCLIBC 1
  135. #elif defined(__GLIBC__) || defined(__GNU_LIBRARY__)
  136. # define V8_LIBC_GLIBC 1
  137. #else
  138. # define V8_LIBC_BSD V8_OS_BSD
  139. #endif
  140. // -----------------------------------------------------------------------------
  141. // Compiler detection
  142. //
  143. // V8_CC_GNU - GCC, or clang in gcc mode
  144. // V8_CC_INTEL - Intel C++
  145. // V8_CC_MINGW - Minimalist GNU for Windows
  146. // V8_CC_MINGW32 - Minimalist GNU for Windows (mingw32)
  147. // V8_CC_MINGW64 - Minimalist GNU for Windows (mingw-w64)
  148. // V8_CC_MSVC - Microsoft Visual C/C++, or clang in cl.exe mode
  149. //
  150. // C++11 feature detection
  151. //
  152. // Compiler-specific feature detection
  153. //
  154. // V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline))
  155. // supported
  156. // V8_HAS_ATTRIBUTE_DEPRECATED - __attribute__((deprecated)) supported
  157. // V8_HAS_ATTRIBUTE_NOINLINE - __attribute__((noinline)) supported
  158. // V8_HAS_ATTRIBUTE_UNUSED - __attribute__((unused)) supported
  159. // V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported
  160. // V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT - __attribute__((warn_unused_result))
  161. // supported
  162. // V8_HAS_BUILTIN_BSWAP16 - __builtin_bswap16() supported
  163. // V8_HAS_BUILTIN_BSWAP32 - __builtin_bswap32() supported
  164. // V8_HAS_BUILTIN_BSWAP64 - __builtin_bswap64() supported
  165. // V8_HAS_BUILTIN_CLZ - __builtin_clz() supported
  166. // V8_HAS_BUILTIN_CTZ - __builtin_ctz() supported
  167. // V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported
  168. // V8_HAS_BUILTIN_FRAME_ADDRESS - __builtin_frame_address() supported
  169. // V8_HAS_BUILTIN_POPCOUNT - __builtin_popcount() supported
  170. // V8_HAS_BUILTIN_SADD_OVERFLOW - __builtin_sadd_overflow() supported
  171. // V8_HAS_BUILTIN_SSUB_OVERFLOW - __builtin_ssub_overflow() supported
  172. // V8_HAS_BUILTIN_UADD_OVERFLOW - __builtin_uadd_overflow() supported
  173. // V8_HAS_DECLSPEC_DEPRECATED - __declspec(deprecated) supported
  174. // V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported
  175. // V8_HAS_DECLSPEC_SELECTANY - __declspec(selectany) supported
  176. // V8_HAS_DECLSPEC_NORETURN - __declspec(noreturn) supported
  177. // V8_HAS___FORCEINLINE - __forceinline supported
  178. //
  179. // Note that testing for compilers and/or features must be done using #if
  180. // not #ifdef. For example, to test for Intel C++ Compiler, use:
  181. // #if V8_CC_INTEL
  182. // ...
  183. // #endif
  184. #if defined(__clang__)
  185. #if defined(__GNUC__) // Clang in gcc mode.
  186. # define V8_CC_GNU 1
  187. #endif
  188. # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline))
  189. # define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated))
  190. # define V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE \
  191. (__has_extension(attribute_deprecated_with_message))
  192. # define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline))
  193. # define V8_HAS_ATTRIBUTE_UNUSED (__has_attribute(unused))
  194. # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility))
  195. # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \
  196. (__has_attribute(warn_unused_result))
  197. # define V8_HAS_BUILTIN_BSWAP16 (__has_builtin(__builtin_bswap16))
  198. # define V8_HAS_BUILTIN_BSWAP32 (__has_builtin(__builtin_bswap32))
  199. # define V8_HAS_BUILTIN_BSWAP64 (__has_builtin(__builtin_bswap64))
  200. # define V8_HAS_BUILTIN_CLZ (__has_builtin(__builtin_clz))
  201. # define V8_HAS_BUILTIN_CTZ (__has_builtin(__builtin_ctz))
  202. # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect))
  203. # define V8_HAS_BUILTIN_FRAME_ADDRESS (__has_builtin(__builtin_frame_address))
  204. # define V8_HAS_BUILTIN_POPCOUNT (__has_builtin(__builtin_popcount))
  205. # define V8_HAS_BUILTIN_SADD_OVERFLOW (__has_builtin(__builtin_sadd_overflow))
  206. # define V8_HAS_BUILTIN_SSUB_OVERFLOW (__has_builtin(__builtin_ssub_overflow))
  207. # define V8_HAS_BUILTIN_UADD_OVERFLOW (__has_builtin(__builtin_uadd_overflow))
  208. # if __cplusplus >= 201402L
  209. # define V8_CAN_HAVE_DCHECK_IN_CONSTEXPR 1
  210. # endif
  211. #elif defined(__GNUC__)
  212. # define V8_CC_GNU 1
  213. # if defined(__INTEL_COMPILER) // Intel C++ also masquerades as GCC 3.2.0
  214. # define V8_CC_INTEL 1
  215. # endif
  216. # if defined(__MINGW32__)
  217. # define V8_CC_MINGW32 1
  218. # endif
  219. # if defined(__MINGW64__)
  220. # define V8_CC_MINGW64 1
  221. # endif
  222. # define V8_CC_MINGW (V8_CC_MINGW32 || V8_CC_MINGW64)
  223. // always_inline is available in gcc 4.0 but not very reliable until 4.4.
  224. // Works around "sorry, unimplemented: inlining failed" build errors with
  225. // older compilers.
  226. # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (V8_GNUC_PREREQ(4, 4, 0))
  227. # define V8_HAS_ATTRIBUTE_DEPRECATED (V8_GNUC_PREREQ(3, 4, 0))
  228. # define V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE (V8_GNUC_PREREQ(4, 5, 0))
  229. # define V8_HAS_ATTRIBUTE_NOINLINE (V8_GNUC_PREREQ(3, 4, 0))
  230. # define V8_HAS_ATTRIBUTE_UNUSED (V8_GNUC_PREREQ(2, 95, 0))
  231. # define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0))
  232. # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \
  233. (!V8_CC_INTEL && V8_GNUC_PREREQ(4, 1, 0))
  234. # define V8_HAS_BUILTIN_CLZ (V8_GNUC_PREREQ(3, 4, 0))
  235. # define V8_HAS_BUILTIN_CTZ (V8_GNUC_PREREQ(3, 4, 0))
  236. # define V8_HAS_BUILTIN_EXPECT (V8_GNUC_PREREQ(2, 96, 0))
  237. # define V8_HAS_BUILTIN_FRAME_ADDRESS (V8_GNUC_PREREQ(2, 96, 0))
  238. # define V8_HAS_BUILTIN_POPCOUNT (V8_GNUC_PREREQ(3, 4, 0))
  239. #endif
  240. #if defined(_MSC_VER)
  241. # define V8_CC_MSVC 1
  242. # define V8_HAS_DECLSPEC_DEPRECATED 1
  243. # define V8_HAS_DECLSPEC_NOINLINE 1
  244. # define V8_HAS_DECLSPEC_SELECTANY 1
  245. # define V8_HAS_DECLSPEC_NORETURN 1
  246. # define V8_HAS___FORCEINLINE 1
  247. #endif
  248. // -----------------------------------------------------------------------------
  249. // Helper macros
  250. // A macro used to make better inlining. Don't bother for debug builds.
  251. // Use like:
  252. // V8_INLINE int GetZero() { return 0; }
  253. #if !defined(DEBUG) && V8_HAS_ATTRIBUTE_ALWAYS_INLINE
  254. # define V8_INLINE inline __attribute__((always_inline))
  255. #elif !defined(DEBUG) && V8_HAS___FORCEINLINE
  256. # define V8_INLINE __forceinline
  257. #else
  258. # define V8_INLINE inline
  259. #endif
  260. // A macro used to tell the compiler to never inline a particular function.
  261. // Don't bother for debug builds.
  262. // Use like:
  263. // V8_NOINLINE int GetMinusOne() { return -1; }
  264. #if !defined(DEBUG) && V8_HAS_ATTRIBUTE_NOINLINE
  265. # define V8_NOINLINE __attribute__((noinline))
  266. #elif !defined(DEBUG) && V8_HAS_DECLSPEC_NOINLINE
  267. # define V8_NOINLINE __declspec(noinline)
  268. #else
  269. # define V8_NOINLINE /* NOT SUPPORTED */
  270. #endif
  271. // A macro (V8_DEPRECATED) to mark classes or functions as deprecated.
  272. #if defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE
  273. #define V8_DEPRECATED(message, declarator) \
  274. declarator __attribute__((deprecated(message)))
  275. #elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED
  276. #define V8_DEPRECATED(message, declarator) \
  277. declarator __attribute__((deprecated))
  278. #elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_DECLSPEC_DEPRECATED
  279. #define V8_DEPRECATED(message, declarator) __declspec(deprecated) declarator
  280. #else
  281. #define V8_DEPRECATED(message, declarator) declarator
  282. #endif
  283. // A macro (V8_DEPRECATE_SOON) to make it easier to see what will be deprecated.
  284. #if defined(V8_IMMINENT_DEPRECATION_WARNINGS) && \
  285. V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE
  286. #define V8_DEPRECATE_SOON(message, declarator) \
  287. declarator __attribute__((deprecated(message)))
  288. #elif defined(V8_IMMINENT_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED
  289. #define V8_DEPRECATE_SOON(message, declarator) \
  290. declarator __attribute__((deprecated))
  291. #elif defined(V8_IMMINENT_DEPRECATION_WARNINGS) && V8_HAS_DECLSPEC_DEPRECATED
  292. #define V8_DEPRECATE_SOON(message, declarator) __declspec(deprecated) declarator
  293. #else
  294. #define V8_DEPRECATE_SOON(message, declarator) declarator
  295. #endif
  296. // A macro to provide the compiler with branch prediction information.
  297. #if V8_HAS_BUILTIN_EXPECT
  298. # define V8_UNLIKELY(condition) (__builtin_expect(!!(condition), 0))
  299. # define V8_LIKELY(condition) (__builtin_expect(!!(condition), 1))
  300. #else
  301. # define V8_UNLIKELY(condition) (condition)
  302. # define V8_LIKELY(condition) (condition)
  303. #endif
  304. // Annotate a function indicating the caller must examine the return value.
  305. // Use like:
  306. // int foo() V8_WARN_UNUSED_RESULT;
  307. #if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT
  308. #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
  309. #else
  310. #define V8_WARN_UNUSED_RESULT /* NOT SUPPORTED */
  311. #endif
  312. #if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED)
  313. #error Inconsistent build configuration: To build the V8 shared library \
  314. set BUILDING_V8_SHARED, to include its headers for linking against the \
  315. V8 shared library set USING_V8_SHARED.
  316. #endif
  317. #ifdef V8_OS_WIN
  318. // Setup for Windows DLL export/import. When building the V8 DLL the
  319. // BUILDING_V8_SHARED needs to be defined. When building a program which uses
  320. // the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8
  321. // static library or building a program which uses the V8 static library neither
  322. // BUILDING_V8_SHARED nor USING_V8_SHARED should be defined.
  323. #ifdef BUILDING_V8_SHARED
  324. # define V8_EXPORT __declspec(dllexport)
  325. #elif USING_V8_SHARED
  326. # define V8_EXPORT __declspec(dllimport)
  327. #else
  328. # define V8_EXPORT
  329. #endif // BUILDING_V8_SHARED
  330. #else // V8_OS_WIN
  331. // Setup for Linux shared library export.
  332. #if V8_HAS_ATTRIBUTE_VISIBILITY
  333. # ifdef BUILDING_V8_SHARED
  334. # define V8_EXPORT __attribute__ ((visibility("default")))
  335. # else
  336. # define V8_EXPORT
  337. # endif
  338. #else
  339. # define V8_EXPORT
  340. #endif
  341. #endif // V8_OS_WIN
  342. // clang-format on
  343. #endif // V8CONFIG_H_