summaryrefslogtreecommitdiff
path: root/src/prebuilt/wasm2c.include.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/prebuilt/wasm2c.include.c')
-rw-r--r--src/prebuilt/wasm2c.include.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/prebuilt/wasm2c.include.c b/src/prebuilt/wasm2c.include.c
index bc0bc105..0f1b4b31 100644
--- a/src/prebuilt/wasm2c.include.c
+++ b/src/prebuilt/wasm2c.include.c
@@ -121,25 +121,25 @@ const char SECTION_NAME(declarations)[] =
" : (UNLIKELY((x) == 0 && (y) == 0)) ? (signbit(x) ? y : x) \\\n"
" : (x > y) ? x : y)\n"
"\n"
-"#define TRUNC_S(ut, st, ft, min, max, maxop, x) \\\n"
-" ((UNLIKELY((x) != (x))) ? TRAP(INVALID_CONVERSION) \\\n"
-" : (UNLIKELY((x) < (ft)(min) || (x) maxop (ft)(max))) ? TRAP(INT_OVERFLOW) \\\n"
-" : (ut)(st)(x))\n"
-"\n"
-"#define I32_TRUNC_S_F32(x) TRUNC_S(u32, s32, f32, INT32_MIN, INT32_MAX, >=, x)\n"
-"#define I64_TRUNC_S_F32(x) TRUNC_S(u64, s64, f32, INT64_MIN, INT64_MAX, >=, x)\n"
-"#define I32_TRUNC_S_F64(x) TRUNC_S(u32, s32, f64, INT32_MIN, INT32_MAX, >, x)\n"
-"#define I64_TRUNC_S_F64(x) TRUNC_S(u64, s64, f64, INT64_MIN, INT64_MAX, >=, x)\n"
-"\n"
-"#define TRUNC_U(ut, ft, max, maxop, x) \\\n"
-" ((UNLIKELY((x) != (x))) ? TRAP(INVALID_CONVERSION) \\\n"
-" : (UNLIKELY((x) <= (ft)-1 || (x) maxop (ft)(max))) ? TRAP(INT_OVERFLOW) \\\n"
-" : (ut)(x))\n"
-"\n"
-"#define I32_TRUNC_U_F32(x) TRUNC_U(u32, f32, UINT32_MAX, >=, x)\n"
-"#define I64_TRUNC_U_F32(x) TRUNC_U(u64, f32, UINT64_MAX, >=, x)\n"
-"#define I32_TRUNC_U_F64(x) TRUNC_U(u32, f64, UINT32_MAX, >, x)\n"
-"#define I64_TRUNC_U_F64(x) TRUNC_U(u64, f64, UINT64_MAX, >=, x)\n"
+"#define TRUNC_S(ut, st, ft, min, minop, max, x) \\\n"
+" ((UNLIKELY((x) != (x))) ? TRAP(INVALID_CONVERSION) \\\n"
+" : (UNLIKELY(!((x)minop(min) && (x) < (max)))) ? TRAP(INT_OVERFLOW) \\\n"
+" : (ut)(st)(x))\n"
+"\n"
+"#define I32_TRUNC_S_F32(x) TRUNC_S(u32, s32, f32, (f32)INT32_MIN, >=, 2147483648.f, x)\n"
+"#define I64_TRUNC_S_F32(x) TRUNC_S(u64, s64, f32, (f32)INT64_MIN, >=, (f32)INT64_MAX, x)\n"
+"#define I32_TRUNC_S_F64(x) TRUNC_S(u32, s32, f64, -2147483649., >, 2147483648., x)\n"
+"#define I64_TRUNC_S_F64(x) TRUNC_S(u64, s64, f64, (f64)INT64_MIN, >=, (f64)INT64_MAX, x)\n"
+"\n"
+"#define TRUNC_U(ut, ft, max, x) \\\n"
+" ((UNLIKELY((x) != (x))) ? TRAP(INVALID_CONVERSION) \\\n"
+" : (UNLIKELY(!((x) > (ft)-1 && (x) < (max)))) ? TRAP(INT_OVERFLOW) \\\n"
+" : (ut)(x))\n"
+"\n"
+"#define I32_TRUNC_U_F32(x) TRUNC_U(u32, f32, 4294967296.f, x)\n"
+"#define I64_TRUNC_U_F32(x) TRUNC_U(u64, f32, (f32)UINT64_MAX, x)\n"
+"#define I32_TRUNC_U_F64(x) TRUNC_U(u32, f64, 4294967296., x)\n"
+"#define I64_TRUNC_U_F64(x) TRUNC_U(u64, f64, (f64)UINT64_MAX, x)\n"
"\n"
"#define DEFINE_REINTERPRET(name, t1, t2) \\\n"
" static inline t2 name(t1 x) { \\\n"