From 65a106c95945338df4bfebd03390d7572eb1b09a Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 31 Jul 2023 16:43:20 +0200 Subject: QuickJS: Fix building on x86 Fixes: QBS-1744 Change-Id: Ic2a35650ac6dc00b63d7d274d4feba46cae676cb Reviewed-by: Ivan Komissarov --- changelogs/changes-2.1.1.md | 1 + src/lib/corelib/tools/scripttools.h | 2 ++ src/shared/quickjs/quickjs.c | 12 ++++++++++++ src/shared/quickjs/quickjs.h | 3 ++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/changelogs/changes-2.1.1.md b/changelogs/changes-2.1.1.md index 760149718..d0cdaad4f 100644 --- a/changelogs/changes-2.1.1.md +++ b/changelogs/changes-2.1.1.md @@ -1,6 +1,7 @@ # General * Fixed Probe lookup in multiplexed products. * Fixed excessively slow module merging in some circumstances. +* Fixed building QuickJS on x86 systems. # Contributors * Christian Kandeler diff --git a/src/lib/corelib/tools/scripttools.h b/src/lib/corelib/tools/scripttools.h index ea7993485..955c37af5 100644 --- a/src/lib/corelib/tools/scripttools.h +++ b/src/lib/corelib/tools/scripttools.h @@ -201,9 +201,11 @@ QVariant QBS_AUTOTEST_EXPORT getConfigProperty(const QVariantMap &cfg, const QSt } // namespace qbs // Only to be used for objects! +#ifndef JS_NAN_BOXING inline bool operator==(JSValue v1, JSValue v2) { return v1.u.ptr == v2.u.ptr; } inline bool operator!=(JSValue v1, JSValue v2) { return !(v1 == v2); } inline bool operator<(JSValue v1, JSValue v2) { return v1.u.ptr < v2.u.ptr; } inline qbs::QHashValueType qHash(const JSValue &v) { return QT_PREPEND_NAMESPACE(qHash)(v.u.ptr); } +#endif #endif // QBS_SCRIPTTOOLS_H diff --git a/src/shared/quickjs/quickjs.c b/src/shared/quickjs/quickjs.c index 9b5ea51a0..3665eea5e 100644 --- a/src/shared/quickjs/quickjs.c +++ b/src/shared/quickjs/quickjs.c @@ -54232,6 +54232,17 @@ JSValue JS_NewCFunctionMagic(JSContext *ctx, JSCFunctionMagic *func, magic); } +#ifdef JS_NAN_BOXING +JSValue mkVal(int32_t tag, int32_t val) +{ + return ((uint64_t)(tag) << 32) | (uint32_t)(val); +} + +JSValue mkPtr(int32_t tag, void *p) +{ + return ((uint64_t)(tag) << 32) | (uintptr_t)(p); +} +#else JSValue mkVal(int32_t tag, int32_t val) { return (JSValue){ (JSValueUnion){ .int32 = val }, tag }; @@ -54241,6 +54252,7 @@ JSValue mkPtr(int32_t tag, void *p) { return (JSValue){ (JSValueUnion){ .ptr = p }, tag }; } +#endif void JS_FreeValue(JSContext *ctx, JSValue v) { if (JS_VALUE_HAS_REF_COUNT(v)) { diff --git a/src/shared/quickjs/quickjs.h b/src/shared/quickjs/quickjs.h index fbea4af3d..f2caef137 100644 --- a/src/shared/quickjs/quickjs.h +++ b/src/shared/quickjs/quickjs.h @@ -156,8 +156,9 @@ static inline double JS_VALUE_GET_FLOAT64(JSValue v) #define JS_NAN (0x7ff8000000000000 - ((uint64_t)JS_FLOAT64_TAG_ADDEND << 32)) -static inline JSValue __JS_NewFloat64(JSContext *ctx, double d) +static inline JSValue JS_NewFloat64Impl(JSContext *ctx, double d) { + (void) ctx; union { double d; uint64_t u64; -- cgit v1.2.3