Implemented pause as an inline function in a cpu arch dependent
header file.

Signed-off-by: Petri Savolainen <[email protected]>
---
 helper/Makefile.am                                |  2 ++
 platform/linux-generic/Makefile.am                |  4 +++-
 platform/linux-generic/Makefile.inc               |  1 +
 platform/linux-generic/arch/linux/odp/cpu_arch.h  | 22 ++++++++++++++++++
 platform/linux-generic/arch/mips64/odp/cpu_arch.h | 26 ++++++++++++++++++++++
 platform/linux-generic/arch/x86/odp/cpu_arch.h    | 27 +++++++++++++++++++++++
 platform/linux-generic/include/odp/cpu.h          |  2 ++
 7 files changed, 83 insertions(+), 1 deletion(-)
 create mode 100644 platform/linux-generic/arch/linux/odp/cpu_arch.h
 create mode 100644 platform/linux-generic/arch/mips64/odp/cpu_arch.h
 create mode 100644 platform/linux-generic/arch/x86/odp/cpu_arch.h

diff --git a/helper/Makefile.am b/helper/Makefile.am
index 1906ae2..876e541 100644
--- a/helper/Makefile.am
+++ b/helper/Makefile.am
@@ -1,3 +1,5 @@
+include $(top_srcdir)/platform/@with_platform@/Makefile.inc
+
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = $(top_builddir)/pkgconfig/libodphelper.pc
 
diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index 56c244e..ffb4c45 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -2,6 +2,7 @@
 #export CUSTOM_STR=https://git.linaro.org/lng/odp.git
 
 include $(top_srcdir)/platform/Makefile.inc
+include $(top_srcdir)/platform/@with_platform@/Makefile.inc
 
 AM_CFLAGS +=  -I$(srcdir)/include
 AM_CFLAGS +=  -I$(top_srcdir)/include
@@ -52,7 +53,8 @@ odpinclude_HEADERS = \
                  $(srcdir)/include/odp/time.h \
                  $(srcdir)/include/odp/timer.h \
                  $(srcdir)/include/odp/traffic_mngr.h \
-                 $(srcdir)/include/odp/version.h
+                 $(srcdir)/include/odp/version.h \
+                 $(srcdir)/arch/@ARCH@/odp/cpu_arch.h
 
 odpplatincludedir= $(includedir)/odp/plat
 odpplatinclude_HEADERS = \
diff --git a/platform/linux-generic/Makefile.inc 
b/platform/linux-generic/Makefile.inc
index e69de29..19e206b 100644
--- a/platform/linux-generic/Makefile.inc
+++ b/platform/linux-generic/Makefile.inc
@@ -0,0 +1 @@
+AM_CFLAGS += -I$(top_srcdir)/platform/$(with_platform)/arch/$(ARCH)
diff --git a/platform/linux-generic/arch/linux/odp/cpu_arch.h 
b/platform/linux-generic/arch/linux/odp/cpu_arch.h
new file mode 100644
index 0000000..1c79f87
--- /dev/null
+++ b/platform/linux-generic/arch/linux/odp/cpu_arch.h
@@ -0,0 +1,22 @@
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#ifndef ODP_PLAT_CPU_ARCH_H_
+#define ODP_PLAT_CPU_ARCH_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline void odp_cpu_pause(void)
+{
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/platform/linux-generic/arch/mips64/odp/cpu_arch.h 
b/platform/linux-generic/arch/mips64/odp/cpu_arch.h
new file mode 100644
index 0000000..3bfa0dc
--- /dev/null
+++ b/platform/linux-generic/arch/mips64/odp/cpu_arch.h
@@ -0,0 +1,26 @@
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#ifndef ODP_PLAT_CPU_ARCH_H_
+#define ODP_PLAT_CPU_ARCH_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline void odp_cpu_pause(void)
+{
+       __asm__ __volatile__ ("nop");
+       __asm__ __volatile__ ("nop");
+       __asm__ __volatile__ ("nop");
+       __asm__ __volatile__ ("nop");
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/platform/linux-generic/arch/x86/odp/cpu_arch.h 
b/platform/linux-generic/arch/x86/odp/cpu_arch.h
new file mode 100644
index 0000000..997a954
--- /dev/null
+++ b/platform/linux-generic/arch/x86/odp/cpu_arch.h
@@ -0,0 +1,27 @@
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#ifndef ODP_PLAT_CPU_ARCH_H_
+#define ODP_PLAT_CPU_ARCH_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline void odp_cpu_pause(void)
+{
+#ifdef __SSE2__
+       __asm__ __volatile__ ("pause");
+#else
+       __asm__ __volatile__ ("rep; nop");
+#endif
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/platform/linux-generic/include/odp/cpu.h 
b/platform/linux-generic/include/odp/cpu.h
index b5b5320..b98507d 100644
--- a/platform/linux-generic/include/odp/cpu.h
+++ b/platform/linux-generic/include/odp/cpu.h
@@ -17,6 +17,8 @@
 extern "C" {
 #endif
 
+#include <odp/cpu_arch.h>
+
 #include <odp/api/cpu.h>
 
 #ifdef __cplusplus
-- 
2.6.3

_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to