DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/2] fix compilation on FreeBSD
@ 2018-04-27  2:43 Thomas Monjalon
  2018-04-27  2:43 ` [dpdk-dev] [PATCH 1/2] eal: fix build with glibc < 2.16 Thomas Monjalon
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Thomas Monjalon @ 2018-04-27  2:43 UTC (permalink / raw)
  To: dev

The compilation was broken on FreeBSD due to the commit
for auxv, implemented only for Linux in the common files.

Thomas Monjalon (2):
  eal: fix build with glibc < 2.16
  eal: fix build on FreeBSD

 lib/librte_eal/bsdapp/eal/Makefile                 |  1 +
 lib/librte_eal/bsdapp/eal/eal_cpuflags.c           | 21 ++++++
 lib/librte_eal/bsdapp/eal/meson.build              |  1 +
 lib/librte_eal/common/eal_common_cpuflags.c        | 79 ----------------------
 lib/librte_eal/linuxapp/eal/Makefile               |  1 +
 .../eal/eal_cpuflags.c}                            | 49 +-------------
 lib/librte_eal/linuxapp/eal/meson.build            |  1 +
 7 files changed, 27 insertions(+), 126 deletions(-)
 create mode 100644 lib/librte_eal/bsdapp/eal/eal_cpuflags.c
 copy lib/librte_eal/{common/eal_common_cpuflags.c => linuxapp/eal/eal_cpuflags.c} (60%)

-- 
2.16.2

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

* [dpdk-dev] [PATCH 1/2] eal: fix build with glibc < 2.16
  2018-04-27  2:43 [dpdk-dev] [PATCH 0/2] fix compilation on FreeBSD Thomas Monjalon
@ 2018-04-27  2:43 ` Thomas Monjalon
  2018-04-30 13:13   ` Aaron Conole
  2018-04-27  2:43 ` [dpdk-dev] [PATCH 2/2] eal: fix build on FreeBSD Thomas Monjalon
  2018-04-27  9:03 ` [dpdk-dev] [PATCH 0/2] fix compilation " Maxime Coquelin
  2 siblings, 1 reply; 7+ messages in thread
From: Thomas Monjalon @ 2018-04-27  2:43 UTC (permalink / raw)
  To: dev; +Cc: aconole, tredaelli

The fake getauxval function does not use its parameter.
So the compiler raised this error:
	lib/librte_eal/common/eal_common_cpuflags.c:25:25: error:
	unused parameter 'type'

Fixes: 2ed9bf330709 ("eal: abstract away the auxiliary vector")
Cc: aconole@redhat.com
Cc: tredaelli@redhat.com

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 lib/librte_eal/common/eal_common_cpuflags.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_cpuflags.c b/lib/librte_eal/common/eal_common_cpuflags.c
index a09667563..6a9dbaeb1 100644
--- a/lib/librte_eal/common/eal_common_cpuflags.c
+++ b/lib/librte_eal/common/eal_common_cpuflags.c
@@ -22,7 +22,7 @@
 
 #ifndef HAS_AUXV
 static unsigned long
-getauxval(unsigned long type)
+getauxval(unsigned long type __rte_unused)
 {
 	errno = ENOTSUP;
 	return 0;
-- 
2.16.2

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

* [dpdk-dev] [PATCH 2/2] eal: fix build on FreeBSD
  2018-04-27  2:43 [dpdk-dev] [PATCH 0/2] fix compilation on FreeBSD Thomas Monjalon
  2018-04-27  2:43 ` [dpdk-dev] [PATCH 1/2] eal: fix build with glibc < 2.16 Thomas Monjalon
@ 2018-04-27  2:43 ` Thomas Monjalon
  2018-04-30 13:17   ` Aaron Conole
  2018-04-27  9:03 ` [dpdk-dev] [PATCH 0/2] fix compilation " Maxime Coquelin
  2 siblings, 1 reply; 7+ messages in thread
From: Thomas Monjalon @ 2018-04-27  2:43 UTC (permalink / raw)
  To: dev; +Cc: aconole, tredaelli

The auxiliary vector read is implemented only for Linux.
It could be done with procstat_getauxv() for FreeBSD.

Since the commit below, the auxiliary vector functions
are compiled for every architectures, including x86
which is tested with FreeBSD.

This patch is only adding a fake/empty implementation
of auxiliary vector read, for compilation on FreeBSD.

Fixes: 2ed9bf330709 ("eal: abstract away the auxiliary vector")
Cc: aconole@redhat.com
Cc: tredaelli@redhat.com

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 lib/librte_eal/bsdapp/eal/Makefile                 |  1 +
 lib/librte_eal/bsdapp/eal/eal_cpuflags.c           | 21 ++++++
 lib/librte_eal/bsdapp/eal/meson.build              |  1 +
 lib/librte_eal/common/eal_common_cpuflags.c        | 79 ----------------------
 lib/librte_eal/linuxapp/eal/Makefile               |  1 +
 .../eal/eal_cpuflags.c}                            | 47 +------------
 lib/librte_eal/linuxapp/eal/meson.build            |  1 +
 7 files changed, 26 insertions(+), 125 deletions(-)
 create mode 100644 lib/librte_eal/bsdapp/eal/eal_cpuflags.c
 copy lib/librte_eal/{common/eal_common_cpuflags.c => linuxapp/eal/eal_cpuflags.c} (61%)

diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile
index 200285e01..3fd33f1e4 100644
--- a/lib/librte_eal/bsdapp/eal/Makefile
+++ b/lib/librte_eal/bsdapp/eal/Makefile
@@ -25,6 +25,7 @@ LIBABIVER := 7
 
 # specific to bsdapp exec-env
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) := eal.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_cpuflags.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_memory.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_hugepage_info.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_thread.c
diff --git a/lib/librte_eal/bsdapp/eal/eal_cpuflags.c b/lib/librte_eal/bsdapp/eal/eal_cpuflags.c
new file mode 100644
index 000000000..69b161ea6
--- /dev/null
+++ b/lib/librte_eal/bsdapp/eal/eal_cpuflags.c
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2018 Mellanox Technologies, Ltd
+ */
+
+#include <rte_common.h>
+#include <rte_cpuflags.h>
+
+unsigned long
+rte_cpu_getauxval(unsigned long type __rte_unused)
+{
+	/* not implemented */
+	return 0;
+}
+
+int
+rte_cpu_strcmp_auxval(unsigned long type __rte_unused,
+		const char *str __rte_unused)
+{
+	/* not implemented */
+	return -1;
+}
diff --git a/lib/librte_eal/bsdapp/eal/meson.build b/lib/librte_eal/bsdapp/eal/meson.build
index 4c5611879..47e16a649 100644
--- a/lib/librte_eal/bsdapp/eal/meson.build
+++ b/lib/librte_eal/bsdapp/eal/meson.build
@@ -4,6 +4,7 @@
 env_objs = []
 env_headers = []
 env_sources = files('eal_alarm.c',
+		'eal_cpuflags.c',
 		'eal_debug.c',
 		'eal_hugepage_info.c',
 		'eal_interrupts.c',
diff --git a/lib/librte_eal/common/eal_common_cpuflags.c b/lib/librte_eal/common/eal_common_cpuflags.c
index 6a9dbaeb1..3a055f7c7 100644
--- a/lib/librte_eal/common/eal_common_cpuflags.c
+++ b/lib/librte_eal/common/eal_common_cpuflags.c
@@ -2,90 +2,11 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
-#include <elf.h>
-#include <fcntl.h>
 #include <stdio.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
-#if __GLIBC_PREREQ(2, 16)
-#include <sys/auxv.h>
-#define HAS_AUXV 1
-#endif
-#endif
 
 #include <rte_common.h>
 #include <rte_cpuflags.h>
 
-#ifndef HAS_AUXV
-static unsigned long
-getauxval(unsigned long type __rte_unused)
-{
-	errno = ENOTSUP;
-	return 0;
-}
-#endif
-
-#ifdef RTE_ARCH_64
-typedef Elf64_auxv_t Internal_Elfx_auxv_t;
-#else
-typedef Elf32_auxv_t Internal_Elfx_auxv_t;
-#endif
-
-
-/**
- * Provides a method for retrieving values from the auxiliary vector and
- * possibly running a string comparison.
- *
- * @return Always returns a result.  When the result is 0, check errno
- * to see if an error occurred during processing.
- */
-static unsigned long
-_rte_cpu_getauxval(unsigned long type, const char *str)
-{
-	unsigned long val;
-
-	errno = 0;
-	val = getauxval(type);
-
-	if (!val && (errno == ENOTSUP || errno == ENOENT)) {
-		int auxv_fd = open("/proc/self/auxv", O_RDONLY);
-		Internal_Elfx_auxv_t auxv;
-
-		if (auxv_fd == -1)
-			return 0;
-
-		errno = ENOENT;
-		while (read(auxv_fd, &auxv, sizeof(auxv)) == sizeof(auxv)) {
-			if (auxv.a_type == type) {
-				errno = 0;
-				val = auxv.a_un.a_val;
-				if (str)
-					val = strcmp((const char *)val, str);
-				break;
-			}
-		}
-		close(auxv_fd);
-	}
-
-	return val;
-}
-
-unsigned long
-rte_cpu_getauxval(unsigned long type)
-{
-	return _rte_cpu_getauxval(type, NULL);
-}
-
-int
-rte_cpu_strcmp_auxval(unsigned long type, const char *str)
-{
-	return _rte_cpu_getauxval(type, str);
-}
-
 /**
  * Checks if the machine is adequate for running the binary. If it is not, the
  * program exits with status 1.
diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile
index 45517a27b..3719ec9d7 100644
--- a/lib/librte_eal/linuxapp/eal/Makefile
+++ b/lib/librte_eal/linuxapp/eal/Makefile
@@ -30,6 +30,7 @@ endif
 
 # specific to linuxapp exec-env
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) := eal.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_cpuflags.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_hugepage_info.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_memory.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_thread.c
diff --git a/lib/librte_eal/common/eal_common_cpuflags.c b/lib/librte_eal/linuxapp/eal/eal_cpuflags.c
similarity index 61%
copy from lib/librte_eal/common/eal_common_cpuflags.c
copy to lib/librte_eal/linuxapp/eal/eal_cpuflags.c
index 6a9dbaeb1..d38296e1e 100644
--- a/lib/librte_eal/common/eal_common_cpuflags.c
+++ b/lib/librte_eal/linuxapp/eal/eal_cpuflags.c
@@ -1,10 +1,9 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2014 Intel Corporation
+ * Copyright 2018 Red Hat, Inc.
  */
 
 #include <elf.h>
 #include <fcntl.h>
-#include <stdio.h>
 #include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -17,7 +16,6 @@
 #endif
 #endif
 
-#include <rte_common.h>
 #include <rte_cpuflags.h>
 
 #ifndef HAS_AUXV
@@ -35,7 +33,6 @@ typedef Elf64_auxv_t Internal_Elfx_auxv_t;
 typedef Elf32_auxv_t Internal_Elfx_auxv_t;
 #endif
 
-
 /**
  * Provides a method for retrieving values from the auxiliary vector and
  * possibly running a string comparison.
@@ -85,45 +82,3 @@ rte_cpu_strcmp_auxval(unsigned long type, const char *str)
 {
 	return _rte_cpu_getauxval(type, str);
 }
-
-/**
- * Checks if the machine is adequate for running the binary. If it is not, the
- * program exits with status 1.
- */
-void
-rte_cpu_check_supported(void)
-{
-	if (!rte_cpu_is_supported())
-		exit(1);
-}
-
-int
-rte_cpu_is_supported(void)
-{
-	/* This is generated at compile-time by the build system */
-	static const enum rte_cpu_flag_t compile_time_flags[] = {
-			RTE_COMPILE_TIME_CPUFLAGS
-	};
-	unsigned count = RTE_DIM(compile_time_flags), i;
-	int ret;
-
-	for (i = 0; i < count; i++) {
-		ret = rte_cpu_get_flag_enabled(compile_time_flags[i]);
-
-		if (ret < 0) {
-			fprintf(stderr,
-				"ERROR: CPU feature flag lookup failed with error %d\n",
-				ret);
-			return 0;
-		}
-		if (!ret) {
-			fprintf(stderr,
-			        "ERROR: This system does not support \"%s\".\n"
-			        "Please check that RTE_MACHINE is set correctly.\n",
-			        rte_cpu_get_flag_name(compile_time_flags[i]));
-			return 0;
-		}
-	}
-
-	return 1;
-}
diff --git a/lib/librte_eal/linuxapp/eal/meson.build b/lib/librte_eal/linuxapp/eal/meson.build
index 9c0193105..cce377122 100644
--- a/lib/librte_eal/linuxapp/eal/meson.build
+++ b/lib/librte_eal/linuxapp/eal/meson.build
@@ -7,6 +7,7 @@ install_subdir('include/exec-env', install_dir: get_option('includedir'))
 env_objs = []
 env_headers = []
 env_sources = files('eal_alarm.c',
+		'eal_cpuflags.c',
 		'eal_debug.c',
 		'eal_hugepage_info.c',
 		'eal_interrupts.c',
-- 
2.16.2

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

* Re: [dpdk-dev] [PATCH 0/2] fix compilation on FreeBSD
  2018-04-27  2:43 [dpdk-dev] [PATCH 0/2] fix compilation on FreeBSD Thomas Monjalon
  2018-04-27  2:43 ` [dpdk-dev] [PATCH 1/2] eal: fix build with glibc < 2.16 Thomas Monjalon
  2018-04-27  2:43 ` [dpdk-dev] [PATCH 2/2] eal: fix build on FreeBSD Thomas Monjalon
@ 2018-04-27  9:03 ` Maxime Coquelin
  2018-04-27  9:16   ` Thomas Monjalon
  2 siblings, 1 reply; 7+ messages in thread
From: Maxime Coquelin @ 2018-04-27  9:03 UTC (permalink / raw)
  To: Thomas Monjalon, dev



On 04/27/2018 04:43 AM, Thomas Monjalon wrote:
> The compilation was broken on FreeBSD due to the commit
> for auxv, implemented only for Linux in the common files.
> 
> Thomas Monjalon (2):
>    eal: fix build with glibc < 2.16
>    eal: fix build on FreeBSD
> 
>   lib/librte_eal/bsdapp/eal/Makefile                 |  1 +
>   lib/librte_eal/bsdapp/eal/eal_cpuflags.c           | 21 ++++++
>   lib/librte_eal/bsdapp/eal/meson.build              |  1 +
>   lib/librte_eal/common/eal_common_cpuflags.c        | 79 ----------------------
>   lib/librte_eal/linuxapp/eal/Makefile               |  1 +
>   .../eal/eal_cpuflags.c}                            | 49 +-------------
>   lib/librte_eal/linuxapp/eal/meson.build            |  1 +
>   7 files changed, 27 insertions(+), 126 deletions(-)
>   create mode 100644 lib/librte_eal/bsdapp/eal/eal_cpuflags.c
>   copy lib/librte_eal/{common/eal_common_cpuflags.c => linuxapp/eal/eal_cpuflags.c} (60%)
> 

For the series:
Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Maxime

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

* Re: [dpdk-dev] [PATCH 0/2] fix compilation on FreeBSD
  2018-04-27  9:03 ` [dpdk-dev] [PATCH 0/2] fix compilation " Maxime Coquelin
@ 2018-04-27  9:16   ` Thomas Monjalon
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Monjalon @ 2018-04-27  9:16 UTC (permalink / raw)
  To: dev; +Cc: Maxime Coquelin

27/04/2018 11:03, Maxime Coquelin:
> 
> On 04/27/2018 04:43 AM, Thomas Monjalon wrote:
> > The compilation was broken on FreeBSD due to the commit
> > for auxv, implemented only for Linux in the common files.
> > 
> > Thomas Monjalon (2):
> >    eal: fix build with glibc < 2.16
> >    eal: fix build on FreeBSD
> > 
> >   lib/librte_eal/bsdapp/eal/Makefile                 |  1 +
> >   lib/librte_eal/bsdapp/eal/eal_cpuflags.c           | 21 ++++++
> >   lib/librte_eal/bsdapp/eal/meson.build              |  1 +
> >   lib/librte_eal/common/eal_common_cpuflags.c        | 79 ----------------------
> >   lib/librte_eal/linuxapp/eal/Makefile               |  1 +
> >   .../eal/eal_cpuflags.c}                            | 49 +-------------
> >   lib/librte_eal/linuxapp/eal/meson.build            |  1 +
> >   7 files changed, 27 insertions(+), 126 deletions(-)
> >   create mode 100644 lib/librte_eal/bsdapp/eal/eal_cpuflags.c
> >   copy lib/librte_eal/{common/eal_common_cpuflags.c => linuxapp/eal/eal_cpuflags.c} (60%)
> > 
> 
> For the series:
> Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Applied

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

* Re: [dpdk-dev] [PATCH 1/2] eal: fix build with glibc < 2.16
  2018-04-27  2:43 ` [dpdk-dev] [PATCH 1/2] eal: fix build with glibc < 2.16 Thomas Monjalon
@ 2018-04-30 13:13   ` Aaron Conole
  0 siblings, 0 replies; 7+ messages in thread
From: Aaron Conole @ 2018-04-30 13:13 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, tredaelli

Thomas Monjalon <thomas@monjalon.net> writes:

> The fake getauxval function does not use its parameter.
> So the compiler raised this error:
> 	lib/librte_eal/common/eal_common_cpuflags.c:25:25: error:
> 	unused parameter 'type'
>
> Fixes: 2ed9bf330709 ("eal: abstract away the auxiliary vector")
> Cc: aconole@redhat.com
> Cc: tredaelli@redhat.com
>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
Oops - sorry about that.

Acked-by: Aaron Conole <aconole@redhat.com>

>  lib/librte_eal/common/eal_common_cpuflags.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/librte_eal/common/eal_common_cpuflags.c b/lib/librte_eal/common/eal_common_cpuflags.c
> index a09667563..6a9dbaeb1 100644
> --- a/lib/librte_eal/common/eal_common_cpuflags.c
> +++ b/lib/librte_eal/common/eal_common_cpuflags.c
> @@ -22,7 +22,7 @@
>  
>  #ifndef HAS_AUXV
>  static unsigned long
> -getauxval(unsigned long type)
> +getauxval(unsigned long type __rte_unused)
>  {
>  	errno = ENOTSUP;
>  	return 0;

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

* Re: [dpdk-dev] [PATCH 2/2] eal: fix build on FreeBSD
  2018-04-27  2:43 ` [dpdk-dev] [PATCH 2/2] eal: fix build on FreeBSD Thomas Monjalon
@ 2018-04-30 13:17   ` Aaron Conole
  0 siblings, 0 replies; 7+ messages in thread
From: Aaron Conole @ 2018-04-30 13:17 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, tredaelli

Thomas Monjalon <thomas@monjalon.net> writes:

> The auxiliary vector read is implemented only for Linux.
> It could be done with procstat_getauxv() for FreeBSD.
>
> Since the commit below, the auxiliary vector functions
> are compiled for every architectures, including x86
> which is tested with FreeBSD.
>
> This patch is only adding a fake/empty implementation
> of auxiliary vector read, for compilation on FreeBSD.
>
> Fixes: 2ed9bf330709 ("eal: abstract away the auxiliary vector")
> Cc: aconole@redhat.com
> Cc: tredaelli@redhat.com
>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---

Makes sense to me.  Thanks for fixing this up, Thomas.  Sorry for
turning it sideways.  I'll make sure to test on freebsd next time.

Acked-by: Aaron Conole <aconole@redhat.com>

>  lib/librte_eal/bsdapp/eal/Makefile                 |  1 +
>  lib/librte_eal/bsdapp/eal/eal_cpuflags.c           | 21 ++++++
>  lib/librte_eal/bsdapp/eal/meson.build              |  1 +
>  lib/librte_eal/common/eal_common_cpuflags.c        | 79 ----------------------
>  lib/librte_eal/linuxapp/eal/Makefile               |  1 +
>  .../eal/eal_cpuflags.c}                            | 47 +------------
>  lib/librte_eal/linuxapp/eal/meson.build            |  1 +
>  7 files changed, 26 insertions(+), 125 deletions(-)
>  create mode 100644 lib/librte_eal/bsdapp/eal/eal_cpuflags.c
>  copy lib/librte_eal/{common/eal_common_cpuflags.c => linuxapp/eal/eal_cpuflags.c} (61%)
>
> diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile
> index 200285e01..3fd33f1e4 100644
> --- a/lib/librte_eal/bsdapp/eal/Makefile
> +++ b/lib/librte_eal/bsdapp/eal/Makefile
> @@ -25,6 +25,7 @@ LIBABIVER := 7
>  
>  # specific to bsdapp exec-env
>  SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) := eal.c
> +SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_cpuflags.c
>  SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_memory.c
>  SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_hugepage_info.c
>  SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_thread.c
> diff --git a/lib/librte_eal/bsdapp/eal/eal_cpuflags.c b/lib/librte_eal/bsdapp/eal/eal_cpuflags.c
> new file mode 100644
> index 000000000..69b161ea6
> --- /dev/null
> +++ b/lib/librte_eal/bsdapp/eal/eal_cpuflags.c
> @@ -0,0 +1,21 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright 2018 Mellanox Technologies, Ltd
> + */
> +
> +#include <rte_common.h>
> +#include <rte_cpuflags.h>
> +
> +unsigned long
> +rte_cpu_getauxval(unsigned long type __rte_unused)
> +{
> +	/* not implemented */
> +	return 0;
> +}
> +
> +int
> +rte_cpu_strcmp_auxval(unsigned long type __rte_unused,
> +		const char *str __rte_unused)
> +{
> +	/* not implemented */
> +	return -1;
> +}
> diff --git a/lib/librte_eal/bsdapp/eal/meson.build b/lib/librte_eal/bsdapp/eal/meson.build
> index 4c5611879..47e16a649 100644
> --- a/lib/librte_eal/bsdapp/eal/meson.build
> +++ b/lib/librte_eal/bsdapp/eal/meson.build
> @@ -4,6 +4,7 @@
>  env_objs = []
>  env_headers = []
>  env_sources = files('eal_alarm.c',
> +		'eal_cpuflags.c',
>  		'eal_debug.c',
>  		'eal_hugepage_info.c',
>  		'eal_interrupts.c',
> diff --git a/lib/librte_eal/common/eal_common_cpuflags.c b/lib/librte_eal/common/eal_common_cpuflags.c
> index 6a9dbaeb1..3a055f7c7 100644
> --- a/lib/librte_eal/common/eal_common_cpuflags.c
> +++ b/lib/librte_eal/common/eal_common_cpuflags.c
> @@ -2,90 +2,11 @@
>   * Copyright(c) 2010-2014 Intel Corporation
>   */
>  
> -#include <elf.h>
> -#include <fcntl.h>
>  #include <stdio.h>
> -#include <string.h>
> -#include <sys/stat.h>
> -#include <sys/types.h>
> -#include <unistd.h>
> -
> -#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
> -#if __GLIBC_PREREQ(2, 16)
> -#include <sys/auxv.h>
> -#define HAS_AUXV 1
> -#endif
> -#endif
>  
>  #include <rte_common.h>
>  #include <rte_cpuflags.h>
>  
> -#ifndef HAS_AUXV
> -static unsigned long
> -getauxval(unsigned long type __rte_unused)
> -{
> -	errno = ENOTSUP;
> -	return 0;
> -}
> -#endif
> -
> -#ifdef RTE_ARCH_64
> -typedef Elf64_auxv_t Internal_Elfx_auxv_t;
> -#else
> -typedef Elf32_auxv_t Internal_Elfx_auxv_t;
> -#endif
> -
> -
> -/**
> - * Provides a method for retrieving values from the auxiliary vector and
> - * possibly running a string comparison.
> - *
> - * @return Always returns a result.  When the result is 0, check errno
> - * to see if an error occurred during processing.
> - */
> -static unsigned long
> -_rte_cpu_getauxval(unsigned long type, const char *str)
> -{
> -	unsigned long val;
> -
> -	errno = 0;
> -	val = getauxval(type);
> -
> -	if (!val && (errno == ENOTSUP || errno == ENOENT)) {
> -		int auxv_fd = open("/proc/self/auxv", O_RDONLY);
> -		Internal_Elfx_auxv_t auxv;
> -
> -		if (auxv_fd == -1)
> -			return 0;
> -
> -		errno = ENOENT;
> -		while (read(auxv_fd, &auxv, sizeof(auxv)) == sizeof(auxv)) {
> -			if (auxv.a_type == type) {
> -				errno = 0;
> -				val = auxv.a_un.a_val;
> -				if (str)
> -					val = strcmp((const char *)val, str);
> -				break;
> -			}
> -		}
> -		close(auxv_fd);
> -	}
> -
> -	return val;
> -}
> -
> -unsigned long
> -rte_cpu_getauxval(unsigned long type)
> -{
> -	return _rte_cpu_getauxval(type, NULL);
> -}
> -
> -int
> -rte_cpu_strcmp_auxval(unsigned long type, const char *str)
> -{
> -	return _rte_cpu_getauxval(type, str);
> -}
> -
>  /**
>   * Checks if the machine is adequate for running the binary. If it is not, the
>   * program exits with status 1.
> diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile
> index 45517a27b..3719ec9d7 100644
> --- a/lib/librte_eal/linuxapp/eal/Makefile
> +++ b/lib/librte_eal/linuxapp/eal/Makefile
> @@ -30,6 +30,7 @@ endif
>  
>  # specific to linuxapp exec-env
>  SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) := eal.c
> +SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_cpuflags.c
>  SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_hugepage_info.c
>  SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_memory.c
>  SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_thread.c
> diff --git a/lib/librte_eal/common/eal_common_cpuflags.c b/lib/librte_eal/linuxapp/eal/eal_cpuflags.c
> similarity index 61%
> copy from lib/librte_eal/common/eal_common_cpuflags.c
> copy to lib/librte_eal/linuxapp/eal/eal_cpuflags.c
> index 6a9dbaeb1..d38296e1e 100644
> --- a/lib/librte_eal/common/eal_common_cpuflags.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_cpuflags.c
> @@ -1,10 +1,9 @@
>  /* SPDX-License-Identifier: BSD-3-Clause
> - * Copyright(c) 2010-2014 Intel Corporation
> + * Copyright 2018 Red Hat, Inc.
>   */
>  
>  #include <elf.h>
>  #include <fcntl.h>
> -#include <stdio.h>
>  #include <string.h>
>  #include <sys/stat.h>
>  #include <sys/types.h>
> @@ -17,7 +16,6 @@
>  #endif
>  #endif
>  
> -#include <rte_common.h>
>  #include <rte_cpuflags.h>
>  
>  #ifndef HAS_AUXV
> @@ -35,7 +33,6 @@ typedef Elf64_auxv_t Internal_Elfx_auxv_t;
>  typedef Elf32_auxv_t Internal_Elfx_auxv_t;
>  #endif
>  
> -
>  /**
>   * Provides a method for retrieving values from the auxiliary vector and
>   * possibly running a string comparison.
> @@ -85,45 +82,3 @@ rte_cpu_strcmp_auxval(unsigned long type, const char *str)
>  {
>  	return _rte_cpu_getauxval(type, str);
>  }
> -
> -/**
> - * Checks if the machine is adequate for running the binary. If it is not, the
> - * program exits with status 1.
> - */
> -void
> -rte_cpu_check_supported(void)
> -{
> -	if (!rte_cpu_is_supported())
> -		exit(1);
> -}
> -
> -int
> -rte_cpu_is_supported(void)
> -{
> -	/* This is generated at compile-time by the build system */
> -	static const enum rte_cpu_flag_t compile_time_flags[] = {
> -			RTE_COMPILE_TIME_CPUFLAGS
> -	};
> -	unsigned count = RTE_DIM(compile_time_flags), i;
> -	int ret;
> -
> -	for (i = 0; i < count; i++) {
> -		ret = rte_cpu_get_flag_enabled(compile_time_flags[i]);
> -
> -		if (ret < 0) {
> -			fprintf(stderr,
> -				"ERROR: CPU feature flag lookup failed with error %d\n",
> -				ret);
> -			return 0;
> -		}
> -		if (!ret) {
> -			fprintf(stderr,
> -			        "ERROR: This system does not support \"%s\".\n"
> -			        "Please check that RTE_MACHINE is set correctly.\n",
> -			        rte_cpu_get_flag_name(compile_time_flags[i]));
> -			return 0;
> -		}
> -	}
> -
> -	return 1;
> -}
> diff --git a/lib/librte_eal/linuxapp/eal/meson.build b/lib/librte_eal/linuxapp/eal/meson.build
> index 9c0193105..cce377122 100644
> --- a/lib/librte_eal/linuxapp/eal/meson.build
> +++ b/lib/librte_eal/linuxapp/eal/meson.build
> @@ -7,6 +7,7 @@ install_subdir('include/exec-env', install_dir: get_option('includedir'))
>  env_objs = []
>  env_headers = []
>  env_sources = files('eal_alarm.c',
> +		'eal_cpuflags.c',
>  		'eal_debug.c',
>  		'eal_hugepage_info.c',
>  		'eal_interrupts.c',

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

end of thread, other threads:[~2018-04-30 13:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-27  2:43 [dpdk-dev] [PATCH 0/2] fix compilation on FreeBSD Thomas Monjalon
2018-04-27  2:43 ` [dpdk-dev] [PATCH 1/2] eal: fix build with glibc < 2.16 Thomas Monjalon
2018-04-30 13:13   ` Aaron Conole
2018-04-27  2:43 ` [dpdk-dev] [PATCH 2/2] eal: fix build on FreeBSD Thomas Monjalon
2018-04-30 13:17   ` Aaron Conole
2018-04-27  9:03 ` [dpdk-dev] [PATCH 0/2] fix compilation " Maxime Coquelin
2018-04-27  9:16   ` Thomas Monjalon

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