ppc64le: fix build without glibc and using Clang
PATCH 1/1 ppc64le: fix build without glibc and using Clang
__ppc_get_timebase() is only present when glibc is used.
--- lib/eal/ppc/include/rte_altivec.h | 3 +++ lib/eal/ppc/include/rte_cycles.h | 12 ++++++++++++ lib/eal/ppc/rte_cycles.c | 16 ++++++++++++++++ 3 files changed, 31 insertions(+)
lib/eal/ppc/include/rte_altivec.h +3 -0
@@ -7,6 +7,9 @@#define _RTE_ALTIVEC_H_/* To include altivec.h, GCC version must be >= 4.8 */ +#ifdef __clang__ +#define vector __vector +#endif #include <altivec.h> /*
lib/eal/ppc/include/rte_cycles.h +12 -0
@@ -10,7 +10,13 @@extern "C" {#endif +#ifdef linux +#include <features.h> +#endif + +#ifdef __GLIBC__#include <sys/platform/ppc.h> +#endif #include "generic/rte_cycles.h"
@@ -26,7 +32,13 @@ extern "C" {static inline uint64_t rte_rdtsc (void ) { +#ifdef __GLIBC__return __ppc_get_timebase (); +#else +uint64_t __tb; + __asm__volatile ("mfspr %0, 268" :"=r" (__tb)); +return __tb; +#endif } static inline uint64_t
lib/eal/ppc/rte_cycles.c +16 -0
@@ -2,12 +2,28 @@* Copyright (C) IBM Corporation 2019. */ +#ifdef linux +#include <features.h> +#elif defined(__FreeBSD__) +#include <sys/types.h> +#include <sys/sysctl.h> +#endif + +#ifdef __GLIBC__#include <sys/platform/ppc.h> +#endif #include "eal_private.h" uint64_t get_tsc_freq_arch (void ) { +#ifdef __GLIBC__return __ppc_get_timebase_freq (); +#elif defined(__FreeBSD__) +uint64_t freq; +size_t length =sizeof (freq); +sysctlbyname ("kern.timecounter.tc.timebase.frequency" , &freq, &length,NULL ,0 ); +return freq; +#endif }
Signature · 1 line
2.31.1
Quoted 79 lines · Piotr Kubaj
__ppc_get_timebase()is only present when glibc is used.Signed-off-by Piotr Kubaj <[email protected]>--- lib/eal/ppc/include/rte_altivec.h | 3 +++ lib/eal/ppc/include/rte_cycles.h | 12 ++++++++++++ lib/eal/ppc/rte_cycles.c | 16 ++++++++++++++++ 3 files changed, 31 insertions(+)lib/eal/ppc/include/rte_altivec.h +3
-0@@ -7,6 +7,9 @@#define _RTE_ALTIVEC_H_/* To include altivec.h, GCC version must be >= 4.8 */ +#ifdef __clang__ +#define vector __vector +#endif #include <altivec.h> /* lib/eal/ppc/include/rte_cycles.h +12
-0@@ -10,7 +10,13 @@extern "C" {#endif +#ifdef linux +#include <features.h> +#endif + +#ifdef __GLIBC__#include <sys/platform/ppc.h> +#endif #include "generic/rte_cycles.h" @@ -26,7 +32,13 @@ extern "C" {static inline uint64_t rte_rdtsc (void ) { +#ifdef __GLIBC__return __ppc_get_timebase (); +#else +uint64_t __tb; + __asm__volatile ("mfspr %0, 268" :"=r" (__tb)); +return __tb; +#endif } static inline uint64_tlib/eal/ppc/rte_cycles.c +9
-0@@ -2,12 +2,28 @@* Copyright (C) IBM Corporation 2019. */ +#ifdef linux +#include <features.h> +#elif defined(__FreeBSD__) +#include <sys/types.h> +#include <sys/sysctl.h> +#endif + +#ifdef __GLIBC__#include <sys/platform/ppc.h> +#endif #include "eal_private.h" uint64_t get_tsc_freq_arch (void )
lib/eal/ppc/rte_cycles.c line 29
Quoted 10 lines
lib/eal/ppc/rte_cycles.c +7
-0{ +#ifdef __GLIBC__return __ppc_get_timebase_freq (); +#elif defined(__FreeBSD__) +uint64_t freq; +size_t length =sizeof (freq); +sysctlbyname ("kern.timecounter.tc.timebase.frequency" , &freq, &length,NULL ,0 ); +return freq; +#endif }
18/05/2021 22:42, David Christensen:
Quoted 11 lines · Piotr Kubaj
Quoted 8 lines
__ppc_get_timebase()is only present when glibc is used.Signed-off-by Piotr Kubaj <[email protected]>--- lib/eal/ppc/include/rte_altivec.h | 3 +++ lib/eal/ppc/include/rte_cycles.h | 12 ++++++++++++ lib/eal/ppc/rte_cycles.c | 16 ++++++++++++++++ 3 files changed, 31 insertions(+)Reviewed-by David Christensen <[email protected]>
This patch does a lot more than what is described. It seems adding support for FreeBSD.
For testing OS, please use #ifdef RTE_EXEC_ENV_*
Well, isn't FreeBSD already supported?
Even https://www.dpdk.org/ mentions supporting FreeBSD.
Quoted 18 lines · Thomas Monjalon
18/05/2021 22:42, David Christensen:
Quoted 11 lines · Piotr Kubaj
Quoted 8 lines
__ppc_get_timebase()is only present when glibc is used.Signed-off-by Piotr Kubaj <[email protected]>--- lib/eal/ppc/include/rte_altivec.h | 3 +++ lib/eal/ppc/include/rte_cycles.h | 12 ++++++++++++ lib/eal/ppc/rte_cycles.c | 16 ++++++++++++++++ 3 files changed, 31 insertions(+)Reviewed-by David Christensen <[email protected]>This patch does a lot more than what is described. It seems adding support for FreeBSD.
For testing OS, please use #ifdef RTE_EXEC_ENV_*
19/05/2021 11:57, Piotr Kubaj:
Quoted 3 lines
Well, isn't FreeBSD already supported?
Even https://www.dpdk.org/ mentions supporting FreeBSD.
Yes it is supposed to be supported.
But why are you adding all this code for PPC?
It doesn't seem to be all related to clang only.
PS: please do not top-post.
Quoted 17 lines · Thomas Monjalon
Quoted 16 lines
18/05/2021 22:42, David Christensen:
Quoted 11 lines · Piotr Kubaj
Quoted 8 lines
__ppc_get_timebase()is only present when glibc is used.Signed-off-by Piotr Kubaj <[email protected]>--- lib/eal/ppc/include/rte_altivec.h | 3 +++ lib/eal/ppc/include/rte_cycles.h | 12 ++++++++++++ lib/eal/ppc/rte_cycles.c | 16 ++++++++++++++++ 3 files changed, 31 insertions(+)Reviewed-by David Christensen <[email protected]>This patch does a lot more than what is described. It seems adding support for FreeBSD.
For testing OS, please use #ifdef RTE_EXEC_ENV_*
Quoted 33 lines · Thomas Monjalon
19/05/2021 11:57, Piotr Kubaj:
Quoted 3 lines
Well, isn't FreeBSD already supported?
Even https://www.dpdk.org/ mentions supporting FreeBSD.
Yes it is supposed to be supported.
But why are you adding all this code for PPC?
It doesn't seem to be all related to clang only.PS: please do not top-post.
Quoted 17 lines · Thomas Monjalon
Quoted 16 lines
18/05/2021 22:42, David Christensen:
Quoted 11 lines · Piotr Kubaj
Quoted 8 lines
__ppc_get_timebase()is only present when glibc is used.Signed-off-by Piotr Kubaj <[email protected]>--- lib/eal/ppc/include/rte_altivec.h | 3 +++ lib/eal/ppc/include/rte_cycles.h | 12 ++++++++++++ lib/eal/ppc/rte_cycles.c | 16 ++++++++++++++++ 3 files changed, 31 insertions(+)Reviewed-by David Christensen <[email protected]>This patch does a lot more than what is described. It seems adding support for FreeBSD.
For testing OS, please use #ifdef RTE_EXEC_ENV_*
Well, I'm adding this code for PPC, because there are build issues on powerpc64le machines running FreeBSD.