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 --- common/atomic.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'common') diff --git a/common/atomic.h b/common/atomic.h index 874d510d..2033476b 100644 --- a/common/atomic.h +++ b/common/atomic.h @@ -4,6 +4,19 @@ #include "static_assert.h" #include "bool.h" +#ifdef __GNUC__ +/* This helps cast away the const-ness of a pointer without accidentally + * changing the pointer type. This is necessary due to Clang's inability to use + * atomic_load on a const _Atomic variable. + */ +#define CONST_CAST(T, V) __extension__({ \ + const T _tmp = (V); \ + (T)_tmp; \ +}) +#else +#define CONST_CAST(T, V) ((T)(V)) +#endif + #ifdef __cplusplus extern "C" { #endif -- cgit v1.2.3