Skip to content

Commit

Permalink
fix scoping
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent committed Nov 25, 2023
1 parent 75fb161 commit 4f7381e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions w2c2/w2c2_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -1222,9 +1222,10 @@ DEFINE_ATOMIC_STORE(i64_atomic_store32, U32, U64)

#define DEFINE_ATOMIC_RMW(name, op, op2, size, t) \
static W2C2_INLINE t name(wasmMemory* mem, U64 addr, t value) { \
U ## size old = 0; \
WASM_MUTEX_LOCK(&mem->mutex); \
{ \
U ## size old = readSwapU ## size(mem->data, addr); \
old = readSwapU ## size(mem->data, addr); \
U ## size wrapped = (U ## size)value; \
U ## size new = old op2 wrapped; \
writeSwapU ## size(mem->data, addr, new); \
Expand Down Expand Up @@ -1286,9 +1287,10 @@ DEFINE_ATOMIC_RMW(i64_atomic_rmw_xor, xor, ^, 64, U64)

#define DEFINE_ATOMIC_RMW_XCHG(name, size, t) \
static W2C2_INLINE t name(wasmMemory* mem, U64 addr, t value) { \
U ## size old = 0; \
WASM_MUTEX_LOCK(&mem->mutex); \
{ \
U ## size old = readSwapU ## size(mem->data, addr); \
old = readSwapU ## size(mem->data, addr); \
U ## size wrapped = (U ## size)value; \
writeSwapU ## size(mem->data, addr, wrapped); \
} \
Expand Down Expand Up @@ -1326,11 +1328,12 @@ DEFINE_ATOMIC_RMW_XCHG(i64_atomic_rmw_xchg, 64, U64)

#define DEFINE_ATOMIC_RMW_CMPXCHG(name, size, t) \
static W2C2_INLINE t name(wasmMemory* mem, U64 addr, t expected, t replacement) { \
U ## size old = 0;
WASM_MUTEX_LOCK(&mem->mutex); \
{ \
U ## size expected_wrapped = (U ## size)expected; \
U ## size replacement_wrapped = (U ## size)replacement; \
U ## size old = readSwapU ## size(mem->data, addr); \
old = readSwapU ## size(mem->data, addr); \
if (old == expected_wrapped) { \
writeSwapU ## size(mem->data, addr, replacement_wrapped); \
} \
Expand Down

0 comments on commit 4f7381e

Please sign in to comment.