aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/arch/x86
diff options
context:
space:
mode:
authorPetri Savolainen <petri.savolainen@nokia.com>2023-06-28 10:48:24 +0300
committerPetri Savolainen <petri.savolainen@nokia.com>2023-07-12 11:02:07 +0300
commitf42d23801f34dc0ca0aa0463bb92bf4fdc310d8e (patch)
tree9f85b9da8bd74a4b19b09670a2c326f8938227b0 /platform/linux-generic/arch/x86
parent6cf41639a8400b32999626b029e522a0ddcde16f (diff)
linux-gen: sync: implement new memory barriers
Implement the new load and store synchronization barriers with x86 and aarch64 instructions. The default implementation falls back to the strongest GCC built-in (__sync_synchronize()), which would be the strong enough on x86 (mfence), but too weak on aarch64 (dmb). Signed-off-by: Petri Savolainen <petri.savolainen@nokia.com> Reviewed-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Jere Leppänen <jere.leppanen@nokia.com>
Diffstat (limited to 'platform/linux-generic/arch/x86')
-rw-r--r--platform/linux-generic/arch/x86/odp/api/abi/sync_inlines.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/platform/linux-generic/arch/x86/odp/api/abi/sync_inlines.h b/platform/linux-generic/arch/x86/odp/api/abi/sync_inlines.h
new file mode 100644
index 000000000..bebe6b571
--- /dev/null
+++ b/platform/linux-generic/arch/x86/odp/api/abi/sync_inlines.h
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Nokia
+ */
+
+#ifndef ODP_ARCH_SYNC_INLINES_H_
+#define ODP_ARCH_SYNC_INLINES_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline void _odp_mb_sync(void)
+{
+ __asm__ volatile("mfence" ::: "memory");
+}
+
+static inline void _odp_mb_sync_load(void)
+{
+ __asm__ volatile("lfence" ::: "memory");
+}
+
+static inline void _odp_mb_sync_store(void)
+{
+ __asm__ volatile("sfence" ::: "memory");
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif