mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-07-24 19:55:26 +03:00
71 lines
1.3 KiB
Diff
71 lines
1.3 KiB
Diff
--- 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
|
|
}
|