diff options
author | Soni L <EnderMoneyMod@gmail.com> | 2024-01-31 23:54:46 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-31 18:54:46 -0800 |
commit | 38860a9fa7c4d247f73a1e0b161adb0b700731bf (patch) | |
tree | ccfadd5a63c8e1c8acb20983251e8e3900f445fd /src/prebuilt/wasm2c_atomicops_source_declarations.cc | |
parent | 49950cbcb8e3729cd056f1f76ee4000dbcbe309f (diff) | |
download | wabt-38860a9fa7c4d247f73a1e0b161adb0b700731bf.tar.gz wabt-38860a9fa7c4d247f73a1e0b161adb0b700731bf.tar.bz2 wabt-38860a9fa7c4d247f73a1e0b161adb0b700731bf.zip |
Remove unnecessary restriction (#2378)
Thanks to MEM_ADDR we don't need to think about big-endian vs
little-endian for any scalar(!) operations.
Diffstat (limited to 'src/prebuilt/wasm2c_atomicops_source_declarations.cc')
-rw-r--r-- | src/prebuilt/wasm2c_atomicops_source_declarations.cc | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/src/prebuilt/wasm2c_atomicops_source_declarations.cc b/src/prebuilt/wasm2c_atomicops_source_declarations.cc index 68b687f3..8312d5d6 100644 --- a/src/prebuilt/wasm2c_atomicops_source_declarations.cc +++ b/src/prebuilt/wasm2c_atomicops_source_declarations.cc @@ -1,13 +1,6 @@ const char* s_atomicops_source_declarations = R"w2c_template(#include <stdatomic.h> )w2c_template" R"w2c_template( -#if WABT_BIG_ENDIAN -)w2c_template" -R"w2c_template(#error "wasm2c atomics not supported on big endian" -)w2c_template" -R"w2c_template(#endif -)w2c_template" -R"w2c_template( #ifndef WASM_RT_C11_AVAILABLE )w2c_template" R"w2c_template(#error "C11 is required for Wasm threads and shared memory support" @@ -324,39 +317,41 @@ R"w2c_template(DEFINE_ATOMIC_RMW(i64_atomic_rmw32_xor_u, fetch_xor, ^, u32, u64) R"w2c_template(DEFINE_ATOMIC_RMW(i64_atomic_rmw_xor, fetch_xor, ^, u64, u64) )w2c_template" R"w2c_template( -#define DEFINE_ATOMIC_XCHG(name, opname, t1, t2) \ +#define DEFINE_ATOMIC_XCHG(name, opname, t1, t2) \ +)w2c_template" +R"w2c_template( static inline t2 name(wasm_rt_memory_t* mem, u64 addr, t2 value) { \ )w2c_template" -R"w2c_template( static inline t2 name(wasm_rt_memory_t* mem, u64 addr, t2 value) { \ +R"w2c_template( MEMCHECK(mem, addr, t1); \ )w2c_template" -R"w2c_template( MEMCHECK(mem, addr, t1); \ +R"w2c_template( ATOMIC_ALIGNMENT_CHECK(addr, t1); \ )w2c_template" -R"w2c_template( ATOMIC_ALIGNMENT_CHECK(addr, t1); \ +R"w2c_template( t1 wrapped = (t1)value; \ )w2c_template" -R"w2c_template( t1 wrapped = (t1)value; \ +R"w2c_template( t1 ret; \ )w2c_template" -R"w2c_template( t1 ret; \ +R"w2c_template( wasm_rt_memcpy(&ret, MEM_ADDR(mem, addr, sizeof(t1)), sizeof(t1)); \ )w2c_template" -R"w2c_template( wasm_rt_memcpy(&ret, &mem->data[addr], sizeof(t1)); \ +R"w2c_template( wasm_rt_memcpy(MEM_ADDR(mem, addr, sizeof(t1)), &wrapped, sizeof(t1)); \ )w2c_template" -R"w2c_template( wasm_rt_memcpy(&mem->data[addr], &wrapped, sizeof(t1)); \ +R"w2c_template( return (t2)ret; \ )w2c_template" -R"w2c_template( return (t2)ret; \ +R"w2c_template( } \ )w2c_template" -R"w2c_template( } \ +R"w2c_template( static inline t2 name##_shared(wasm_rt_shared_memory_t* mem, u64 addr, \ )w2c_template" -R"w2c_template( static inline t2 name##_shared(wasm_rt_shared_memory_t* mem, u64 addr, \ +R"w2c_template( t2 value) { \ )w2c_template" -R"w2c_template( t2 value) { \ +R"w2c_template( MEMCHECK(mem, addr, t1); \ )w2c_template" -R"w2c_template( MEMCHECK(mem, addr, t1); \ +R"w2c_template( ATOMIC_ALIGNMENT_CHECK(addr, t1); \ )w2c_template" -R"w2c_template( ATOMIC_ALIGNMENT_CHECK(addr, t1); \ +R"w2c_template( t1 wrapped = (t1)value; \ )w2c_template" -R"w2c_template( t1 wrapped = (t1)value; \ +R"w2c_template( t1 ret = atomic_##opname( \ )w2c_template" -R"w2c_template( t1 ret = atomic_##opname((_Atomic volatile t1*)&mem->data[addr], wrapped); \ +R"w2c_template( (_Atomic volatile t1*)MEM_ADDR(mem, addr, sizeof(t1)), wrapped); \ )w2c_template" -R"w2c_template( return (t2)ret; \ +R"w2c_template( return (t2)ret; \ )w2c_template" R"w2c_template( } )w2c_template" |