|
|
c7ffa4 |
From a5c9b9278cd4fa0b61db045ed19df449f07ab139 Mon Sep 17 00:00:00 2001
|
|
|
c7ffa4 |
From: Thomas Monjalon <thomas@monjalon.net>
|
|
|
c7ffa4 |
Date: Fri, 27 Apr 2018 03:49:19 +0200
|
|
|
c7ffa4 |
Subject: [PATCH 2/2] eal: fix build on FreeBSD
|
|
|
c7ffa4 |
|
|
|
c7ffa4 |
The auxiliary vector read is implemented only for Linux.
|
|
|
c7ffa4 |
It could be done with procstat_getauxv() for FreeBSD.
|
|
|
c7ffa4 |
|
|
|
c7ffa4 |
Since the commit below, the auxiliary vector functions
|
|
|
c7ffa4 |
are compiled for every architectures, including x86
|
|
|
c7ffa4 |
which is tested with FreeBSD.
|
|
|
c7ffa4 |
|
|
|
c7ffa4 |
This patch is moving the Linux implementation in Linux directory,
|
|
|
c7ffa4 |
and adding a fake/empty implementation for FreeBSD.
|
|
|
c7ffa4 |
|
|
|
c7ffa4 |
Fixes: 2ed9bf330709 ("eal: abstract away the auxiliary vector")
|
|
|
c7ffa4 |
|
|
|
c7ffa4 |
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
|
|
|
c7ffa4 |
Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
|
|
|
c7ffa4 |
---
|
|
|
c7ffa4 |
lib/librte_eal/bsdapp/eal/Makefile | 1 +
|
|
|
c7ffa4 |
lib/librte_eal/bsdapp/eal/eal_cpuflags.c | 21 ++++++
|
|
|
c7ffa4 |
lib/librte_eal/common/eal_common_cpuflags.c | 79 -------------------
|
|
|
c7ffa4 |
lib/librte_eal/linuxapp/eal/Makefile | 1 +
|
|
|
c7ffa4 |
lib/librte_eal/linuxapp/eal/eal_cpuflags.c | 84 +++++++++++++++++++++
|
|
|
c7ffa4 |
7 files changed, 109 insertions(+), 79 deletions(-)
|
|
|
c7ffa4 |
create mode 100644 lib/librte_eal/bsdapp/eal/eal_cpuflags.c
|
|
|
c7ffa4 |
create mode 100644 lib/librte_eal/linuxapp/eal/eal_cpuflags.c
|
|
|
c7ffa4 |
|
|
|
c7ffa4 |
diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile
|
|
|
c7ffa4 |
index 200285e01..3fd33f1e4 100644
|
|
|
c7ffa4 |
--- a/lib/librte_eal/bsdapp/eal/Makefile
|
|
|
c7ffa4 |
+++ b/lib/librte_eal/bsdapp/eal/Makefile
|
|
|
c7ffa4 |
@@ -25,6 +25,7 @@ LIBABIVER := 7
|
|
|
c7ffa4 |
|
|
|
c7ffa4 |
# specific to bsdapp exec-env
|
|
|
c7ffa4 |
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) := eal.c
|
|
|
c7ffa4 |
+SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_cpuflags.c
|
|
|
c7ffa4 |
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_memory.c
|
|
|
c7ffa4 |
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_hugepage_info.c
|
|
|
c7ffa4 |
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_thread.c
|
|
|
c7ffa4 |
diff --git a/lib/librte_eal/bsdapp/eal/eal_cpuflags.c b/lib/librte_eal/bsdapp/eal/eal_cpuflags.c
|
|
|
c7ffa4 |
new file mode 100644
|
|
|
c7ffa4 |
index 000000000..69b161ea6
|
|
|
c7ffa4 |
--- /dev/null
|
|
|
c7ffa4 |
+++ b/lib/librte_eal/bsdapp/eal/eal_cpuflags.c
|
|
|
c7ffa4 |
@@ -0,0 +1,21 @@
|
|
|
c7ffa4 |
+/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
c7ffa4 |
+ * Copyright 2018 Mellanox Technologies, Ltd
|
|
|
c7ffa4 |
+ */
|
|
|
c7ffa4 |
+
|
|
|
c7ffa4 |
+#include <rte_common.h>
|
|
|
c7ffa4 |
+#include <rte_cpuflags.h>
|
|
|
c7ffa4 |
+
|
|
|
c7ffa4 |
+unsigned long
|
|
|
c7ffa4 |
+rte_cpu_getauxval(unsigned long type __rte_unused)
|
|
|
c7ffa4 |
+{
|
|
|
c7ffa4 |
+ /* not implemented */
|
|
|
c7ffa4 |
+ return 0;
|
|
|
c7ffa4 |
+}
|
|
|
c7ffa4 |
+
|
|
|
c7ffa4 |
+int
|
|
|
c7ffa4 |
+rte_cpu_strcmp_auxval(unsigned long type __rte_unused,
|
|
|
c7ffa4 |
+ const char *str __rte_unused)
|
|
|
c7ffa4 |
+{
|
|
|
c7ffa4 |
+ /* not implemented */
|
|
|
c7ffa4 |
+ return -1;
|
|
|
c7ffa4 |
+}
|
|
|
c7ffa4 |
diff --git a/lib/librte_eal/common/eal_common_cpuflags.c b/lib/librte_eal/common/eal_common_cpuflags.c
|
|
|
c7ffa4 |
index 6a9dbaeb1..3a055f7c7 100644
|
|
|
c7ffa4 |
--- a/lib/librte_eal/common/eal_common_cpuflags.c
|
|
|
c7ffa4 |
+++ b/lib/librte_eal/common/eal_common_cpuflags.c
|
|
|
c7ffa4 |
@@ -2,90 +2,11 @@
|
|
|
c7ffa4 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
c7ffa4 |
*/
|
|
|
c7ffa4 |
|
|
|
c7ffa4 |
-#include <elf.h>
|
|
|
c7ffa4 |
-#include <fcntl.h>
|
|
|
c7ffa4 |
#include <stdio.h>
|
|
|
c7ffa4 |
-#include <string.h>
|
|
|
c7ffa4 |
-#include <sys/stat.h>
|
|
|
c7ffa4 |
-#include <sys/types.h>
|
|
|
c7ffa4 |
-#include <unistd.h>
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
|
|
|
c7ffa4 |
-#if __GLIBC_PREREQ(2, 16)
|
|
|
c7ffa4 |
-#include <sys/auxv.h>
|
|
|
c7ffa4 |
-#define HAS_AUXV 1
|
|
|
c7ffa4 |
-#endif
|
|
|
c7ffa4 |
-#endif
|
|
|
c7ffa4 |
|
|
|
c7ffa4 |
#include <rte_common.h>
|
|
|
c7ffa4 |
#include <rte_cpuflags.h>
|
|
|
c7ffa4 |
|
|
|
c7ffa4 |
-#ifndef HAS_AUXV
|
|
|
c7ffa4 |
-static unsigned long
|
|
|
c7ffa4 |
-getauxval(unsigned long type __rte_unused)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- errno = ENOTSUP;
|
|
|
c7ffa4 |
- return 0;
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
-#endif
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-#ifdef RTE_ARCH_64
|
|
|
c7ffa4 |
-typedef Elf64_auxv_t Internal_Elfx_auxv_t;
|
|
|
c7ffa4 |
-#else
|
|
|
c7ffa4 |
-typedef Elf32_auxv_t Internal_Elfx_auxv_t;
|
|
|
c7ffa4 |
-#endif
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-/**
|
|
|
c7ffa4 |
- * Provides a method for retrieving values from the auxiliary vector and
|
|
|
c7ffa4 |
- * possibly running a string comparison.
|
|
|
c7ffa4 |
- *
|
|
|
c7ffa4 |
- * @return Always returns a result. When the result is 0, check errno
|
|
|
c7ffa4 |
- * to see if an error occurred during processing.
|
|
|
c7ffa4 |
- */
|
|
|
c7ffa4 |
-static unsigned long
|
|
|
c7ffa4 |
-_rte_cpu_getauxval(unsigned long type, const char *str)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- unsigned long val;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- errno = 0;
|
|
|
c7ffa4 |
- val = getauxval(type);
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (!val && (errno == ENOTSUP || errno == ENOENT)) {
|
|
|
c7ffa4 |
- int auxv_fd = open("/proc/self/auxv", O_RDONLY);
|
|
|
c7ffa4 |
- Internal_Elfx_auxv_t auxv;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- if (auxv_fd == -1)
|
|
|
c7ffa4 |
- return 0;
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- errno = ENOENT;
|
|
|
c7ffa4 |
- while (read(auxv_fd, &auxv, sizeof(auxv)) == sizeof(auxv)) {
|
|
|
c7ffa4 |
- if (auxv.a_type == type) {
|
|
|
c7ffa4 |
- errno = 0;
|
|
|
c7ffa4 |
- val = auxv.a_un.a_val;
|
|
|
c7ffa4 |
- if (str)
|
|
|
c7ffa4 |
- val = strcmp((const char *)val, str);
|
|
|
c7ffa4 |
- break;
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
- close(auxv_fd);
|
|
|
c7ffa4 |
- }
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
- return val;
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-unsigned long
|
|
|
c7ffa4 |
-rte_cpu_getauxval(unsigned long type)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- return _rte_cpu_getauxval(type, NULL);
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
-int
|
|
|
c7ffa4 |
-rte_cpu_strcmp_auxval(unsigned long type, const char *str)
|
|
|
c7ffa4 |
-{
|
|
|
c7ffa4 |
- return _rte_cpu_getauxval(type, str);
|
|
|
c7ffa4 |
-}
|
|
|
c7ffa4 |
-
|
|
|
c7ffa4 |
/**
|
|
|
c7ffa4 |
* Checks if the machine is adequate for running the binary. If it is not, the
|
|
|
c7ffa4 |
* program exits with status 1.
|
|
|
c7ffa4 |
diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile
|
|
|
c7ffa4 |
index 45517a27b..3719ec9d7 100644
|
|
|
c7ffa4 |
--- a/lib/librte_eal/linuxapp/eal/Makefile
|
|
|
c7ffa4 |
+++ b/lib/librte_eal/linuxapp/eal/Makefile
|
|
|
c7ffa4 |
@@ -30,6 +30,7 @@ endif
|
|
|
c7ffa4 |
|
|
|
c7ffa4 |
# specific to linuxapp exec-env
|
|
|
c7ffa4 |
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) := eal.c
|
|
|
c7ffa4 |
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_cpuflags.c
|
|
|
c7ffa4 |
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_hugepage_info.c
|
|
|
c7ffa4 |
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_memory.c
|
|
|
c7ffa4 |
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_thread.c
|
|
|
c7ffa4 |
diff --git a/lib/librte_eal/linuxapp/eal/eal_cpuflags.c b/lib/librte_eal/linuxapp/eal/eal_cpuflags.c
|
|
|
c7ffa4 |
new file mode 100644
|
|
|
c7ffa4 |
index 000000000..d38296e1e
|
|
|
c7ffa4 |
--- /dev/null
|
|
|
c7ffa4 |
+++ b/lib/librte_eal/linuxapp/eal/eal_cpuflags.c
|
|
|
c7ffa4 |
@@ -0,0 +1,84 @@
|
|
|
c7ffa4 |
+/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
c7ffa4 |
+ * Copyright 2018 Red Hat, Inc.
|
|
|
c7ffa4 |
+ */
|
|
|
c7ffa4 |
+
|
|
|
c7ffa4 |
+#include <elf.h>
|
|
|
c7ffa4 |
+#include <fcntl.h>
|
|
|
c7ffa4 |
+#include <string.h>
|
|
|
c7ffa4 |
+#include <sys/stat.h>
|
|
|
c7ffa4 |
+#include <sys/types.h>
|
|
|
c7ffa4 |
+#include <unistd.h>
|
|
|
c7ffa4 |
+
|
|
|
c7ffa4 |
+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
|
|
|
c7ffa4 |
+#if __GLIBC_PREREQ(2, 16)
|
|
|
c7ffa4 |
+#include <sys/auxv.h>
|
|
|
c7ffa4 |
+#define HAS_AUXV 1
|
|
|
c7ffa4 |
+#endif
|
|
|
c7ffa4 |
+#endif
|
|
|
c7ffa4 |
+
|
|
|
c7ffa4 |
+#include <rte_cpuflags.h>
|
|
|
c7ffa4 |
+
|
|
|
c7ffa4 |
+#ifndef HAS_AUXV
|
|
|
c7ffa4 |
+static unsigned long
|
|
|
c7ffa4 |
+getauxval(unsigned long type __rte_unused)
|
|
|
c7ffa4 |
+{
|
|
|
c7ffa4 |
+ errno = ENOTSUP;
|
|
|
c7ffa4 |
+ return 0;
|
|
|
c7ffa4 |
+}
|
|
|
c7ffa4 |
+#endif
|
|
|
c7ffa4 |
+
|
|
|
c7ffa4 |
+#ifdef RTE_ARCH_64
|
|
|
c7ffa4 |
+typedef Elf64_auxv_t Internal_Elfx_auxv_t;
|
|
|
c7ffa4 |
+#else
|
|
|
c7ffa4 |
+typedef Elf32_auxv_t Internal_Elfx_auxv_t;
|
|
|
c7ffa4 |
+#endif
|
|
|
c7ffa4 |
+
|
|
|
c7ffa4 |
+/**
|
|
|
c7ffa4 |
+ * Provides a method for retrieving values from the auxiliary vector and
|
|
|
c7ffa4 |
+ * possibly running a string comparison.
|
|
|
c7ffa4 |
+ *
|
|
|
c7ffa4 |
+ * @return Always returns a result. When the result is 0, check errno
|
|
|
c7ffa4 |
+ * to see if an error occurred during processing.
|
|
|
c7ffa4 |
+ */
|
|
|
c7ffa4 |
+static unsigned long
|
|
|
c7ffa4 |
+_rte_cpu_getauxval(unsigned long type, const char *str)
|
|
|
c7ffa4 |
+{
|
|
|
c7ffa4 |
+ unsigned long val;
|
|
|
c7ffa4 |
+
|
|
|
c7ffa4 |
+ errno = 0;
|
|
|
c7ffa4 |
+ val = getauxval(type);
|
|
|
c7ffa4 |
+
|
|
|
c7ffa4 |
+ if (!val && (errno == ENOTSUP || errno == ENOENT)) {
|
|
|
c7ffa4 |
+ int auxv_fd = open("/proc/self/auxv", O_RDONLY);
|
|
|
c7ffa4 |
+ Internal_Elfx_auxv_t auxv;
|
|
|
c7ffa4 |
+
|
|
|
c7ffa4 |
+ if (auxv_fd == -1)
|
|
|
c7ffa4 |
+ return 0;
|
|
|
c7ffa4 |
+
|
|
|
c7ffa4 |
+ errno = ENOENT;
|
|
|
c7ffa4 |
+ while (read(auxv_fd, &auxv, sizeof(auxv)) == sizeof(auxv)) {
|
|
|
c7ffa4 |
+ if (auxv.a_type == type) {
|
|
|
c7ffa4 |
+ errno = 0;
|
|
|
c7ffa4 |
+ val = auxv.a_un.a_val;
|
|
|
c7ffa4 |
+ if (str)
|
|
|
c7ffa4 |
+ val = strcmp((const char *)val, str);
|
|
|
c7ffa4 |
+ break;
|
|
|
c7ffa4 |
+ }
|
|
|
c7ffa4 |
+ }
|
|
|
c7ffa4 |
+ close(auxv_fd);
|
|
|
c7ffa4 |
+ }
|
|
|
c7ffa4 |
+
|
|
|
c7ffa4 |
+ return val;
|
|
|
c7ffa4 |
+}
|
|
|
c7ffa4 |
+
|
|
|
c7ffa4 |
+unsigned long
|
|
|
c7ffa4 |
+rte_cpu_getauxval(unsigned long type)
|
|
|
c7ffa4 |
+{
|
|
|
c7ffa4 |
+ return _rte_cpu_getauxval(type, NULL);
|
|
|
c7ffa4 |
+}
|
|
|
c7ffa4 |
+
|
|
|
c7ffa4 |
+int
|
|
|
c7ffa4 |
+rte_cpu_strcmp_auxval(unsigned long type, const char *str)
|
|
|
c7ffa4 |
+{
|
|
|
c7ffa4 |
+ return _rte_cpu_getauxval(type, str);
|
|
|
c7ffa4 |
+}
|
|
|
c7ffa4 |
--
|
|
|
c7ffa4 |
2.17.0
|
|
|
c7ffa4 |
|