Browse Source

use fpclassify() etc replacements in FreeBSD + clang to avoid a FreeBSD math.h header bug

pull/1/head
Sami Vaarala 11 years ago
parent
commit
ce1faf070f
  1. 33
      src/duk_features.h

33
src/duk_features.h

@ -152,6 +152,11 @@ static __inline__ unsigned long long duk_rdtsc(void) {
#define DUK_F_AMIGAOS #define DUK_F_AMIGAOS
#endif #endif
/* FreeBSD. */
#if defined(__FreeBSD__)
#define DUK_F_FREEBSD
#endif
/* GCC and GCC version convenience define. */ /* GCC and GCC version convenience define. */
#if defined(__GNUC__) #if defined(__GNUC__)
#define DUK_F_GCC #define DUK_F_GCC
@ -163,6 +168,11 @@ static __inline__ unsigned long long duk_rdtsc(void) {
#endif #endif
#endif #endif
/* Clang. */
#if defined(__clang__)
#define DUK_F_CLANG
#endif
/* /*
* Platform detection and system includes * Platform detection and system includes
* *
@ -777,9 +787,24 @@ extern double duk_computed_nan;
#undef DUK_USE_REPL_SIGNBIT #undef DUK_USE_REPL_SIGNBIT
#undef DUK_USE_REPL_ISFINITE #undef DUK_USE_REPL_ISFINITE
#undef DUK_USE_REPL_ISNAN #undef DUK_USE_REPL_ISNAN
/* complex condition broken into separate parts */
#undef DUK_F_USE_REPL_ALL
#if !(defined(FP_NAN) && defined(FP_INFINITE) && defined(FP_ZERO) && \ #if !(defined(FP_NAN) && defined(FP_INFINITE) && defined(FP_ZERO) && \
defined(FP_SUBNORMAL) && defined(FP_NORMAL)) || \ defined(FP_SUBNORMAL) && defined(FP_NORMAL))
(defined(DUK_F_AMIGAOS) && defined(__VBCC__)) /* missing some obvious constants */
#define DUK_F_USE_REPL_ALL
#elif defined(DUK_F_AMIGAOS) && defined(__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_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
#endif
#if defined(DUK_F_USE_REPL_ALL)
#define DUK_USE_REPL_FPCLASSIFY #define DUK_USE_REPL_FPCLASSIFY
#define DUK_USE_REPL_SIGNBIT #define DUK_USE_REPL_SIGNBIT
#define DUK_USE_REPL_ISFINITE #define DUK_USE_REPL_ISFINITE
@ -805,6 +830,10 @@ extern double duk_computed_nan;
#define DUK_FP_NORMAL FP_NORMAL #define DUK_FP_NORMAL FP_NORMAL
#endif #endif
#if defined(DUK_F_USE_REPL_ALL)
#undef DUK_F_USE_REPL_ALL
#endif
/* Some math functions are C99 only. This is also an issue with some /* Some math functions are C99 only. This is also an issue with some
* embedded environments using uclibc where uclibc has been configured * embedded environments using uclibc where uclibc has been configured
* not to provide some functions. For now, use replacements whenever * not to provide some functions. For now, use replacements whenever

Loading…
Cancel
Save