From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AE17BA0A02; Mon, 17 May 2021 09:59:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 59AFC410F1; Mon, 17 May 2021 09:59:48 +0200 (CEST) Received: from mail.anongoth.pl (mail.anongoth.pl [46.248.190.61]) by mails.dpdk.org (Postfix) with ESMTP id B70334003C for ; Mon, 17 May 2021 02:46:53 +0200 (CEST) Received: from talos.g.anongoth.pl (unknown [192.168.1.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: pkubaj@anongoth.pl) by mail.anongoth.pl (Postfix) with ESMTPSA id 547FCC465E; Mon, 17 May 2021 02:46:52 +0200 (CEST) From: Piotr Kubaj To: drc@linux.vnet.ibm.com Cc: dev@dpdk.org, Piotr Kubaj Date: Mon, 17 May 2021 02:46:21 +0200 Message-Id: <20210517004621.64357-1-pkubaj@FreeBSD.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Mon, 17 May 2021 09:59:45 +0200 Subject: [dpdk-dev] [PATCH] ppc64le: fix build without glibc and using Clang X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" __ppc_get_timebase() is only present when glibc is used. Signed-off-by: Piotr Kubaj --- 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(+) diff --git a/lib/eal/ppc/include/rte_altivec.h b/lib/eal/ppc/include/rte_altivec.h index 1551a94544..3fcc819c11 100644 --- a/lib/eal/ppc/include/rte_altivec.h +++ b/lib/eal/ppc/include/rte_altivec.h @@ -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 /* diff --git a/lib/eal/ppc/include/rte_cycles.h b/lib/eal/ppc/include/rte_cycles.h index 5585f9273c..a8307ceaff 100644 --- a/lib/eal/ppc/include/rte_cycles.h +++ b/lib/eal/ppc/include/rte_cycles.h @@ -10,7 +10,13 @@ extern "C" { #endif +#ifdef linux +#include +#endif + +#ifdef __GLIBC__ #include +#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 diff --git a/lib/eal/ppc/rte_cycles.c b/lib/eal/ppc/rte_cycles.c index 3180adb0ff..48545c4d67 100644 --- a/lib/eal/ppc/rte_cycles.c +++ b/lib/eal/ppc/rte_cycles.c @@ -2,12 +2,28 @@ * Copyright (C) IBM Corporation 2019. */ +#ifdef linux +#include +#elif defined(__FreeBSD__) +#include +#include +#endif + +#ifdef __GLIBC__ #include +#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 } -- 2.31.1