diff options
author | Petri Savolainen <petri.savolainen@linaro.org> | 2018-05-24 16:54:46 +0300 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2018-05-28 18:08:02 +0300 |
commit | f4f4dcee96e534c0badc28258ad09ef50b35ec76 (patch) | |
tree | e675eac2558f12b6b6dd2fba914030c6ea4849ae /platform/linux-generic/arch/x86/odp | |
parent | d6e4b3df266ee1c847763ba50fa802d9e9e62b5e (diff) |
linux-gen: cpu: inline cpu cycle functions on x86
Moved cpu cycle and pause functions into
arch/x86/odp_arch_cpu_inlines.h.
Uncommented pause function in spec file and removed it
from ABI file. It's safer for ABI compat mode to not have
code included into ABI spec files.
Other architectures use the default odp_arch_cpu_inlines.h,
which does not change the current implementation.
Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'platform/linux-generic/arch/x86/odp')
-rw-r--r-- | platform/linux-generic/arch/x86/odp/api/abi/cpu.h | 10 | ||||
-rw-r--r-- | platform/linux-generic/arch/x86/odp/api/abi/cpu_inlines.h | 48 |
2 files changed, 50 insertions, 8 deletions
diff --git a/platform/linux-generic/arch/x86/odp/api/abi/cpu.h b/platform/linux-generic/arch/x86/odp/api/abi/cpu.h index 523fa99e5..9224af9a0 100644 --- a/platform/linux-generic/arch/x86/odp/api/abi/cpu.h +++ b/platform/linux-generic/arch/x86/odp/api/abi/cpu.h @@ -13,14 +13,8 @@ extern "C" { #define ODP_CACHE_LINE_SIZE 64 -static inline void odp_cpu_pause(void) -{ -#ifdef __SSE2__ - __asm__ __volatile__ ("pause"); -#else - __asm__ __volatile__ ("rep; nop"); -#endif -} +/* Inlined functions for non-ABI compat mode */ +#include <odp/api/plat/cpu_inlines.h> #ifdef __cplusplus } diff --git a/platform/linux-generic/arch/x86/odp/api/abi/cpu_inlines.h b/platform/linux-generic/arch/x86/odp/api/abi/cpu_inlines.h new file mode 100644 index 000000000..63be3da65 --- /dev/null +++ b/platform/linux-generic/arch/x86/odp/api/abi/cpu_inlines.h @@ -0,0 +1,48 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_ARCH_CPU_INLINES_H_ +#define ODP_ARCH_CPU_INLINES_H_ + +#include <stdint.h> + +_ODP_INLINE void odp_cpu_pause(void) +{ +#ifdef __SSE2__ + __asm__ __volatile__ ("pause"); +#else + __asm__ __volatile__ ("rep; nop"); +#endif +} + +_ODP_INLINE uint64_t odp_cpu_cycles(void) +{ + union { + uint64_t tsc_64; + struct { + uint32_t lo_32; + uint32_t hi_32; + }; + } tsc; + + __asm__ __volatile__ ("rdtsc" : + "=a" (tsc.lo_32), + "=d" (tsc.hi_32) : : "memory"); + + return tsc.tsc_64; +} + +_ODP_INLINE uint64_t odp_cpu_cycles_max(void) +{ + return UINT64_MAX; +} + +_ODP_INLINE uint64_t odp_cpu_cycles_resolution(void) +{ + return 1; +} + +#endif |