From c682feffb0a6cde943687587721f2603b3846ceb Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Sat, 5 Oct 2024 19:04:10 -0400 Subject: atomic: Rely on wrapping for al_inc_u16() Signed-off-by: Andrew Opalach --- include/al/random.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'include/al') 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); } -- cgit v1.2.3-101-g0448