summaryrefslogtreecommitdiff
path: root/include/al
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2024-10-05 19:04:10 -0400
committerAndrew Opalach <andrew@akon.city> 2024-10-05 19:04:10 -0400
commitc682feffb0a6cde943687587721f2603b3846ceb (patch)
tree5a99ca31862619502a218e772e4d8ad1eae2db01 /include/al
parent2e136aa341fead57ee60ad8f1718cb9584baa03b (diff)
downloadlibalabaster-c682feffb0a6cde943687587721f2603b3846ceb.tar.gz
libalabaster-c682feffb0a6cde943687587721f2603b3846ceb.tar.bz2
libalabaster-c682feffb0a6cde943687587721f2603b3846ceb.zip
atomic: Rely on wrapping for al_inc_u16()
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'include/al')
-rw-r--r--include/al/random.h8
1 files changed, 2 insertions, 6 deletions
diff --git a/include/al/random.h b/include/al/random.h
index 9d27c18..31da3f3 100644
--- a/include/al/random.h
+++ b/include/al/random.h
@@ -19,16 +19,12 @@ static s32 al_rand(void)
}
// Each file that includes this header will have a separate counter.
-static atomic(u16) _al_inc_value = 1;
+static atomic(u16) _al_inc_value = 0;
// This is apart of random because currently al_inc_u16() is used as a substitute
-// for proper random ID generation.
+// for proper random id generation.
static u16 al_inc_u16(void)
{
- if (al_atomic_load(u16)(&_al_inc_value, AL_ATOMIC_ACQUIRE) == UINT16_MAX) {
- al_atomic_store(u16)(&_al_inc_value, 1, AL_ATOMIC_RELEASE);
- return 1;
- }
return al_atomic_add(u16)(&_al_inc_value, 1, AL_ATOMIC_RELEASE);
}