px4_atomic: use volatile hack for Snappy

It looks like the atomic builtins are not available using QuRT and the
Hexagon toolchain, so our best bet is to use `volatile` for the atomics.
This commit is contained in:
Julian Oes 2019-05-06 15:26:11 +02:00 committed by Daniel Agar
parent e6621bf7fb
commit 0a978f51e6
1 changed files with 14 additions and 0 deletions

View File

@ -80,7 +80,11 @@ public:
*/
inline T load() const
{
#ifdef __PX4_QURT
return _value;
#else
return __atomic_load_n(&_value, __ATOMIC_SEQ_CST);
#endif
}
/**
@ -88,7 +92,11 @@ public:
*/
inline void store(T value)
{
#ifdef __PX4_QURT
_value = value;
#else
__atomic_store(&_value, &value, __ATOMIC_SEQ_CST);
#endif
}
/**
@ -159,7 +167,13 @@ public:
}
private:
#ifdef __PX4_QURT
// It seems that __atomic_store and __atomic_load are not supported on Qurt,
// so the best that we can do is to use volatile.
volatile T _value;
#else
T _value;
#endif
};
using atomic_int = atomic<int>;