diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 417f5fef5a41..d8ce842e7de9 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -124,6 +124,14 @@ using JS::SourceText; # define JS_ADDRESSOF_VA_LIST(ap) (&(ap)) #endif +// See preprocessor definition of JS_BITS_PER_WORD in jstypes.h; make sure +// JS_64BIT (used internally) agrees with it +#ifdef JS_64BIT +static_assert(JS_BITS_PER_WORD == 64, "values must be in sync"); +#else +static_assert(JS_BITS_PER_WORD == 32, "values must be in sync"); +#endif + JS_PUBLIC_API void JS::CallArgs::reportMoreArgsNeeded(JSContext* cx, const char* fnname, unsigned required, diff --git a/js/src/jstypes.h b/js/src/jstypes.h index 8d24a3aaf02c..f3881456301c 100644 --- a/js/src/jstypes.h +++ b/js/src/jstypes.h @@ -109,12 +109,17 @@ constexpr size_t RoundDown(size_t x, size_t y) { return (x / y) * y; } constexpr size_t Round(size_t x, size_t y) { return ((x + y / 2) / y) * y; } } // namespace js -#if defined(JS_64BIT) +#if (defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 8) || \ + (defined(UINTPTR_MAX) && UINTPTR_MAX == 0xFFFFFFFFFFFFFFFFu) # define JS_BITS_PER_WORD 64 #else # define JS_BITS_PER_WORD 32 #endif +static_assert(sizeof(void*) == 8 ? JS_BITS_PER_WORD == 64 + : JS_BITS_PER_WORD == 32, + "preprocessor and compiler must agree"); + /*********************************************************************** ** MACROS: JS_FUNC_TO_DATA_PTR ** JS_DATA_TO_FUNC_PTR