diff options
Diffstat (limited to 'integration/bunjs-only-snippets/ffi.test.fixture.callback.c')
-rw-r--r-- | integration/bunjs-only-snippets/ffi.test.fixture.callback.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/integration/bunjs-only-snippets/ffi.test.fixture.callback.c b/integration/bunjs-only-snippets/ffi.test.fixture.callback.c index a428926ef..a0da35f62 100644 --- a/integration/bunjs-only-snippets/ffi.test.fixture.callback.c +++ b/integration/bunjs-only-snippets/ffi.test.fixture.callback.c @@ -100,6 +100,7 @@ typedef union EncodedJSValue { #endif void* asPtr; + double asDouble; } EncodedJSValue; EncodedJSValue ValueUndefined = { TagValueUndefined }; @@ -116,6 +117,7 @@ JSContext cachedJSContext; void* cachedCallbackFunction; #endif + static EncodedJSValue INT32_TO_JSVALUE(int32_t val) __attribute__((__always_inline__)); static EncodedJSValue DOUBLE_TO_JSVALUE(double val) __attribute__((__always_inline__)); static EncodedJSValue FLOAT_TO_JSVALUE(float val) __attribute__((__always_inline__)); @@ -149,19 +151,16 @@ static EncodedJSValue INT32_TO_JSVALUE(int32_t val) { return res; } + static EncodedJSValue DOUBLE_TO_JSVALUE(double val) { - EncodedJSValue res; -#ifdef USES_FLOAT - res.asInt64 = trunc(val) == val ? val : val - DoubleEncodeOffset; -#else -// should never get here - res.asInt64 = 0xa; -#endif + EncodedJSValue res; + res.asDouble = val; + res.asInt64 += DoubleEncodeOffset; return res; } static EncodedJSValue FLOAT_TO_JSVALUE(float val) { - return DOUBLE_TO_JSVALUE(val); + return DOUBLE_TO_JSVALUE((double)val); } static EncodedJSValue BOOLEAN_TO_JSVALUE(bool val) { @@ -172,7 +171,8 @@ static EncodedJSValue BOOLEAN_TO_JSVALUE(bool val) { static double JSVALUE_TO_DOUBLE(EncodedJSValue val) { - return val.asInt64 + DoubleEncodeOffset; + val.asInt64 -= DoubleEncodeOffset; + return val.asDouble; } static float JSVALUE_TO_FLOAT(EncodedJSValue val) { |