diff --git a/src/duk_bi_math.c b/src/duk_bi_math.c index c22cb349..7a5ed4b2 100644 --- a/src/duk_bi_math.c +++ b/src/duk_bi_math.c @@ -4,6 +4,8 @@ #include "duk_internal.h" +#if defined(DUK_USE_MATH_BUILTIN) + /* * Use static helpers which can work with math.h functions matching * the following signatures. This is not portable if any of these math @@ -248,3 +250,34 @@ duk_ret_t duk_bi_math_object_random(duk_context *ctx) { duk_push_number(ctx, (duk_double_t) duk_util_tinyrandom_get_double((duk_hthread *) ctx)); return 1; } + +#else /* DUK_USE_MATH_BUILTIN */ + +/* A stubbed built-in is useful for e.g. compilation torture testing with BCC. */ + +duk_ret_t duk_bi_math_object_onearg_shared(duk_context *ctx) { + DUK_UNREF(ctx); + return DUK_RET_UNIMPLEMENTED_ERROR; +} + +duk_ret_t duk_bi_math_object_twoarg_shared(duk_context *ctx) { + DUK_UNREF(ctx); + return DUK_RET_UNIMPLEMENTED_ERROR; +} + +duk_ret_t duk_bi_math_object_max(duk_context *ctx) { + DUK_UNREF(ctx); + return DUK_RET_UNIMPLEMENTED_ERROR; +} + +duk_ret_t duk_bi_math_object_min(duk_context *ctx) { + DUK_UNREF(ctx); + return DUK_RET_UNIMPLEMENTED_ERROR; +} + +duk_ret_t duk_bi_math_object_random(duk_context *ctx) { + DUK_UNREF(ctx); + return DUK_RET_UNIMPLEMENTED_ERROR; +} + +#endif /* DUK_USE_MATH_BUILTIN */ diff --git a/src/duk_features.h.in b/src/duk_features.h.in index 854937a3..1fe89707 100644 --- a/src/duk_features.h.in +++ b/src/duk_features.h.in @@ -1779,6 +1779,12 @@ typedef FILE duk_file; * Ecmascript features / compliance options */ +#if defined(DUK_F_BCC) +/* Math built-in is stubbed out on BCC to allow compiler torture testing. */ +#else +#define DUK_USE_MATH_BUILTIN +#endif + #define DUK_USE_REGEXP_SUPPORT #if defined(DUK_OPT_NO_REGEXP_SUPPORT) #undef DUK_USE_REGEXP_SUPPORT