зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1590907 - Determine 64-bit in public JS header without configure macro. r=froydnj,sfink
If only relying on JS_64BIT to determine whether the system is 64-bits, then the result will be incorrect when the header is installed as a public header for use by embedders, and since JS_BITS_PER_WORD affects the layout of structs in header files, things will go badly wrong. This uses two other ways of determining pointer width, hopefully cross-platform enough. __SIZEOF_POINTER__ is a GCC-ism and probably works in Clang as well. UINTPTR_MAX is hopefully sufficiently cross-platform as a last resort. Differential Revision: https://phabricator.services.mozilla.com/D52458 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
dda8b08621
Коммит
a896136d45
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче