Skip to content

Commit

Permalink
mem.c: add fallback implementations for stdatomic functions
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed Aug 11, 2024
1 parent fc7ce01 commit 1cc6d38
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@

#include "mem.h"

#if defined(__STDC_NO_ATOMICS__)
static size_t
atomic_fetch_sub(size_t *p, size_t diff)
{
size_t ov = *p;
*p -= diff;
return ov;
}

static bool
atomic_compare_exchange_weak(size_t *p, size_t *ov, size_t nv)
{
assert(*p == *ov);
*p = nv;
return true;
}
#endif

#if defined(TOYWASM_ENABLE_HEAP_TRACKING)
static void
mem_unreserve_one(struct mem_context *ctx, size_t diff)
Expand Down

0 comments on commit 1cc6d38

Please sign in to comment.