JavaScript-Embedded
view release on metacpan or search on metacpan
lib/JavaScript/Embedded/C/lib/duk_config.h view on Meta::CPAN
#define DUK_STRLEN strlen
#endif
#if !defined(DUK_STRCMP)
#define DUK_STRCMP strcmp
#endif
#if !defined(DUK_STRNCMP)
#define DUK_STRNCMP strncmp
#endif
#if !defined(DUK_SPRINTF)
#define DUK_SPRINTF sprintf
#endif
#if !defined(DUK_SNPRINTF)
/* snprintf() is technically not part of C89 but usually available. */
#define DUK_SNPRINTF snprintf
#endif
#if !defined(DUK_VSPRINTF)
#define DUK_VSPRINTF vsprintf
#endif
#if !defined(DUK_VSNPRINTF)
/* vsnprintf() is technically not part of C89 but usually available. */
#define DUK_VSNPRINTF vsnprintf
#endif
#if !defined(DUK_SSCANF)
#define DUK_SSCANF sscanf
#endif
#if !defined(DUK_VSSCANF)
#define DUK_VSSCANF vsscanf
#endif
#if !defined(DUK_MEMZERO)
#define DUK_MEMZERO(p,n) DUK_MEMSET((p), 0, (n))
#endif
#if !defined(DUK_DOUBLE_INFINITY)
#undef DUK_USE_COMPUTED_INFINITY
#if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION < 40600)
/* GCC older than 4.6: avoid overflow warnings related to using INFINITY */
#define DUK_DOUBLE_INFINITY (__builtin_inf())
#elif defined(INFINITY)
#define DUK_DOUBLE_INFINITY ((double) INFINITY)
#elif !defined(DUK_F_VBCC) && !defined(DUK_F_MSVC) && !defined(DUK_F_BCC) && \
!defined(DUK_F_OLD_SOLARIS) && !defined(DUK_F_AIX)
#define DUK_DOUBLE_INFINITY (1.0 / 0.0)
#else
/* In VBCC (1.0 / 0.0) results in a warning and 0.0 instead of infinity.
* Use a computed infinity (initialized when a heap is created at the
* latest).
*/
#define DUK_USE_COMPUTED_INFINITY
#define DUK_DOUBLE_INFINITY duk_computed_infinity
#endif
#endif
#if !defined(DUK_DOUBLE_NAN)
#undef DUK_USE_COMPUTED_NAN
#if defined(NAN)
#define DUK_DOUBLE_NAN NAN
#elif !defined(DUK_F_VBCC) && !defined(DUK_F_MSVC) && !defined(DUK_F_BCC) && \
!defined(DUK_F_OLD_SOLARIS) && !defined(DUK_F_AIX)
#define DUK_DOUBLE_NAN (0.0 / 0.0)
#else
/* In VBCC (0.0 / 0.0) results in a warning and 0.0 instead of NaN.
* In MSVC (VS2010 Express) (0.0 / 0.0) results in a compile error.
* Use a computed NaN (initialized when a heap is created at the
* latest).
*/
#define DUK_USE_COMPUTED_NAN
#define DUK_DOUBLE_NAN duk_computed_nan
#endif
#endif
/* Many platforms are missing fpclassify() and friends, so use replacements
* if necessary. The replacement constants (FP_NAN etc) can be anything but
* match Linux constants now.
*/
#undef DUK_USE_REPL_FPCLASSIFY
#undef DUK_USE_REPL_SIGNBIT
#undef DUK_USE_REPL_ISFINITE
#undef DUK_USE_REPL_ISNAN
#undef DUK_USE_REPL_ISINF
/* Complex condition broken into separate parts. */
#undef DUK_F_USE_REPL_ALL
#if !(defined(FP_NAN) && defined(FP_INFINITE) && defined(FP_ZERO) && \
defined(FP_SUBNORMAL) && defined(FP_NORMAL))
/* Missing some obvious constants. */
#define DUK_F_USE_REPL_ALL
#elif defined(DUK_F_AMIGAOS) && defined(DUK_F_VBCC)
/* VBCC is missing the built-ins even in C99 mode (perhaps a header issue). */
#define DUK_F_USE_REPL_ALL
#elif defined(DUK_F_AMIGAOS) && defined(DUK_F_M68K)
/* AmigaOS + M68K seems to have math issues even when using GCC cross
* compilation. Use replacements for all AmigaOS versions on M68K
* regardless of compiler.
*/
#define DUK_F_USE_REPL_ALL
#elif defined(DUK_F_FREEBSD) && defined(DUK_F_CLANG)
/* Placeholder fix for (detection is wider than necessary):
* http://llvm.org/bugs/show_bug.cgi?id=17788
*/
#define DUK_F_USE_REPL_ALL
#elif defined(DUK_F_UCLIBC)
/* At least some uclibc versions have broken floating point math. For
* example, fpclassify() can incorrectly classify certain NaN formats.
* To be safe, use replacements.
*/
#define DUK_F_USE_REPL_ALL
#elif defined(DUK_F_AIX)
/* Older versions may be missing isnan(), etc. */
#define DUK_F_USE_REPL_ALL
#endif
#if defined(DUK_F_USE_REPL_ALL)
#define DUK_USE_REPL_FPCLASSIFY
#define DUK_USE_REPL_SIGNBIT
#define DUK_USE_REPL_ISFINITE
#define DUK_USE_REPL_ISNAN
#define DUK_USE_REPL_ISINF
#define DUK_FPCLASSIFY duk_repl_fpclassify
#define DUK_SIGNBIT duk_repl_signbit
#define DUK_ISFINITE duk_repl_isfinite
#define DUK_ISNAN duk_repl_isnan
#define DUK_ISINF duk_repl_isinf
#define DUK_FP_NAN 0
#define DUK_FP_INFINITE 1
#define DUK_FP_ZERO 2
#define DUK_FP_SUBNORMAL 3
#define DUK_FP_NORMAL 4
#else
#define DUK_FPCLASSIFY fpclassify
#define DUK_SIGNBIT signbit
#define DUK_ISFINITE isfinite
#define DUK_ISNAN isnan
#define DUK_ISINF isinf
#define DUK_FP_NAN FP_NAN
#define DUK_FP_INFINITE FP_INFINITE
#define DUK_FP_ZERO FP_ZERO
#define DUK_FP_SUBNORMAL FP_SUBNORMAL
#define DUK_FP_NORMAL FP_NORMAL
#endif
#if defined(DUK_F_USE_REPL_ALL)
#undef DUK_F_USE_REPL_ALL
#endif
/* These functions don't currently need replacement but are wrapped for
* completeness. Because these are used as function pointers, they need
* to be defined as concrete C functions (not macros).
*/
#if !defined(DUK_FABS)
#define DUK_FABS fabs
#endif
#if !defined(DUK_FLOOR)
#define DUK_FLOOR floor
#endif
#if !defined(DUK_CEIL)
#define DUK_CEIL ceil
#endif
#if !defined(DUK_FMOD)
#define DUK_FMOD fmod
#endif
#if !defined(DUK_POW)
#define DUK_POW pow
#endif
lib/JavaScript/Embedded/C/lib/duk_config.h view on Meta::CPAN
#define DUK_ATAN2 atan2
#endif
#if !defined(DUK_SIN)
#define DUK_SIN sin
#endif
#if !defined(DUK_COS)
#define DUK_COS cos
#endif
#if !defined(DUK_TAN)
#define DUK_TAN tan
#endif
#if !defined(DUK_EXP)
#define DUK_EXP exp
#endif
#if !defined(DUK_LOG)
#define DUK_LOG log
#endif
#if !defined(DUK_SQRT)
#define DUK_SQRT sqrt
#endif
/* The functions below exist only in C99/C++11 or later and need a workaround
* for platforms that don't include them. MSVC isn't detected as C99, but
* these functions also exist in MSVC 2013 and later so include a clause for
* that too. Android doesn't have log2; disable all of these for Android.
*/
#if (defined(DUK_F_C99) || defined(DUK_F_CPP11) || (defined(_MSC_VER) && (_MSC_VER >= 1800))) && \
!defined(DUK_F_ANDROID) && !defined(DUK_F_MINT)
#if !defined(DUK_CBRT)
#define DUK_CBRT cbrt
#endif
#if !defined(DUK_LOG2)
#define DUK_LOG2 log2
#endif
#if !defined(DUK_LOG10)
#define DUK_LOG10 log10
#endif
#if !defined(DUK_TRUNC)
#define DUK_TRUNC trunc
#endif
#endif /* DUK_F_C99 etc */
/* NetBSD 6.0 x86 (at least) has a few problems with pow() semantics,
* see test-bug-netbsd-math-pow.js. MinGW has similar (but different)
* issues, see test-bug-mingw-math-issues.js. Enable pow() workarounds
* for these targets.
*/
#undef DUK_USE_POW_WORKAROUNDS
#if defined(DUK_F_NETBSD) || defined(DUK_F_MINGW)
#define DUK_USE_POW_WORKAROUNDS
#endif
/* Similar workarounds for atan2() semantics issues. MinGW issues are
* documented in test-bug-mingw-math-issues.js.
*/
#undef DUK_USE_ATAN2_WORKAROUNDS
#if defined(DUK_F_MINGW)
#define DUK_USE_ATAN2_WORKAROUNDS
#endif
/* Rely as little as possible on compiler behavior for NaN comparison,
* signed zero handling, etc. Currently never activated but may be needed
* for broken compilers.
*/
#undef DUK_USE_PARANOID_MATH
/* There was a curious bug where test-bi-date-canceling.js would fail e.g.
* on 64-bit Ubuntu, gcc-4.8.1, -m32, and no -std=c99. Some date computations
* using doubles would be optimized which then broke some corner case tests.
* The problem goes away by adding 'volatile' to the datetime computations.
* Not sure what the actual triggering conditions are, but using this on
* non-C99 systems solves the known issues and has relatively little cost
* on other platforms.
*/
#undef DUK_USE_PARANOID_DATE_COMPUTATION
#if !defined(DUK_F_C99)
#define DUK_USE_PARANOID_DATE_COMPUTATION
#endif
/*
* Byte order and double memory layout detection
*
* Endianness detection is a major portability hassle because the macros
* and headers are not standardized. There's even variance across UNIX
* platforms. Even with "standard" headers, details like underscore count
* varies between platforms, e.g. both __BYTE_ORDER and _BYTE_ORDER are used
* (Crossbridge has a single underscore, for instance).
*
* The checks below are structured with this in mind: several approaches are
* used, and at the end we check if any of them worked. This allows generic
* approaches to be tried first, and platform/compiler specific hacks tried
* last. As a last resort, the user can force a specific endianness, as it's
* not likely that automatic detection will work on the most exotic platforms.
*
* Duktape supports little and big endian machines. There's also support
* for a hybrid used by some ARM machines where integers are little endian
* but IEEE double values use a mixed order (12345678 -> 43218765). This
* byte order for doubles is referred to as "mixed endian".
*/
/* GCC and Clang provide endianness defines as built-in predefines, with
* leading and trailing double underscores (e.g. __BYTE_ORDER__). See
* output of "make gccpredefs" and "make clangpredefs". Clang doesn't
* seem to provide __FLOAT_WORD_ORDER__; assume not mixed endian for clang.
* http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
*/
#if !defined(DUK_USE_BYTEORDER) && defined(__BYTE_ORDER__)
#if defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
#if defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__)
#define DUK_USE_BYTEORDER 1
#elif defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__)
#define DUK_USE_BYTEORDER 2
#elif !defined(__FLOAT_WORD_ORDER__)
/* Float word order not known, assume not a hybrid. */
#define DUK_USE_BYTEORDER 1
#else
/* Byte order is little endian but cannot determine IEEE double word order. */
#endif /* float word order */
#elif defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
#if defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__)
#define DUK_USE_BYTEORDER 3
( run in 1.218 second using v1.01-cache-2.11-cpan-39bf76dae61 )