summaryrefslogtreecommitdiff
path: root/sys/include
diff options
context:
space:
mode:
authorsigsegv7 <ian@vegaa.systems>2023-09-28 15:36:22 -0400
committersigsegv7 <ian@vegaa.systems>2023-09-28 15:36:22 -0400
commit215efd60900f28bb543ffab400306fbd01a4f76c (patch)
treee0852a5e27249d91b1817dd256445f5a085ed295 /sys/include
parent6acd23f6e758bddc2b204baeafc7885e837f002d (diff)
kernel: cdefs: Add memory barrier helper
Signed-off-by: sigsegv7 <ian@vegaa.systems>
Diffstat (limited to 'sys/include')
-rw-r--r--sys/include/sys/cdefs.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/include/sys/cdefs.h b/sys/include/sys/cdefs.h
index 56d1f87..bec4431 100644
--- a/sys/include/sys/cdefs.h
+++ b/sys/include/sys/cdefs.h
@@ -38,6 +38,9 @@
#define __used __attr(used)
#define __naked __attr(naked)
+/* Wrapper for inline asm */
+#define __ASMV __asm__ __volatile__
+
/* Pack a structure */
#define __packed __attribute__((__packed__))
@@ -54,6 +57,12 @@
#define __cacheline_aligned __aligned(64)
/*
+ * Memory barrier, ensure compiler doesn't reorder
+ * memory accesses.
+ */
+#define __mem_barrier() __ASMV("" ::: "memory")
+
+/*
* To be used when an empty body is required like:
*
* #ifdef DEBUG
@@ -106,9 +115,6 @@
/* Computes 2^x i.e 2 to the power of 'x' */
#define __POW2(x) (1ULL << x)
-/* Wrapper for inline asm */
-#define __ASMV __asm__ __volatile__
-
/*
* Used to give metadata to
* a specific module. Example