forked from Archive/PX4-Autopilot
QuRT: workaround for __sync_bool_compare_and_swap
The Hexagon compiler version does not support __sync_bool_compare_and_swap. Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
parent
58595e2e78
commit
6ab25ae890
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue