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 5537CA0550; Tue, 31 May 2022 19:25:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3A8DF40689; Tue, 31 May 2022 19:25:29 +0200 (CEST) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by mails.dpdk.org (Postfix) with ESMTP id 290CA4067B for ; Tue, 31 May 2022 19:25:28 +0200 (CEST) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24VHO7FS030565; Tue, 31 May 2022 17:25:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=hClaf8d9jVHXXcyHPQ3r0eCE7Qf20ZPIN+7UAOm3Dkk=; b=HJF8eZAwKP46lCjA6PIRrgAXTE5LzTkEImCDZqmTKM9gOoFxvikfodIm1UzKycjqSj7/ +RxvsHh1UAARyvdYRioDcti7Q4Wf1sRTKSyamP6UEfgoHBbKZNS9X3JRAWHUdlIHDDEk /XUtuSU2wJ7+qHXDORBP/Bj8VKbH8lbiHu3sEzD2fbapr4pwlLPCnLtzpNvhICoWZmBR thuWBUxfECUvfFyjPqC1Xvrm5v0TwXwSOMPTBPQsTIUoLYLB4inlyQGk2WhWWvdz9eIP P5Sjr7Tabmf2blvEofsTV9NYE/nh8RtI2FFddU1jxBLP7zdsl2lHVulYvEeA2Nh7FncI SA== Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gdm4s4q7v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 31 May 2022 17:25:02 +0000 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 24VHKbII027535; Tue, 31 May 2022 17:25:01 GMT Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by ppma02dal.us.ibm.com with ESMTP id 3gd1acrv6g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 31 May 2022 17:25:01 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 24VHP0Np27525404 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 May 2022 17:25:00 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BD3AA11206B; Tue, 31 May 2022 17:25:00 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 57666112064; Tue, 31 May 2022 17:25:00 +0000 (GMT) Received: from [9.163.6.39] (unknown [9.163.6.39]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 31 May 2022 17:25:00 +0000 (GMT) Message-ID: Date: Tue, 31 May 2022 10:24:59 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v7] eal/ppc: fix compilation for musl Content-Language: en-US To: Duncan Bellamy , dev@dpdk.org References: <20220502142615.3705639-1-dunk@denkimushi.com> <20220514071435.3024492-1-dunk@denkimushi.com> From: David Christensen In-Reply-To: <20220514071435.3024492-1-dunk@denkimushi.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 3staxI08i6bqFu7Rb-a0MlUA7WLRPzLa X-Proofpoint-GUID: 3staxI08i6bqFu7Rb-a0MlUA7WLRPzLa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-05-31_07,2022-05-30_03,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=730 mlxscore=0 malwarescore=0 priorityscore=1501 phishscore=0 spamscore=0 suspectscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2205310080 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 On 5/14/22 12:14 AM, Duncan Bellamy wrote: > musl lacks __ppc_get_timebase() but has __builtin_ppc_get_timebase() > > Signed-off-by: Duncan Bellamy > --- > lib/eal/ppc/include/rte_cycles.h | 7 ++++++ > lib/eal/ppc/rte_cycles.c | 39 ++++++++++++++++++++++++++++++++ > 2 files changed, 46 insertions(+) > > diff --git a/lib/eal/ppc/include/rte_cycles.h b/lib/eal/ppc/include/rte_cycles.h > index 5585f9273c..666fc9b0bf 100644 > --- a/lib/eal/ppc/include/rte_cycles.h > +++ b/lib/eal/ppc/include/rte_cycles.h > @@ -10,7 +10,10 @@ > extern "C" { > #endif > > +#include > +#ifdef __GLIBC__ > #include > +#endif > > #include "generic/rte_cycles.h" > > @@ -26,7 +29,11 @@ extern "C" { > static inline uint64_t > rte_rdtsc(void) > { > +#ifdef __GLIBC__ > return __ppc_get_timebase(); > +#else > + return __builtin_ppc_get_timebase(); > +#endif > } > > static inline uint64_t > diff --git a/lib/eal/ppc/rte_cycles.c b/lib/eal/ppc/rte_cycles.c > index 3180adb0ff..cd4bdff8b8 100644 > --- a/lib/eal/ppc/rte_cycles.c > +++ b/lib/eal/ppc/rte_cycles.c > @@ -2,12 +2,51 @@ > * Copyright (C) IBM Corporation 2019. > */ > > +#include > +#ifdef __GLIBC__ > #include > +#elif RTE_EXEC_ENV_LINUX > +#include > +#include > +#endif > > #include "eal_private.h" > > uint64_t > get_tsc_freq_arch(void) > { > +#ifdef __GLIBC__ > return __ppc_get_timebase_freq(); > +#elif RTE_EXEC_ENV_LINUX > + static unsigned long base; > + char buf[512]; > + ssize_t nr; > + FILE *f; > + > + if (base != 0) > + goto out; > + > + f = fopen("/proc/cpuinfo", "rb"); > + if (f == NULL) > + goto out; > + > + while (fgets(buf, sizeof(buf), f) != NULL) { > + char *ret = strstr(buf, "timebase"); > + > + if (ret == NULL) > + continue; > + ret += sizeof("timebase") - 1; > + ret = strchr(ret, ':'); > + if (ret == NULL) > + continue; > + base = strtoul(ret + 1, NULL, 10); > + break; > + } > + fclose(f); > +out: > + return (uint64_t) base; > +#else > + return 0; > +#endif > + > } Reviewed-by: David Christensen