eal/ppc: fix compilation for musl
musl lacks __ppc_get_timebase() but has __builtin_ppc_get_timebase() Signed-off-by: Duncan Bellamy <dunk@denkimushi.com> Reviewed-by: David Christensen <drc@linux.vnet.ibm.com>
This commit is contained in:
parent
77dd857d30
commit
0615dd2aa1
@ -10,7 +10,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <features.h>
|
||||
#ifdef __GLIBC__
|
||||
#include <sys/platform/ppc.h>
|
||||
#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
|
||||
|
@ -2,12 +2,51 @@
|
||||
* Copyright (C) IBM Corporation 2019.
|
||||
*/
|
||||
|
||||
#include <features.h>
|
||||
#ifdef __GLIBC__
|
||||
#include <sys/platform/ppc.h>
|
||||
#elif RTE_EXEC_ENV_LINUX
|
||||
#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();
|
||||
#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
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user