aboutsummaryrefslogtreecommitdiff
path: root/winsup/testsuite/winsup.api/pthread/cpu_relax.h
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/testsuite/winsup.api/pthread/cpu_relax.h')
-rw-r--r--winsup/testsuite/winsup.api/pthread/cpu_relax.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/winsup/testsuite/winsup.api/pthread/cpu_relax.h b/winsup/testsuite/winsup.api/pthread/cpu_relax.h
new file mode 100644
index 0000000..c31ef8c
--- /dev/null
+++ b/winsup/testsuite/winsup.api/pthread/cpu_relax.h
@@ -0,0 +1,13 @@
+#ifndef CPU_RELAX_H
+#define CPU_RELAX_H
+
+#if defined(__x86_64__) || defined(__i386__) // Check for x86 architectures
+ #define CPU_RELAX() __asm__ volatile ("pause" :::)
+#elif defined(__aarch64__) || defined(__arm__) // Check for ARM architectures
+ #define CPU_RELAX() __asm__ volatile ("dmb ishst\n" \
+ "yield" :::)
+#else
+ #error unimplemented for this target
+#endif
+
+#endif