From 0a978f51e6699199309effc2675c1329f214af38 Mon Sep 17 00:00:00 2001
From: Julian Oes <julian@oes.ch>
Date: Mon, 6 May 2019 15:26:11 +0200
Subject: [PATCH] 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.
---
 src/platforms/px4_atomic.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/platforms/px4_atomic.h b/src/platforms/px4_atomic.h
index a5bde13808..be2858ea83 100644
--- a/src/platforms/px4_atomic.h
+++ b/src/platforms/px4_atomic.h
@@ -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>;
-- 
GitLab