diff --git a/src/drivers/device/ringbuffer.cpp b/src/drivers/device/ringbuffer.cpp index e77402b0d1..0da2467fd6 100644 --- a/src/drivers/device/ringbuffer.cpp +++ b/src/drivers/device/ringbuffer.cpp @@ -235,7 +235,20 @@ RingBuffer::force(double val) } // FIXME - clang crashes on this get() call -#ifndef __PX4_QURT +#ifdef __PX4_QURT +#define __PX4_SBCAP my_sync_bool_compare_and_swap +static bool my_sync_bool_compare_and_swap(volatile unsigned *a, unsigned b, unsigned c) +{ + if (*a == b) { + *a = c; + return true; + } + return false; +} + +#else +#define __PX4_SBCAP __sync_bool_compare_and_swap +#endif bool RingBuffer::get(void *val, size_t val_size) { @@ -258,14 +271,13 @@ RingBuffer::get(void *val, size_t val_size) memcpy(val, &_buf[candidate * _item_size], val_size); /* if the tail pointer didn't change, we got our item */ - } while (!__sync_bool_compare_and_swap(&_tail, candidate, next)); + } while (!__PX4_SBCAP(&_tail, candidate, next)); return true; } else { return false; } } -#endif bool RingBuffer::get(int8_t &val)