Skip to content

Commit

Permalink
atomics: Introduce atomic_load_relaxed(), atomic_store_relaxed()
Browse files Browse the repository at this point in the history
- Use as shorthand to atomic_load_*_ex(addr, ATOMIC_RELAXED)
  • Loading branch information
LekKit committed Jan 12, 2025
1 parent 8063d08 commit 284b58a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/atomics.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,16 @@ static forceinline uint32_t atomic_or_uint32_ex(void* addr, uint32_t val, int me
#endif
}

static forceinline uint32_t atomic_load_uint32_relax(const void* addr)
{
return atomic_load_uint32_ex(addr, ATOMIC_RELAXED);
}

static forceinline void atomic_store_uint32_relax(void* addr, uint32_t val)
{
atomic_store_uint32_ex(addr, val, ATOMIC_RELAXED);
}

static forceinline uint32_t atomic_load_uint32(const void* addr)
{
return atomic_load_uint32_ex(addr, ATOMIC_ACQUIRE);
Expand Down Expand Up @@ -622,6 +632,16 @@ static forceinline uint64_t atomic_or_uint64_ex(void* addr, uint64_t val, int me
#endif
}

static forceinline uint64_t atomic_load_uint64_relax(const void* addr)
{
return atomic_load_uint64_ex(addr, ATOMIC_RELAXED);
}

static forceinline void atomic_store_uint64_relax(void* addr, uint64_t val)
{
atomic_store_uint64_ex(addr, val, ATOMIC_RELAXED);
}

static forceinline uint64_t atomic_load_uint64(const void* addr)
{
return atomic_load_uint64_ex(addr, ATOMIC_ACQUIRE);
Expand Down

0 comments on commit 284b58a

Please sign in to comment.