From: Dunk <dunk@denkimushi.com>
To: dev@dpdk.org
Subject: [PATCH 1/1] fix compilation for ppc64le on musl/Alpine
Date: Sat, 16 Apr 2022 22:21:17 +0100 [thread overview]
Message-ID: <F05860E5-707E-4213-9966-060DC785CD89@denkimushi.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 265 bytes --]
musl lacks __ppc_get_timebase() but has __builtin_ppc_get_timebase()
the __ppc_get_timebase_freq() is taken from:
https://git.alpinelinux.org/aports/commit/?id=06b03f70fb94972286c0c9f6278df89e53903833
Signed-off-by: Duncan Bellamy <dunk@denkimushi.com>
[-- Attachment #2.1: Type: text/html, Size: 583 bytes --]
[-- Attachment #2.2: 01-ppc.patch --]
[-- Type: application/octet-stream, Size: 1288 bytes --]
--- a/lib/eal/ppc/include/rte_cycles.h
+++ b/lib/eal/ppc/include/rte_cycles.h
@@ -10,7 +10,9 @@
extern "C" {
#endif
+#ifdef __GLIBC__
#include <sys/platform/ppc.h>
+#endif
#include "generic/rte_cycles.h"
@@ -26,7 +28,11 @@
static inline uint64_t
rte_rdtsc(void)
{
+#ifdef __GLIBC__
return __ppc_get_timebase();
+#else
+ return __builtin_ppc_get_timebase();
+#endif
}
static inline uint64_t
--- a/lib/eal/ppc/rte_cycles.c
+++ b/lib/eal/ppc/rte_cycles.c
@@ -2,12 +2,44 @@
* Copyright (C) IBM Corporation 2019.
*/
+#ifdef __GLIBC__
#include <sys/platform/ppc.h>
+#else
+#include <string.h>
+#include <stdio.h>
+#endif
#include "eal_private.h"
uint64_t
get_tsc_freq_arch(void)
{
+#ifdef __GLIBC__
return __ppc_get_timebase_freq();
+#else
+ static uint64_t base;
+ if (!base) {
+ FILE *f = fopen("/proc/cpuinfo", "rb");
+ if (f) {
+ ssize_t nr;
+ /* virtually always big enough to hold the line */
+ char buf[512];
+ while (fgets(buf, sizeof(buf), f)) {
+ char *ret = strstr(buf, "timebase");
+ if (!ret) {
+ continue;
+ }
+ ret += sizeof("timebase") - 1;
+ ret = strchr(ret, ':');
+ if (!ret) {
+ continue;
+ }
+ base = strtoul(ret + 1, 0, 10);
+ break;
+ }
+ fclose(f);
+ }
+ }
+ return base;;
+#endif
}
[-- Attachment #2.3: Type: text/html, Size: 156 bytes --]
reply other threads:[~2022-04-16 21:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=F05860E5-707E-4213-9966-060DC785CD89@denkimushi.com \
--to=dunk@denkimushi.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).