Fix compile on older versions of GCC and CLANG (#427)
Older versions of GCC (<4.9) and LLVM (<3.6) do not have __atomic_load_n which is part of the C11 standard. Fix by falling back to __sync_fetch_and_add with a value of 0 when __atomic_load_n is not available. Fixes #423 Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
parent
5e04daf483
commit
123dcfaec5
1 changed files with 4 additions and 0 deletions
|
|
@ -22,7 +22,11 @@ static inline uint32_t atomic_dec(volatile uint32_t *p) {
|
|||
#else
|
||||
|
||||
static inline size_t atomic_load(const volatile size_t *p) {
|
||||
#ifdef __ATOMIC_RELAXED
|
||||
return __atomic_load_n(p, __ATOMIC_RELAXED);
|
||||
#else
|
||||
return __sync_fetch_and_add((volatile size_t *)p, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint32_t atomic_inc(volatile uint32_t *p) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue