From e89c183231d26770f4c8ae80a8d05063c34cf0c9 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 11 Jan 2018 10:03:26 -0800 Subject: Avoid including alMain.h in ringbuffer.c --- Alc/ringbuffer.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'Alc/ringbuffer.c') diff --git a/Alc/ringbuffer.c b/Alc/ringbuffer.c index e2ea2ab5..e029e9b6 100644 --- a/Alc/ringbuffer.c +++ b/Alc/ringbuffer.c @@ -24,7 +24,8 @@ #include #include "ringbuffer.h" -#include "alMain.h" +#include "align.h" +#include "atomic.h" #include "threads.h" #include "almalloc.h" #include "compat.h" @@ -49,9 +50,21 @@ struct ll_ringbuffer { ll_ringbuffer_t *ll_ringbuffer_create(size_t sz, size_t elem_sz) { ll_ringbuffer_t *rb; - size_t power_of_two; + size_t power_of_two = 0; - power_of_two = NextPowerOf2((ALuint)sz); + if(sz > 0) + { + power_of_two = sz - 1; + power_of_two |= power_of_two>>1; + power_of_two |= power_of_two>>2; + power_of_two |= power_of_two>>4; + power_of_two |= power_of_two>>8; + power_of_two |= power_of_two>>16; +#if SIZE_MAX > UINT_MAX + power_of_two |= power_of_two>>32; +#endif + } + power_of_two++; if(power_of_two < sz) return NULL; rb = al_malloc(16, sizeof(*rb) + power_of_two*elem_sz); -- cgit v1.2.3