Skip to content

Commit

Permalink
atomic_add: get old count atomically
Browse files Browse the repository at this point in the history
  • Loading branch information
moonlightsh committed Nov 27, 2023
1 parent ac73451 commit 983932e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/mman.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ s_allocator smalloc_allocator = {malloc, free};
static CSPTR_INLINE size_t atomic_add(volatile size_t *count, const size_t limit, const size_t val) {
size_t old_count, new_count;
do {
old_count = *count;
old_count = __sync_fetch_and_add(count, 0);
if (old_count == limit)
abort();
new_count = old_count + val;
Expand Down

0 comments on commit 983932e

Please sign in to comment.