diff mbox series

[v1,3/3] linux-gen: arch: single cpu cycles file

Message ID 1513861209-18790-4-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [v1,1/3] linux-gen: arch: remove unused powerpc files | expand

Commit Message

Github ODP bot Dec. 21, 2017, 1 p.m. UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


CPU cycle functions were mixed over odp_cpu_cycles.c and
odp_cpu_arch.c files. Implement all three cpu cycle API
functions in odp_cpu_cycles.c. odp_cpu_arch.c is deleted.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
/** Email created from pull request 358 (psavol:master-arch-dir-cleanup)
 ** https://github.com/Linaro/odp/pull/358
 ** Patch: https://github.com/Linaro/odp/pull/358.patch
 ** Base sha: 6b5cdc77eb9759a2349b10372a964648559bc92c
 ** Merge commit sha: 93353441d4d0b5d0d679401db0daaef8f7f26ee1
 **/
 platform/linux-generic/Makefile.am                 | 15 +++------
 platform/linux-generic/arch/default/odp_cpu_arch.c | 38 ----------------------
 .../linux-generic/arch/default/odp_cpu_cycles.c    | 29 +++++++++++++++++
 .../mips64/{odp_cpu_arch.c => odp_cpu_cycles.c}    | 10 ++++++
 .../arch/x86/{odp_cpu_arch.c => odp_cpu_cycles.c}  | 17 ++++++----
 5 files changed, 54 insertions(+), 55 deletions(-)
 delete mode 100644 platform/linux-generic/arch/default/odp_cpu_arch.c
 rename platform/linux-generic/arch/mips64/{odp_cpu_arch.c => odp_cpu_cycles.c} (79%)
 rename platform/linux-generic/arch/x86/{odp_cpu_arch.c => odp_cpu_cycles.c} (77%)
diff mbox series

Patch

diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index d1b916292..8152ea180 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -224,37 +224,32 @@  __LIB__libodp_linux_la_SOURCES = \
 			   odp_weak.c
 
 if ARCH_IS_ARM
-__LIB__libodp_linux_la_SOURCES += arch/default/odp_cpu_arch.c \
-				  arch/default/odp_cpu_cycles.c \
+__LIB__libodp_linux_la_SOURCES += arch/default/odp_cpu_cycles.c \
 				  arch/default/odp_global_time.c \
 				  arch/default/odp_sysinfo_parse.c
 arch_odp_headers = arch/arm/odp/api/cpu_arch.h
 endif
 if ARCH_IS_AARCH64
-__LIB__libodp_linux_la_SOURCES += arch/default/odp_cpu_arch.c \
-				  arch/default/odp_cpu_cycles.c \
+__LIB__libodp_linux_la_SOURCES += arch/default/odp_cpu_cycles.c \
 				  arch/aarch64/odp_global_time.c \
 				  arch/default/odp_sysinfo_parse.c
 arch_odp_headers = arch/aarch64/odp/api/cpu_arch.h
 endif
 if ARCH_IS_MIPS64
-__LIB__libodp_linux_la_SOURCES += arch/mips64/odp_cpu_arch.c \
-				  arch/default/odp_cpu_cycles.c \
+__LIB__libodp_linux_la_SOURCES += arch/mips64/odp_cpu_cycles.c \
 				  arch/default/odp_global_time.c \
 				  arch/mips64/odp_sysinfo_parse.c
 arch_odp_headers = arch/mips64/odp/api/cpu_arch.h
 endif
 if ARCH_IS_POWERPC
-__LIB__libodp_linux_la_SOURCES += arch/default/odp_cpu_arch.c \
-				  arch/default/odp_cpu_cycles.c \
+__LIB__libodp_linux_la_SOURCES += arch/default/odp_cpu_cycles.c \
 				  arch/default/odp_global_time.c \
 				  arch/powerpc/odp_sysinfo_parse.c
 arch_odp_headers = arch/powerpc/odp/api/cpu_arch.h
 endif
 if ARCH_IS_X86
 __LIB__libodp_linux_la_SOURCES += arch/x86/cpu_flags.c \
-				  arch/x86/odp_cpu_arch.c \
-				  arch/default/odp_cpu_cycles.c \
+				  arch/x86/odp_cpu_cycles.c \
 				  arch/x86/odp_global_time.c \
 				  arch/x86/odp_sysinfo_parse.c
 arch_odp_headers = arch/x86/odp/api/cpu_arch.h
diff --git a/platform/linux-generic/arch/default/odp_cpu_arch.c b/platform/linux-generic/arch/default/odp_cpu_arch.c
deleted file mode 100644
index 8a8da7445..000000000
--- a/platform/linux-generic/arch/default/odp_cpu_arch.c
+++ /dev/null
@@ -1,38 +0,0 @@ 
-/* Copyright (c) 2015, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier:     BSD-3-Clause
- */
-
-#include "config.h"
-
-#include <odp_posix_extensions.h>
-
-#include <stdlib.h>
-#include <time.h>
-
-#include <odp/api/cpu.h>
-#include <odp_debug_internal.h>
-
-#define GIGA 1000000000
-
-uint64_t odp_cpu_cycles(void)
-{
-	struct timespec time;
-	uint64_t sec, ns, hz, cycles;
-	int ret;
-
-	ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time);
-
-	if (ret != 0)
-		ODP_ABORT("clock_gettime failed\n");
-
-	hz  = odp_cpu_hz_max();
-	sec = (uint64_t)time.tv_sec;
-	ns  = (uint64_t)time.tv_nsec;
-
-	cycles  = sec * hz;
-	cycles += (ns * hz) / GIGA;
-
-	return cycles;
-}
diff --git a/platform/linux-generic/arch/default/odp_cpu_cycles.c b/platform/linux-generic/arch/default/odp_cpu_cycles.c
index ccc588825..548aa8172 100644
--- a/platform/linux-generic/arch/default/odp_cpu_cycles.c
+++ b/platform/linux-generic/arch/default/odp_cpu_cycles.c
@@ -6,7 +6,36 @@ 
 
 #include "config.h"
 
+#include <odp_posix_extensions.h>
+
+#include <stdlib.h>
+#include <time.h>
+
 #include <odp/api/cpu.h>
+#include <odp_debug_internal.h>
+
+#define GIGA 1000000000
+
+uint64_t odp_cpu_cycles(void)
+{
+	struct timespec time;
+	uint64_t sec, ns, hz, cycles;
+	int ret;
+
+	ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time);
+
+	if (ret != 0)
+		ODP_ABORT("clock_gettime failed\n");
+
+	hz  = odp_cpu_hz_max();
+	sec = (uint64_t)time.tv_sec;
+	ns  = (uint64_t)time.tv_nsec;
+
+	cycles  = sec * hz;
+	cycles += (ns * hz) / GIGA;
+
+	return cycles;
+}
 
 uint64_t odp_cpu_cycles_max(void)
 {
diff --git a/platform/linux-generic/arch/mips64/odp_cpu_arch.c b/platform/linux-generic/arch/mips64/odp_cpu_cycles.c
similarity index 79%
rename from platform/linux-generic/arch/mips64/odp_cpu_arch.c
rename to platform/linux-generic/arch/mips64/odp_cpu_cycles.c
index 50ffc2e77..85a95f097 100644
--- a/platform/linux-generic/arch/mips64/odp_cpu_arch.c
+++ b/platform/linux-generic/arch/mips64/odp_cpu_cycles.c
@@ -21,3 +21,13 @@  uint64_t odp_cpu_cycles(void)
 
 	return cycle;
 }
+
+uint64_t odp_cpu_cycles_max(void)
+{
+	return UINT64_MAX;
+}
+
+uint64_t odp_cpu_cycles_resolution(void)
+{
+	return 1;
+}
diff --git a/platform/linux-generic/arch/x86/odp_cpu_arch.c b/platform/linux-generic/arch/x86/odp_cpu_cycles.c
similarity index 77%
rename from platform/linux-generic/arch/x86/odp_cpu_arch.c
rename to platform/linux-generic/arch/x86/odp_cpu_cycles.c
index a20d91734..a474ac250 100644
--- a/platform/linux-generic/arch/x86/odp_cpu_arch.c
+++ b/platform/linux-generic/arch/x86/odp_cpu_cycles.c
@@ -4,14 +4,7 @@ 
  * SPDX-License-Identifier:     BSD-3-Clause
  */
 
-#include "config.h"
-
-#include <odp_posix_extensions.h>
-
 #include <odp/api/cpu.h>
-#include <odp_debug_internal.h>
-
-#include <time.h>
 
 uint64_t odp_cpu_cycles(void)
 {
@@ -29,3 +22,13 @@  uint64_t odp_cpu_cycles(void)
 
 	return tsc.tsc_64;
 }
+
+uint64_t odp_cpu_cycles_max(void)
+{
+	return UINT64_MAX;
+}
+
+uint64_t odp_cpu_cycles_resolution(void)
+{
+	return 1;
+}