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:
Mark Charlebois 2015-04-27 16:51:33 -07:00
parent 58595e2e78
commit 6ab25ae890
1 changed files with 15 additions and 3 deletions

View File

@ -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)