summaryrefslogtreecommitdiff
path: root/compiler.h
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2015-02-25 18:18:24 -0500
committerEric S. Raymond <esr@thyrsus.com>2015-02-25 18:18:24 -0500
commit33ed89bab834374e4d6f54d918763adf6212040a (patch)
treefb3cb002b6469d8277843cd0d2e2439e1b495e10 /compiler.h
parent05b3c089bc0ba94281190b453dedbe9adf70d25c (diff)
downloadgpsd-33ed89bab834374e4d6f54d918763adf6212040a.tar.gz
Concurrency protection for ntpmon using memory barrier instructions.
Diffstat (limited to 'compiler.h')
-rw-r--r--compiler.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler.h b/compiler.h
index 9d6f3629..bd73808a 100644
--- a/compiler.h
+++ b/compiler.h
@@ -22,4 +22,22 @@
#define UNUSED
#endif
+/* Needed because 4.x versions of GCC are really annoying */
+#define ignore_return(funcall) \
+ do { \
+ ssize_t locresult = (funcall); \
+ assert(locresult != -23); \
+ } while (0)
+
+static /*@unused@*/ inline void memory_barrier(void)
+{
+#ifndef S_SPLINT_S
+#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
+ __atomic_thread_fence(__ATOMIC_SEQ_CST);
+#elif (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+ __sync_synchronize();
+#endif
+#endif /* S_SPLINT_S */
+}
+
#endif /* _GPSD_COMPILER_H_ */