summaryrefslogtreecommitdiff
path: root/compiler.h
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2015-02-26 15:04:31 -0500
committerEric S. Raymond <esr@thyrsus.com>2015-02-26 15:04:31 -0500
commit16645be01bf267fe71a8301d0161c3958041d3d0 (patch)
tree4cdbebadb119424cf00d04c34a085f71cf2f89ed /compiler.h
parentbab8757bc9e0b64883c8eeaa9ce5bd1909bbdcd4 (diff)
downloadgpsd-16645be01bf267fe71a8301d0161c3958041d3d0.tar.gz
memory_barrier() now uses a standardized C11 lockless-concurrency primitive.
All regression tests pass.
Diffstat (limited to 'compiler.h')
-rw-r--r--compiler.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler.h b/compiler.h
index bd73808a..f46b05f0 100644
--- a/compiler.h
+++ b/compiler.h
@@ -7,6 +7,8 @@
#ifndef _GPSD_COMPILER_H_
#define _GPSD_COMPILER_H_
+#include "gpsd_config.h" /* is STD_ATOMIC_H defined? */
+
/* Macro for declaring function with printf-like arguments. */
# if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
#define PRINTF_FUNC(format_index, arg_index) \
@@ -32,11 +34,9 @@
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
+#ifdef STD_ATOMIC_H
+ atomic_thread_fence(memory_order_seq_cst);
+#endif /* STD_ATOMIC_H */
#endif /* S_SPLINT_S */
}