Skip to content
Snippets Groups Projects
Commit 0a978f51 authored by Julian Oes's avatar Julian Oes Committed by Daniel Agar
Browse files

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.
parent e6621bf7
No related branches found
No related tags found
No related merge requests found
......@@ -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>;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment