summaryrefslogtreecommitdiffstats
path: root/sys/sys/cdefs.h
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2012-10-09 14:32:30 +0000
committerattilio <attilio@FreeBSD.org>2012-10-09 14:32:30 +0000
commit6997194551ffae05d71ea650af49c4551d753a1a (patch)
tree18e9f31a3018a88b46e78d76a45d0953dea5276b /sys/sys/cdefs.h
parent6a02d06d1d81ffda0499310925ef854fd237f382 (diff)
downloadFreeBSD-src-6997194551ffae05d71ea650af49c4551d753a1a.zip
FreeBSD-src-6997194551ffae05d71ea650af49c4551d753a1a.tar.gz
Add an unified macro to deny ability from the compiler to reorder
instruction loads/stores at its will. The macro __compiler_membar() is currently supported for both gcc and clang, but kernel compilation will fail otherwise. Reviewed by: bde, kib Discussed with: dim, theraven MFC after: 2 weeks
Diffstat (limited to 'sys/sys/cdefs.h')
-rw-r--r--sys/sys/cdefs.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
index d4c78a9..ad6aefc 100644
--- a/sys/sys/cdefs.h
+++ b/sys/sys/cdefs.h
@@ -82,6 +82,13 @@
# define __GNUC_VA_LIST_COMPATIBILITY 1
#endif
+/*
+ * Compiler memory barriers, specific to gcc and clang.
+ */
+#if defined(__GNUC__)
+#define __compiler_membar() __asm __volatile(" " : : : "memory")
+#endif
+
#ifndef __INTEL_COMPILER
# define __GNUCLIKE_BUILTIN_NEXT_ARG 1
# define __GNUCLIKE_MATH_BUILTIN_RELOPS
OpenPOWER on IntegriCloud