]> Git Repo - qemu.git/commitdiff
include/processor.h: define cpu_relax()
authorEmilio G. Cota <[email protected]>
Wed, 8 Jun 2016 18:55:22 +0000 (14:55 -0400)
committerRichard Henderson <[email protected]>
Sat, 11 Jun 2016 23:10:17 +0000 (23:10 +0000)
Taken from the linux kernel.

Reviewed-by: Sergey Fedorov <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Alex BennĂ©e <[email protected]>
Signed-off-by: Emilio G. Cota <[email protected]>
Message-Id: <1465412133[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
include/qemu/processor.h [new file with mode: 0644]

diff --git a/include/qemu/processor.h b/include/qemu/processor.h
new file mode 100644 (file)
index 0000000..8b25702
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2016, Emilio G. Cota <[email protected]>
+ *
+ * License: GNU GPL, version 2.
+ *   See the COPYING file in the top-level directory.
+ */
+#ifndef QEMU_PROCESSOR_H
+#define QEMU_PROCESSOR_H
+
+#include "qemu/atomic.h"
+
+#if defined(__i386__) || defined(__x86_64__)
+# define cpu_relax() asm volatile("rep; nop" ::: "memory")
+
+#elif defined(__ia64__)
+# define cpu_relax() asm volatile("hint @pause" ::: "memory")
+
+#elif defined(__aarch64__)
+# define cpu_relax() asm volatile("yield" ::: "memory")
+
+#elif defined(__powerpc64__)
+/* set Hardware Multi-Threading (HMT) priority to low; then back to medium */
+# define cpu_relax() asm volatile("or 1, 1, 1;" \
+                                  "or 2, 2, 2;" ::: "memory")
+
+#else
+# define cpu_relax() barrier()
+#endif
+
+#endif /* QEMU_PROCESSOR_H */
This page took 0.026585 seconds and 4 git commands to generate.