DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v2] lib/eal/ppc fix compilation for musl
       [not found] <20220502115228.3AAAB1242D4@dpdk.org>
@ 2022-05-02 14:26 ` Duncan Bellamy
  2022-05-02 17:41   ` David Marchand
                     ` (6 more replies)
  0 siblings, 7 replies; 15+ messages in thread
From: Duncan Bellamy @ 2022-05-02 14:26 UTC (permalink / raw)
  To: dev; +Cc: Duncan Bellamy

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>
---
 lib/eal/ppc/include/rte_cycles.h |  6 ++++++
 lib/eal/ppc/rte_cycles.c         | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/lib/eal/ppc/include/rte_cycles.h b/lib/eal/ppc/include/rte_cycles.h
index 5585f9273c..98ffbd2592 100644
--- a/lib/eal/ppc/include/rte_cycles.h
+++ b/lib/eal/ppc/include/rte_cycles.h
@@ -10,7 +10,9 @@
 extern "C" {
 #endif
 
+#if defined(__GLIBC__)
 #include <sys/platform/ppc.h>
+#endif
 
 #include "generic/rte_cycles.h"
 
@@ -26,7 +28,11 @@ extern "C" {
 static inline uint64_t
 rte_rdtsc(void)
 {
+#if defined(__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..154eba722c 100644
--- a/lib/eal/ppc/rte_cycles.c
+++ b/lib/eal/ppc/rte_cycles.c
@@ -2,12 +2,44 @@
  * Copyright (C) IBM Corporation 2019.
  */
 
+#if defined(__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)
 {
+#if defined(__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
 }
-- 
2.32.0


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2] lib/eal/ppc fix compilation for musl
  2022-05-02 14:26 ` [PATCH v2] lib/eal/ppc fix compilation for musl Duncan Bellamy
@ 2022-05-02 17:41   ` David Marchand
  2022-05-02 20:18     ` Dunk
  2022-05-02 17:42   ` David Christensen
                     ` (5 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: David Marchand @ 2022-05-02 17:41 UTC (permalink / raw)
  To: Duncan Bellamy; +Cc: dev

On Mon, May 2, 2022 at 4:26 PM Duncan Bellamy <dunk@denkimushi.com> wrote:
>
> 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>
> ---
>  lib/eal/ppc/include/rte_cycles.h |  6 ++++++
>  lib/eal/ppc/rte_cycles.c         | 32 ++++++++++++++++++++++++++++++++
>  2 files changed, 38 insertions(+)
>
> diff --git a/lib/eal/ppc/include/rte_cycles.h b/lib/eal/ppc/include/rte_cycles.h
> index 5585f9273c..98ffbd2592 100644
> --- a/lib/eal/ppc/include/rte_cycles.h
> +++ b/lib/eal/ppc/include/rte_cycles.h
> @@ -10,7 +10,9 @@
>  extern "C" {
>  #endif
>
> +#if defined(__GLIBC__)

features.h should be included before looking for __GLIBC__.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2] lib/eal/ppc fix compilation for musl
  2022-05-02 14:26 ` [PATCH v2] lib/eal/ppc fix compilation for musl Duncan Bellamy
  2022-05-02 17:41   ` David Marchand
@ 2022-05-02 17:42   ` David Christensen
  2022-05-02 20:20     ` Dunk
  2022-05-07  9:47   ` [PATCH v3] " Duncan Bellamy
                     ` (4 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: David Christensen @ 2022-05-02 17:42 UTC (permalink / raw)
  To: Duncan Bellamy, dev



On 5/2/22 7:26 AM, Duncan Bellamy wrote:
> 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>
> ---
>   lib/eal/ppc/include/rte_cycles.h |  6 ++++++
>   lib/eal/ppc/rte_cycles.c         | 32 ++++++++++++++++++++++++++++++++
>   2 files changed, 38 insertions(+)
> 
> diff --git a/lib/eal/ppc/include/rte_cycles.h b/lib/eal/ppc/include/rte_cycles.h
> index 5585f9273c..98ffbd2592 100644
> --- a/lib/eal/ppc/include/rte_cycles.h
> +++ b/lib/eal/ppc/include/rte_cycles.h
> @@ -10,7 +10,9 @@
>   extern "C" {
>   #endif
> 
> +#if defined(__GLIBC__)
>   #include <sys/platform/ppc.h>
> +#endif
> 
>   #include "generic/rte_cycles.h"
> 
> @@ -26,7 +28,11 @@ extern "C" {
>   static inline uint64_t
>   rte_rdtsc(void)
>   {
> +#if defined(__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..154eba722c 100644
> --- a/lib/eal/ppc/rte_cycles.c
> +++ b/lib/eal/ppc/rte_cycles.c
> @@ -2,12 +2,44 @@
>    * Copyright (C) IBM Corporation 2019.
>    */
> 
> +#if defined(__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)
>   {
> +#if defined(__GLIBC__)
>   	return __ppc_get_timebase_freq();
> +#else
> +	static uint64_t base;
> +	if (!base) {
> +		FILE *f = fopen("/proc/cpuinfo", "rb");

Code is valid but Linux specific. Access to /proc/cpuinfo needs to live 
in lib/eal/linux/eal_timer.c, surrounded by '#ifndef 
RTE_ARCH_PPC_64/#endif', with stubs for FreeBSD/Windows.

Dave

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2] lib/eal/ppc fix compilation for musl
  2022-05-02 17:41   ` David Marchand
@ 2022-05-02 20:18     ` Dunk
  0 siblings, 0 replies; 15+ messages in thread
From: Dunk @ 2022-05-02 20:18 UTC (permalink / raw)
  To: David Marchand; +Cc: dev



> On 2 May 2022, at 18:42, David Marchand <david.marchand@redhat.com> wrote:
> 
> On Mon, May 2, 2022 at 4:26 PM Duncan Bellamy <dunk@denkimushi.com> wrote:
>> 
>> 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>
>> ---
>> lib/eal/ppc/include/rte_cycles.h |  6 ++++++
>> lib/eal/ppc/rte_cycles.c         | 32 ++++++++++++++++++++++++++++++++
>> 2 files changed, 38 insertions(+)
>> 
>> diff --git a/lib/eal/ppc/include/rte_cycles.h b/lib/eal/ppc/include/rte_cycles.h
>> index 5585f9273c..98ffbd2592 100644
>> --- a/lib/eal/ppc/include/rte_cycles.h
>> +++ b/lib/eal/ppc/include/rte_cycles.h
>> @@ -10,7 +10,9 @@
>> extern "C" {
>> #endif
>> 
>> +#if defined(__GLIBC__)
> 
> features.h should be included before looking for __GLIBC__.
> 
> 
> -- 
> David Marchand
> 

Okay, wondered why it wasn’t working 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2] lib/eal/ppc fix compilation for musl
  2022-05-02 17:42   ` David Christensen
@ 2022-05-02 20:20     ` Dunk
  0 siblings, 0 replies; 15+ messages in thread
From: Dunk @ 2022-05-02 20:20 UTC (permalink / raw)
  To: David Christensen; +Cc: dev



> On 2 May 2022, at 18:43, David Christensen <drc@linux.vnet.ibm.com> wrote:
> 
> 
> 
>> On 5/2/22 7:26 AM, Duncan Bellamy wrote:
>> 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>
>> ---
>>  lib/eal/ppc/include/rte_cycles.h |  6 ++++++
>>  lib/eal/ppc/rte_cycles.c         | 32 ++++++++++++++++++++++++++++++++
>>  2 files changed, 38 insertions(+)
>> diff --git a/lib/eal/ppc/include/rte_cycles.h b/lib/eal/ppc/include/rte_cycles.h
>> index 5585f9273c..98ffbd2592 100644
>> --- a/lib/eal/ppc/include/rte_cycles.h
>> +++ b/lib/eal/ppc/include/rte_cycles.h
>> @@ -10,7 +10,9 @@
>>  extern "C" {
>>  #endif
>> +#if defined(__GLIBC__)
>>  #include <sys/platform/ppc.h>
>> +#endif
>>  #include "generic/rte_cycles.h"
>> @@ -26,7 +28,11 @@ extern "C" {
>>  static inline uint64_t
>>  rte_rdtsc(void)
>>  {
>> +#if defined(__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..154eba722c 100644
>> --- a/lib/eal/ppc/rte_cycles.c
>> +++ b/lib/eal/ppc/rte_cycles.c
>> @@ -2,12 +2,44 @@
>>   * Copyright (C) IBM Corporation 2019.
>>   */
>> +#if defined(__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)
>>  {
>> +#if defined(__GLIBC__)
>>      return __ppc_get_timebase_freq();
>> +#else
>> +    static uint64_t base;
>> +    if (!base) {
>> +        FILE *f = fopen("/proc/cpuinfo", "rb");
> 
> Code is valid but Linux specific. Access to /proc/cpuinfo needs to live in lib/eal/linux/eal_timer.c, surrounded by '#ifndef RTE_ARCH_PPC_64/#endif', with stubs for FreeBSD/Windows.
> Dave

Okay will move, will change glibc check back to ifdef as well.

Duncan 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v3] lib/eal/ppc fix compilation for musl
  2022-05-02 14:26 ` [PATCH v2] lib/eal/ppc fix compilation for musl Duncan Bellamy
  2022-05-02 17:41   ` David Marchand
  2022-05-02 17:42   ` David Christensen
@ 2022-05-07  9:47   ` Duncan Bellamy
  2022-05-07 19:43   ` [PATCH v4] " Duncan Bellamy
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 15+ messages in thread
From: Duncan Bellamy @ 2022-05-07  9:47 UTC (permalink / raw)
  To: dev; +Cc: Duncan Bellamy

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>
---
 lib/eal/common/eal_private.h     |  7 ++++++
 lib/eal/linux/eal_timer.c        | 39 ++++++++++++++++++++++++++++++++
 lib/eal/ppc/include/rte_cycles.h |  7 ++++++
 lib/eal/ppc/rte_cycles.c         | 10 ++++++++
 4 files changed, 63 insertions(+)

diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h
index 44d14241f0..9ac1949e1c 100644
--- a/lib/eal/common/eal_private.h
+++ b/lib/eal/common/eal_private.h
@@ -743,4 +743,11 @@ int eal_asprintf(char **buffer, const char *format, ...);
 		eal_asprintf(buffer, format, ##__VA_ARGS__)
 #endif
 
+/**
+ * Function for systems with no __ppc_get_timebase_freq function.
+ */
+#ifndef RTE_ARCH_PPC_64
+uint64_t no_ppc_get_timebase_freq(void);
+#endif
+
 #endif /* _EAL_PRIVATE_H_ */
diff --git a/lib/eal/linux/eal_timer.c b/lib/eal/linux/eal_timer.c
index 620baf038d..23e06d92c1 100644
--- a/lib/eal/linux/eal_timer.c
+++ b/lib/eal/linux/eal_timer.c
@@ -5,6 +5,8 @@
 
 #include <stdio.h>
 #include <stdint.h>
+#include <string.h>
+#include <features.h>
 
 #include <rte_common.h>
 #include <rte_cycles.h>
@@ -222,3 +224,40 @@ rte_eal_timer_init(void)
 	set_tsc_freq();
 	return 0;
 }
+
+#ifndef RTE_ARCH_PPC_64
+uint64_t
+no_ppc_get_timebase_freq(void)
+{
+	static uint64_t base;
+	#if defined(__LINUX__)
+	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);
+		}
+	}
+	#elif defined(_WIN32) || defined(_WIN64)
+	// windows code here
+	#elif defined(RTE_EXEC_ENV_FREEBSD)
+	// freebsd code here
+	#endif
+	return base;
+}
+#endif
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 <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
diff --git a/lib/eal/ppc/rte_cycles.c b/lib/eal/ppc/rte_cycles.c
index 3180adb0ff..b69fc701a6 100644
--- a/lib/eal/ppc/rte_cycles.c
+++ b/lib/eal/ppc/rte_cycles.c
@@ -2,12 +2,22 @@
  * Copyright (C) IBM Corporation 2019.
  */
 
+#include <features.h>
+#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
+	return no_ppc_get_timebase_freq();
+#endif
 }
-- 
2.32.0


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v4] lib/eal/ppc fix compilation for musl
  2022-05-02 14:26 ` [PATCH v2] lib/eal/ppc fix compilation for musl Duncan Bellamy
                     ` (2 preceding siblings ...)
  2022-05-07  9:47   ` [PATCH v3] " Duncan Bellamy
@ 2022-05-07 19:43   ` Duncan Bellamy
  2022-05-07 21:03   ` [PATCH v5] " Duncan Bellamy
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 15+ messages in thread
From: Duncan Bellamy @ 2022-05-07 19:43 UTC (permalink / raw)
  To: dev; +Cc: Duncan Bellamy

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>
---
 lib/eal/common/eal_private.h     |  7 ++++++
 lib/eal/linux/eal_timer.c        | 39 ++++++++++++++++++++++++++++++++
 lib/eal/ppc/include/rte_cycles.h |  7 ++++++
 lib/eal/ppc/rte_cycles.c         | 10 ++++++++
 4 files changed, 63 insertions(+)

diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h
index 44d14241f0..9ac1949e1c 100644
--- a/lib/eal/common/eal_private.h
+++ b/lib/eal/common/eal_private.h
@@ -743,4 +743,11 @@ int eal_asprintf(char **buffer, const char *format, ...);
 		eal_asprintf(buffer, format, ##__VA_ARGS__)
 #endif
 
+/**
+ * Function for systems with no __ppc_get_timebase_freq function.
+ */
+#ifndef RTE_ARCH_PPC_64
+uint64_t no_ppc_get_timebase_freq(void);
+#endif
+
 #endif /* _EAL_PRIVATE_H_ */
diff --git a/lib/eal/linux/eal_timer.c b/lib/eal/linux/eal_timer.c
index 620baf038d..89cadb9cfb 100644
--- a/lib/eal/linux/eal_timer.c
+++ b/lib/eal/linux/eal_timer.c
@@ -5,6 +5,8 @@
 
 #include <stdio.h>
 #include <stdint.h>
+#include <string.h>
+#include <features.h>
 
 #include <rte_common.h>
 #include <rte_cycles.h>
@@ -222,3 +224,40 @@ rte_eal_timer_init(void)
 	set_tsc_freq();
 	return 0;
 }
+
+#ifndef RTE_ARCH_PPC_64
+uint64_t
+no_ppc_get_timebase_freq(void)
+{
+	static uint64_t base;
+	#if defined(__LINUX__)
+	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);
+		}
+	}
+	#elif defined(_WIN32) || defined(_WIN64)
+	/* windows code here */
+	#elif defined(RTE_EXEC_ENV_FREEBSD)
+	/* freebsd code here */
+	#endif
+	return base;
+}
+#endif
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 <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
diff --git a/lib/eal/ppc/rte_cycles.c b/lib/eal/ppc/rte_cycles.c
index 3180adb0ff..b69fc701a6 100644
--- a/lib/eal/ppc/rte_cycles.c
+++ b/lib/eal/ppc/rte_cycles.c
@@ -2,12 +2,22 @@
  * Copyright (C) IBM Corporation 2019.
  */
 
+#include <features.h>
+#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
+	return no_ppc_get_timebase_freq();
+#endif
 }
-- 
2.32.0


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v5] lib/eal/ppc fix compilation for musl
  2022-05-02 14:26 ` [PATCH v2] lib/eal/ppc fix compilation for musl Duncan Bellamy
                     ` (3 preceding siblings ...)
  2022-05-07 19:43   ` [PATCH v4] " Duncan Bellamy
@ 2022-05-07 21:03   ` Duncan Bellamy
  2022-05-07 21:15   ` [PATCH v6] " Duncan Bellamy
  2022-05-14  7:14   ` [PATCH v7] eal/ppc: " Duncan Bellamy
  6 siblings, 0 replies; 15+ messages in thread
From: Duncan Bellamy @ 2022-05-07 21:03 UTC (permalink / raw)
  To: dev; +Cc: Duncan Bellamy

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>
---
 lib/eal/common/eal_private.h     |  7 +++++++
 lib/eal/linux/eal_timer.c        | 35 ++++++++++++++++++++++++++++++++
 lib/eal/ppc/include/rte_cycles.h |  7 +++++++
 lib/eal/ppc/rte_cycles.c         | 10 +++++++++
 4 files changed, 59 insertions(+)

diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h
index 44d14241f0..9ac1949e1c 100644
--- a/lib/eal/common/eal_private.h
+++ b/lib/eal/common/eal_private.h
@@ -743,4 +743,11 @@ int eal_asprintf(char **buffer, const char *format, ...);
 		eal_asprintf(buffer, format, ##__VA_ARGS__)
 #endif
 
+/**
+ * Function for systems with no __ppc_get_timebase_freq function.
+ */
+#ifndef RTE_ARCH_PPC_64
+uint64_t no_ppc_get_timebase_freq(void);
+#endif
+
 #endif /* _EAL_PRIVATE_H_ */
diff --git a/lib/eal/linux/eal_timer.c b/lib/eal/linux/eal_timer.c
index 620baf038d..c5436ed1c5 100644
--- a/lib/eal/linux/eal_timer.c
+++ b/lib/eal/linux/eal_timer.c
@@ -5,6 +5,8 @@
 
 #include <stdio.h>
 #include <stdint.h>
+#include <string.h>
+#include <features.h>
 
 #include <rte_common.h>
 #include <rte_cycles.h>
@@ -222,3 +224,36 @@ rte_eal_timer_init(void)
 	set_tsc_freq();
 	return 0;
 }
+
+#ifndef RTE_ARCH_PPC_64
+uint64_t
+no_ppc_get_timebase_freq(void)
+{
+	static uint64_t base;
+	#if defined(__LINUX__)
+	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);
+		}
+	}
+	#elif defined(_WIN32) || defined(_WIN64)
+	/* windows code here */
+	#elif defined(RTE_EXEC_ENV_FREEBSD)
+	/* freebsd code here */
+	#endif
+	return base;
+}
+#endif
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 <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
diff --git a/lib/eal/ppc/rte_cycles.c b/lib/eal/ppc/rte_cycles.c
index 3180adb0ff..b69fc701a6 100644
--- a/lib/eal/ppc/rte_cycles.c
+++ b/lib/eal/ppc/rte_cycles.c
@@ -2,12 +2,22 @@
  * Copyright (C) IBM Corporation 2019.
  */
 
+#include <features.h>
+#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
+	return no_ppc_get_timebase_freq();
+#endif
 }
-- 
2.32.0


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v6] lib/eal/ppc fix compilation for musl
  2022-05-02 14:26 ` [PATCH v2] lib/eal/ppc fix compilation for musl Duncan Bellamy
                     ` (4 preceding siblings ...)
  2022-05-07 21:03   ` [PATCH v5] " Duncan Bellamy
@ 2022-05-07 21:15   ` Duncan Bellamy
  2022-05-09 12:06     ` David Marchand
  2022-05-14  7:14   ` [PATCH v7] eal/ppc: " Duncan Bellamy
  6 siblings, 1 reply; 15+ messages in thread
From: Duncan Bellamy @ 2022-05-07 21:15 UTC (permalink / raw)
  To: dev; +Cc: Duncan Bellamy

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>
---
 lib/eal/common/eal_private.h     |  7 ++++++
 lib/eal/linux/eal_timer.c        | 37 ++++++++++++++++++++++++++++++++
 lib/eal/ppc/include/rte_cycles.h |  7 ++++++
 lib/eal/ppc/rte_cycles.c         | 10 +++++++++
 4 files changed, 61 insertions(+)

diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h
index 44d14241f0..9ac1949e1c 100644
--- a/lib/eal/common/eal_private.h
+++ b/lib/eal/common/eal_private.h
@@ -743,4 +743,11 @@ int eal_asprintf(char **buffer, const char *format, ...);
 		eal_asprintf(buffer, format, ##__VA_ARGS__)
 #endif
 
+/**
+ * Function for systems with no __ppc_get_timebase_freq function.
+ */
+#ifndef RTE_ARCH_PPC_64
+uint64_t no_ppc_get_timebase_freq(void);
+#endif
+
 #endif /* _EAL_PRIVATE_H_ */
diff --git a/lib/eal/linux/eal_timer.c b/lib/eal/linux/eal_timer.c
index 620baf038d..4f46f5411d 100644
--- a/lib/eal/linux/eal_timer.c
+++ b/lib/eal/linux/eal_timer.c
@@ -5,6 +5,8 @@
 
 #include <stdio.h>
 #include <stdint.h>
+#include <string.h>
+#include <features.h>
 
 #include <rte_common.h>
 #include <rte_cycles.h>
@@ -222,3 +224,38 @@ rte_eal_timer_init(void)
 	set_tsc_freq();
 	return 0;
 }
+
+#ifndef RTE_ARCH_PPC_64
+uint64_t
+no_ppc_get_timebase_freq(void)
+{
+	static uint64_t base;
+	#if defined(__LINUX__)
+	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);
+		}
+	}
+	#elif defined(_WIN32) || defined(_WIN64)
+	/* windows code here */
+	#elif defined(RTE_EXEC_ENV_FREEBSD)
+	/* freebsd code here */
+	#endif
+	return base;
+}
+#endif
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 <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
diff --git a/lib/eal/ppc/rte_cycles.c b/lib/eal/ppc/rte_cycles.c
index 3180adb0ff..b69fc701a6 100644
--- a/lib/eal/ppc/rte_cycles.c
+++ b/lib/eal/ppc/rte_cycles.c
@@ -2,12 +2,22 @@
  * Copyright (C) IBM Corporation 2019.
  */
 
+#include <features.h>
+#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
+	return no_ppc_get_timebase_freq();
+#endif
 }
-- 
2.32.0


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v6] lib/eal/ppc fix compilation for musl
  2022-05-07 21:15   ` [PATCH v6] " Duncan Bellamy
@ 2022-05-09 12:06     ` David Marchand
  2022-05-09 22:39       ` Dunk
  0 siblings, 1 reply; 15+ messages in thread
From: David Marchand @ 2022-05-09 12:06 UTC (permalink / raw)
  To: Duncan Bellamy; +Cc: dev, David Christensen

On Sat, May 7, 2022 at 11:16 PM Duncan Bellamy <dunk@denkimushi.com> wrote:
>
> 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>

- A patch title does not need lib/ prefix.
Here, "eal/ppc: " is enough.


- Code in lib/eal/linux won't be used for FreeBSD/Windows.
On the other hand, arch-specific code (here, lib/eal/ppc/) can be used
for the various OS.
Besides, as far as I can see in the Linux kernel sources, powerpc is
the only architecture that exports a "timebase" entry in
/proc/cpuinfo.
So, I see no reason to put any code out of lib/eal/ppc.


- In the end, unless I missed some point, the patch could probably
look like (untested):

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 <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
diff --git a/lib/eal/ppc/rte_cycles.c b/lib/eal/ppc/rte_cycles.c
index 3180adb0ff..99d36b2f7e 100644
--- a/lib/eal/ppc/rte_cycles.c
+++ b/lib/eal/ppc/rte_cycles.c
@@ -2,12 +2,50 @@
  * 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
 }


-- 
David Marchand


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v6] lib/eal/ppc fix compilation for musl
  2022-05-09 12:06     ` David Marchand
@ 2022-05-09 22:39       ` Dunk
  0 siblings, 0 replies; 15+ messages in thread
From: Dunk @ 2022-05-09 22:39 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, David Christensen



> On 9 May 2022, at 13:06, David Marchand <david.marchand@redhat.com> wrote:
> 
> On Sat, May 7, 2022 at 11:16 PM Duncan Bellamy <dunk@denkimushi.com> wrote:
>> 
>> 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>
> 
> - A patch title does not need lib/ prefix.
> Here, "eal/ppc: " is enough.
> 
> 
> - Code in lib/eal/linux won't be used for FreeBSD/Windows.
> On the other hand, arch-specific code (here, lib/eal/ppc/) can be used
> for the various OS.
> Besides, as far as I can see in the Linux kernel sources, powerpc is
> the only architecture that exports a "timebase" entry in
> /proc/cpuinfo.
> So, I see no reason to put any code out of lib/eal/ppc.
> 
> 
> - In the end, unless I missed some point, the patch could probably
> look like (untested):
> 
> 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 <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
> diff --git a/lib/eal/ppc/rte_cycles.c b/lib/eal/ppc/rte_cycles.c
> index 3180adb0ff..99d36b2f7e 100644
> --- a/lib/eal/ppc/rte_cycles.c
> +++ b/lib/eal/ppc/rte_cycles.c
> @@ -2,12 +2,50 @@
>  * 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
> }
> 
> 
> -- 
> David Marchand
> 

Thanks, that looks the same thing.  Will run through alpine CI and change commit title

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v7] eal/ppc: fix compilation for musl
  2022-05-02 14:26 ` [PATCH v2] lib/eal/ppc fix compilation for musl Duncan Bellamy
                     ` (5 preceding siblings ...)
  2022-05-07 21:15   ` [PATCH v6] " Duncan Bellamy
@ 2022-05-14  7:14   ` Duncan Bellamy
  2022-05-19 16:18     ` David Marchand
  2022-05-31 17:24     ` David Christensen
  6 siblings, 2 replies; 15+ messages in thread
From: Duncan Bellamy @ 2022-05-14  7:14 UTC (permalink / raw)
  To: dev; +Cc: Duncan Bellamy

musl lacks __ppc_get_timebase() but has __builtin_ppc_get_timebase()

Signed-off-by: Duncan Bellamy <dunk@denkimushi.com>
---
 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 <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
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 <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
+
 }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v7] eal/ppc: fix compilation for musl
  2022-05-14  7:14   ` [PATCH v7] eal/ppc: " Duncan Bellamy
@ 2022-05-19 16:18     ` David Marchand
  2022-05-31 17:24     ` David Christensen
  1 sibling, 0 replies; 15+ messages in thread
From: David Marchand @ 2022-05-19 16:18 UTC (permalink / raw)
  To: Duncan Bellamy; +Cc: dev, David Christensen

On Sat, May 14, 2022 at 9:15 AM Duncan Bellamy <dunk@denkimushi.com> wrote:
>
> musl lacks __ppc_get_timebase() but has __builtin_ppc_get_timebase()
>
> Signed-off-by: Duncan Bellamy <dunk@denkimushi.com>

Cc: maintainer.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v7] eal/ppc: fix compilation for musl
  2022-05-14  7:14   ` [PATCH v7] eal/ppc: " Duncan Bellamy
  2022-05-19 16:18     ` David Marchand
@ 2022-05-31 17:24     ` David Christensen
  2022-06-01 15:06       ` David Marchand
  1 sibling, 1 reply; 15+ messages in thread
From: David Christensen @ 2022-05-31 17:24 UTC (permalink / raw)
  To: Duncan Bellamy, dev



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 <dunk@denkimushi.com>
> ---
>   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 <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
> 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 <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
> +
>   }

Reviewed-by: David Christensen <drc@linux.vnet.ibm.com>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v7] eal/ppc: fix compilation for musl
  2022-05-31 17:24     ` David Christensen
@ 2022-06-01 15:06       ` David Marchand
  0 siblings, 0 replies; 15+ messages in thread
From: David Marchand @ 2022-06-01 15:06 UTC (permalink / raw)
  To: Duncan Bellamy; +Cc: dev, David Christensen

On Tue, May 31, 2022 at 7:26 PM David Christensen
<drc@linux.vnet.ibm.com> wrote:
> 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 <dunk@denkimushi.com>
> Reviewed-by: David Christensen <drc@linux.vnet.ibm.com>

Applied, thanks.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2022-06-01 15:06 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20220502115228.3AAAB1242D4@dpdk.org>
2022-05-02 14:26 ` [PATCH v2] lib/eal/ppc fix compilation for musl Duncan Bellamy
2022-05-02 17:41   ` David Marchand
2022-05-02 20:18     ` Dunk
2022-05-02 17:42   ` David Christensen
2022-05-02 20:20     ` Dunk
2022-05-07  9:47   ` [PATCH v3] " Duncan Bellamy
2022-05-07 19:43   ` [PATCH v4] " Duncan Bellamy
2022-05-07 21:03   ` [PATCH v5] " Duncan Bellamy
2022-05-07 21:15   ` [PATCH v6] " Duncan Bellamy
2022-05-09 12:06     ` David Marchand
2022-05-09 22:39       ` Dunk
2022-05-14  7:14   ` [PATCH v7] eal/ppc: " Duncan Bellamy
2022-05-19 16:18     ` David Marchand
2022-05-31 17:24     ` David Christensen
2022-06-01 15:06       ` David Marchand

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).