JavaScript-Embedded
view release on metacpan or search on metacpan
lib/JavaScript/Embedded/C/lib/duk_config.h view on Meta::CPAN
* 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
#elif !defined(__FLOAT_WORD_ORDER__)
/* Float word order not known, assume not a hybrid. */
#define DUK_USE_BYTEORDER 3
#else
/* Byte order is big endian but cannot determine IEEE double word order. */
#endif /* float word order */
#else
/* Cannot determine byte order; __ORDER_PDP_ENDIAN__ is related to 32-bit
* integer ordering and is not relevant.
*/
#endif /* integer byte order */
#endif /* !defined(DUK_USE_BYTEORDER) && defined(__BYTE_ORDER__) */
/* More or less standard endianness predefines provided by header files.
* The ARM hybrid case is detected by assuming that __FLOAT_WORD_ORDER
* will be big endian, see: http://lists.mysql.com/internals/443.
* On some platforms some defines may be present with an empty value which
* causes comparisons to fail: https://github.com/svaarala/duktape/issues/453.
*/
#if !defined(DUK_USE_BYTEORDER)
#if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && (__BYTE_ORDER == __LITTLE_ENDIAN) || \
defined(_BYTE_ORDER) && defined(_LITTLE_ENDIAN) && (_BYTE_ORDER == _LITTLE_ENDIAN) || \
defined(__LITTLE_ENDIAN__)
#if defined(__FLOAT_WORD_ORDER) && defined(__LITTLE_ENDIAN) && (__FLOAT_WORD_ORDER == __LITTLE_ENDIAN) || \
defined(_FLOAT_WORD_ORDER) && defined(_LITTLE_ENDIAN) && (_FLOAT_WORD_ORDER == _LITTLE_ENDIAN)
#define DUK_USE_BYTEORDER 1
#elif defined(__FLOAT_WORD_ORDER) && defined(__BIG_ENDIAN) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) || \
defined(_FLOAT_WORD_ORDER) && defined(_BIG_ENDIAN) && (_FLOAT_WORD_ORDER == _BIG_ENDIAN)
#define DUK_USE_BYTEORDER 2
#elif !defined(__FLOAT_WORD_ORDER) && !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(__BYTE_ORDER) && defined(__BIG_ENDIAN) && (__BYTE_ORDER == __BIG_ENDIAN) || \
defined(_BYTE_ORDER) && defined(_BIG_ENDIAN) && (_BYTE_ORDER == _BIG_ENDIAN) || \
defined(__BIG_ENDIAN__)
#if defined(__FLOAT_WORD_ORDER) && defined(__BIG_ENDIAN) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) || \
defined(_FLOAT_WORD_ORDER) && defined(_BIG_ENDIAN) && (_FLOAT_WORD_ORDER == _BIG_ENDIAN)
#define DUK_USE_BYTEORDER 3
#elif !defined(__FLOAT_WORD_ORDER) && !defined(_FLOAT_WORD_ORDER)
/* Float word order not known, assume not a hybrid. */
#define DUK_USE_BYTEORDER 3
lib/JavaScript/Embedded/C/lib/duk_config.h view on Meta::CPAN
#endif
#endif
/*
* Alignment requirement and support for unaligned accesses
*
* Assume unaligned accesses are not supported unless specifically allowed
* in the target platform. Some platforms may support unaligned accesses
* but alignment to 4 or 8 may still be desirable. Note that unaligned
* accesses (and even pointers) relative to natural alignment (regardless
* of target alignment) are technically undefined behavior and thus
* compiler/architecture specific.
*/
/* If not forced, use safe default for alignment. */
#if !defined(DUK_USE_ALIGN_BY)
#define DUK_USE_ALIGN_BY 8
#endif
/* Compiler specific hackery needed to force struct size to match alignment,
* see e.g. duk_hbuffer.h.
*
* http://stackoverflow.com/questions/11130109/c-struct-size-alignment
* http://stackoverflow.com/questions/10951039/specifying-64-bit-alignment
*/
#if !(defined(DUK_USE_PACK_MSVC_PRAGMA) || defined(DUK_USE_PACK_GCC_ATTR) || \
defined(DUK_USE_PACK_CLANG_ATTR) || defined(DUK_USE_PACK_DUMMY_MEMBER))
#define DUK_USE_PACK_DUMMY_MEMBER
#endif
#if !defined(DUK_U64_CONSTANT)
#define DUK_U64_CONSTANT(x) x##ULL
#endif
#if !defined(DUK_I64_CONSTANT)
#define DUK_I64_CONSTANT(x) x##LL
#endif
#if !defined(DUK_VA_COPY)
/* We need va_copy() which is defined in C99 / C++11, so an awkward
* replacement is needed for pre-C99 / pre-C++11 environments. This
* will quite likely need portability hacks for some non-C99
* environments.
*/
#if defined(DUK_F_C99) || defined(DUK_F_CPP11)
/* C99 / C++11 and above: rely on va_copy() which is required.
* Omit parenthesis on macro right side on purpose to minimize differences
* to direct use.
*/
#define DUK_VA_COPY(dest,src) va_copy(dest,src)
#else
/* Pre-C99: va_list type is implementation dependent. This replacement
* assumes it is a plain value so that a simple assignment will work.
* This is not the case on all platforms (it may be a single-array element,
* for instance).
*/
#define DUK_VA_COPY(dest,src) do { (dest) = (src); } while (0)
#endif
#endif
#if !defined(DUK_MACRO_STRINGIFY)
/* Macro hackery to convert e.g. __LINE__ to a string without formatting,
* see: http://stackoverflow.com/questions/240353/convert-a-preprocessor-token-to-a-string
*/
#define DUK_MACRO_STRINGIFY_HELPER(x) #x
#define DUK_MACRO_STRINGIFY(x) DUK_MACRO_STRINGIFY_HELPER(x)
#endif
#if !defined(DUK_CAUSE_SEGFAULT)
/* This can be used for testing; valgrind will then indicate the C call stack
* leading to the call site.
*/
#define DUK_CAUSE_SEGFAULT() do { *((volatile duk_uint32_t *) NULL) = (duk_uint32_t) 0xdeadbeefUL; } while (0)
#endif
#if !defined(DUK_UNREF)
/* Macro for suppressing warnings for potentially unreferenced variables.
* The variables can be actually unreferenced or unreferenced in some
* specific cases only; for instance, if a variable is only debug printed,
* it is unreferenced when debug printing is disabled. May cause warnings
* for volatile arguments.
*/
#define DUK_UNREF(x) do { (void) (x); } while (0)
#endif
/* Fillin for DUK_NORETURN; DUK_WO_NORETURN() is used to insert dummy
* dummy statements after noreturn calls to silence harmless compiler
* warnings, e.g.:
*
* DUK_ERROR_TYPE(thr, "aiee");
* DUK_WO_NORETURN(return 0;);
*
* Statements inside DUK_WO_NORETURN() must NEVER be actually reachable,
* and they're only included to satisfy the compiler.
*/
#if defined(DUK_NORETURN)
#define DUK_WO_NORETURN(stmt) do { } while (0)
#else
#define DUK_NORETURN(decl) decl
#define DUK_WO_NORETURN(stmt) do { stmt } while (0)
#endif
#if defined(DUK_UNREACHABLE)
#define DUK_WO_UNREACHABLE(stmt) do { } while (0)
#else
/* Don't know how to declare unreachable point, so don't do it; this
* may cause some spurious compilation warnings (e.g. "variable used
* uninitialized").
*/
#define DUK_UNREACHABLE() do { } while (0)
#define DUK_WO_UNREACHABLE(stmt) do { stmt } while (0)
#endif
#if !defined(DUK_LOSE_CONST)
/* Convert any input pointer into a "void *", losing a const qualifier.
* This is not fully portable because casting through duk_uintptr_t may
* not work on all architectures (e.g. those with long, segmented pointers).
*/
#define DUK_LOSE_CONST(src) ((void *) (duk_uintptr_t) (src))
#endif
#if !defined(DUK_LIKELY)
#define DUK_LIKELY(x) (x)
#endif
#if !defined(DUK_UNLIKELY)
#define DUK_UNLIKELY(x) (x)
#endif
#if !defined(DUK_UNPREDICTABLE)
#define DUK_UNPREDICTABLE(x) (x)
#endif
#if !defined(DUK_NOINLINE)
#define DUK_NOINLINE /*nop*/
#endif
#if !defined(DUK_INLINE)
#define DUK_INLINE /*nop*/
#endif
( run in 1.472 second using v1.01-cache-2.11-cpan-8644d7adfcd )