diff options
author | Sam Clegg <sbc@chromium.org> | 2023-09-08 17:07:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-09 00:07:41 +0000 |
commit | 2581e8d55d01f3c431c2d7fcbfd89ce84fe2811f (patch) | |
tree | c3f02806cf265ebadb5d24d68e6e7e72cb79683a /wasm2c | |
parent | 24008ffdca19c4b45081b1f3027319ce6f243986 (diff) | |
download | wabt-2581e8d55d01f3c431c2d7fcbfd89ce84fe2811f.tar.gz wabt-2581e8d55d01f3c431c2d7fcbfd89ce84fe2811f.tar.bz2 wabt-2581e8d55d01f3c431c2d7fcbfd89ce84fe2811f.zip |
[wasm2c] Use wasm_rt_memcpy everywhere in generated code (#2292)
Diffstat (limited to 'wasm2c')
-rw-r--r-- | wasm2c/examples/fac/fac.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/wasm2c/examples/fac/fac.c b/wasm2c/examples/fac/fac.c index 153ab1fb..f6d6d0de 100644 --- a/wasm2c/examples/fac/fac.c +++ b/wasm2c/examples/fac/fac.c @@ -88,7 +88,7 @@ static inline void load_data(void* dest, const void* src, size_t n) { } size_t i = 0; u8* dest_chars = dest; - memcpy(dest, src, n); + wasm_rt_memcpy(dest, src, n); for (i = 0; i < (n >> 1); i++) { u8 cursor = dest_chars[i]; dest_chars[i] = dest_chars[n - i - 1]; @@ -122,7 +122,7 @@ static inline void load_data(void* dest, const void* src, size_t n) { if (!n) { return; } - memcpy(dest, src, n); + wasm_rt_memcpy(dest, src, n); } #define LOAD_DATA(m, o, i, s) \ do { \ @@ -358,11 +358,11 @@ POPCOUNT_DEFINE_PORTABLE(I64_POPCNT, u64) #define I64_TRUNC_SAT_U_F64(x) \ TRUNC_SAT_U(u64, f64, (f64)UINT64_MAX, UINT64_MAX, x) -#define DEFINE_REINTERPRET(name, t1, t2) \ - static inline t2 name(t1 x) { \ - t2 result; \ - memcpy(&result, &x, sizeof(result)); \ - return result; \ +#define DEFINE_REINTERPRET(name, t1, t2) \ + static inline t2 name(t1 x) { \ + t2 result; \ + wasm_rt_memcpy(&result, &x, sizeof(result)); \ + return result; \ } DEFINE_REINTERPRET(f32_reinterpret_i32, u32, f32) @@ -372,17 +372,17 @@ DEFINE_REINTERPRET(i64_reinterpret_f64, f64, u64) static float quiet_nanf(float x) { uint32_t tmp; - memcpy(&tmp, &x, 4); + wasm_rt_memcpy(&tmp, &x, 4); tmp |= 0x7fc00000lu; - memcpy(&x, &tmp, 4); + wasm_rt_memcpy(&x, &tmp, 4); return x; } static double quiet_nan(double x) { uint64_t tmp; - memcpy(&tmp, &x, 8); + wasm_rt_memcpy(&tmp, &x, 8); tmp |= 0x7ff8000000000000llu; - memcpy(&x, &tmp, 8); + wasm_rt_memcpy(&x, &tmp, 8); return x; } @@ -459,9 +459,9 @@ static double wasm_nearbyint(double x) { static float wasm_fabsf(float x) { if (UNLIKELY(isnan(x))) { uint32_t tmp; - memcpy(&tmp, &x, 4); + wasm_rt_memcpy(&tmp, &x, 4); tmp = tmp & ~(1UL << 31); - memcpy(&x, &tmp, 4); + wasm_rt_memcpy(&x, &tmp, 4); return x; } return fabsf(x); @@ -470,9 +470,9 @@ static float wasm_fabsf(float x) { static double wasm_fabs(double x) { if (UNLIKELY(isnan(x))) { uint64_t tmp; - memcpy(&tmp, &x, 8); + wasm_rt_memcpy(&tmp, &x, 8); tmp = tmp & ~(1ULL << 63); - memcpy(&x, &tmp, 8); + wasm_rt_memcpy(&x, &tmp, 8); return x; } return fabs(x); |