patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: ncopa@alpinelinux.org, stable@dpdk.org,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
	David Marchand <david.marchand@redhat.com>,
	Bruce Richardson <bruce.richardson@intel.com>,
	Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>,
	Narcisa Ana Maria Vasile <navasile@linux.microsoft.com>,
	Dmitry Malloy <dmitrym@microsoft.com>,
	Pallavi Kadam <pallavi.kadam@intel.com>,
	Kevin Laatz <kevin.laatz@intel.com>,
	Jerin Jacob <jerin.jacob@caviumnetworks.com>,
	Ferruh Yigit <ferruh.yigit@intel.com>
Subject: [dpdk-stable] [PATCH v7 05/17] eal: fix build with musl
Date: Fri, 19 Mar 2021 15:57:18 +0100	[thread overview]
Message-ID: <20210319145730.3555384-6-thomas@monjalon.net> (raw)
In-Reply-To: <20210319145730.3555384-1-thomas@monjalon.net>

In musl libc, cpu_set_t is defined only if _GNU_SOURCE is defined.
In case _GNU_SOURCE is undefined, as in eal_common_errno.c,
it was not possible to include rte_os.h which uses cpu_set_t.

This limitation is removed: if CPU_SETSIZE is not defined,
cpu_set_t related definitions and functions are skipped.
Note: such definitions are unneeded in eal_common_errno.c.

Applications which do not define _GNU_SOURCE may miss cpu_set_t related
features on musl. Such case is detected by RTE_HAS_CPUSET being undefined,
so functions which depend on rte_cpuset_t will be unavailable.

A missing include of fcntl.h is also added.

Bugzilla ID: 35
Fixes: 11b57c698005 ("eal: fix error string function")
Fixes: 176bb37ca6f3 ("eal: introduce internal wrappers for file operations")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 doc/api/doxy-api.conf.in                | 3 ++-
 lib/librte_eal/freebsd/include/rte_os.h | 1 +
 lib/librte_eal/include/rte_lcore.h      | 4 ++++
 lib/librte_eal/include/rte_thread.h     | 4 ++++
 lib/librte_eal/linux/include/rte_os.h   | 3 +++
 lib/librte_eal/unix/eal_file.c          | 1 +
 lib/librte_eal/windows/include/sched.h  | 1 +
 lib/librte_telemetry/rte_telemetry.h    | 4 ++++
 8 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/doc/api/doxy-api.conf.in b/doc/api/doxy-api.conf.in
index 5eb31508fd..b3c5cdfeca 100644
--- a/doc/api/doxy-api.conf.in
+++ b/doc/api/doxy-api.conf.in
@@ -81,7 +81,8 @@ INPUT                   += @API_EXAMPLES@
 FILE_PATTERNS           = rte_*.h \
                           cmdline.h
 PREDEFINED              = __DOXYGEN__ \
-			   VFIO_PRESENT \
+                          RTE_HAS_CPUSET \
+                          VFIO_PRESENT \
                           __attribute__(x)=
 
 OPTIMIZE_OUTPUT_FOR_C   = YES
diff --git a/lib/librte_eal/freebsd/include/rte_os.h b/lib/librte_eal/freebsd/include/rte_os.h
index c16f2a30e9..627f0483ab 100644
--- a/lib/librte_eal/freebsd/include/rte_os.h
+++ b/lib/librte_eal/freebsd/include/rte_os.h
@@ -13,6 +13,7 @@
 #include <pthread_np.h>
 
 typedef cpuset_t rte_cpuset_t;
+#define RTE_HAS_CPUSET
 #define RTE_CPU_AND(dst, src1, src2) do \
 { \
 	cpuset_t tmp; \
diff --git a/lib/librte_eal/include/rte_lcore.h b/lib/librte_eal/include/rte_lcore.h
index 0fe0bd839c..1550b75da0 100644
--- a/lib/librte_eal/include/rte_lcore.h
+++ b/lib/librte_eal/include/rte_lcore.h
@@ -186,6 +186,8 @@ __rte_experimental
 int
 rte_lcore_to_cpu_id(int lcore_id);
 
+#ifdef RTE_HAS_CPUSET
+
 /**
  * @warning
  * @b EXPERIMENTAL: this API may change without prior notice.
@@ -200,6 +202,8 @@ __rte_experimental
 rte_cpuset_t
 rte_lcore_cpuset(unsigned int lcore_id);
 
+#endif /* RTE_HAS_CPUSET */
+
 /**
  * Test if an lcore is enabled.
  *
diff --git a/lib/librte_eal/include/rte_thread.h b/lib/librte_eal/include/rte_thread.h
index e640ea1857..ac5a89b1ad 100644
--- a/lib/librte_eal/include/rte_thread.h
+++ b/lib/librte_eal/include/rte_thread.h
@@ -25,6 +25,8 @@ extern "C" {
  */
 typedef struct eal_tls_key *rte_tls_key;
 
+#ifdef RTE_HAS_CPUSET
+
 /**
  * Set core affinity of the current thread.
  * Support both EAL and non-EAL thread and update TLS.
@@ -46,6 +48,8 @@ int rte_thread_set_affinity(rte_cpuset_t *cpusetp);
  */
 void rte_thread_get_affinity(rte_cpuset_t *cpusetp);
 
+#endif /* RTE_HAS_CPUSET */
+
 /**
  * Create a TLS data key visible to all threads in the process.
  * the created key is later used to get/set a value.
diff --git a/lib/librte_eal/linux/include/rte_os.h b/lib/librte_eal/linux/include/rte_os.h
index 390b87b3a1..1618b4df22 100644
--- a/lib/librte_eal/linux/include/rte_os.h
+++ b/lib/librte_eal/linux/include/rte_os.h
@@ -12,7 +12,9 @@
 
 #include <sched.h>
 
+#ifdef CPU_SETSIZE /* may require _GNU_SOURCE */
 typedef cpu_set_t rte_cpuset_t;
+#define RTE_HAS_CPUSET
 #define RTE_CPU_AND(dst, src1, src2) CPU_AND(dst, src1, src2)
 #define RTE_CPU_OR(dst, src1, src2) CPU_OR(dst, src1, src2)
 #define RTE_CPU_FILL(set) do \
@@ -28,5 +30,6 @@ typedef cpu_set_t rte_cpuset_t;
 	RTE_CPU_FILL(&tmp); \
 	CPU_XOR(dst, &tmp, src); \
 } while (0)
+#endif
 
 #endif /* _RTE_OS_H_ */
diff --git a/lib/librte_eal/unix/eal_file.c b/lib/librte_eal/unix/eal_file.c
index 1b26475ba4..ec554e0096 100644
--- a/lib/librte_eal/unix/eal_file.c
+++ b/lib/librte_eal/unix/eal_file.c
@@ -4,6 +4,7 @@
 
 #include <sys/file.h>
 #include <sys/mman.h>
+#include <fcntl.h>
 #include <unistd.h>
 
 #include <rte_errno.h>
diff --git a/lib/librte_eal/windows/include/sched.h b/lib/librte_eal/windows/include/sched.h
index fbe07f742c..ff572b5dcb 100644
--- a/lib/librte_eal/windows/include/sched.h
+++ b/lib/librte_eal/windows/include/sched.h
@@ -28,6 +28,7 @@ extern "C" {
 typedef struct _rte_cpuset_s {
 	long long _bits[_NUM_SETS(CPU_SETSIZE)];
 } rte_cpuset_t;
+#define RTE_HAS_CPUSET
 
 #define CPU_SET(b, s) ((s)->_bits[_WHICH_SET(b)] |= (1LL << _WHICH_BIT(b)))
 
diff --git a/lib/librte_telemetry/rte_telemetry.h b/lib/librte_telemetry/rte_telemetry.h
index f7c8534b82..027b048d78 100644
--- a/lib/librte_telemetry/rte_telemetry.h
+++ b/lib/librte_telemetry/rte_telemetry.h
@@ -292,6 +292,8 @@ __rte_experimental
 int
 rte_telemetry_register_cmd(const char *cmd, telemetry_cb fn, const char *help);
 
+#ifdef RTE_HAS_CPUSET
+
 /**
  * @internal
  * Initialize Telemetry.
@@ -314,6 +316,8 @@ int
 rte_telemetry_init(const char *runtime_dir, const char *rte_version, rte_cpuset_t *cpuset,
 		const char **err_str);
 
+#endif /* RTE_HAS_CPUSET */
+
 /**
  * Get a pointer to a container with memory allocated. The container is to be
  * used embedded within an existing telemetry dict/array.
-- 
2.30.1


  parent reply	other threads:[~2021-03-19 14:57 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190313170657.16688-1-ncopa@alpinelinux.org>
     [not found] ` <20210225182250.1149592-1-thomas@monjalon.net>
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 01/17] eal: fix comment of OS-specific header files Thomas Monjalon
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 02/17] buildtools: fix build with busybox Thomas Monjalon
2021-02-26  9:11     ` Bruce Richardson
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 03/17] build: detect execinfo library on Linux Thomas Monjalon
2021-02-26  9:08     ` Bruce Richardson
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 04/17] build: define _GNU_SOURCE globally Thomas Monjalon
2021-02-26  9:08     ` Bruce Richardson
2021-02-26  9:40       ` Thomas Monjalon
2021-02-26  9:46         ` Bruce Richardson
2021-02-26 10:04           ` Thomas Monjalon
2021-02-28 12:53             ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 05/17] eal/linux: fix build with musl Thomas Monjalon
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 06/17] drivers: fix header includes for musl Thomas Monjalon
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 08/17] bus/pci: support I/O port operations with musl Thomas Monjalon
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 09/17] bus/dpaa: fix 64-bit arch detection Thomas Monjalon
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 10/17] bus/dpaa: fix build with musl Thomas Monjalon
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 11/17] common/dpaax/caamflib: " Thomas Monjalon
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 13/17] net/cxgbe: remove use of uint type Thomas Monjalon
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 14/17] net/igc: " Thomas Monjalon
2021-02-26  0:49     ` Wang, Haiyue
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 15/17] vdpa/mlx5: replace pthread functions unavailable in musl Thomas Monjalon
2021-03-01  7:30     ` Matan Azrad
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 16/17] app/testpmd: fix build with musl Thomas Monjalon
2021-02-25 18:22   ` [dpdk-stable] [PATCH v5 17/17] examples/bbdev: fix header include for musl Thomas Monjalon
     [not found] ` <20210228125353.2436562-1-thomas@monjalon.net>
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 01/17] eal: fix comment of OS-specific header files Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 02/17] buildtools: fix build with busybox Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 03/17] build: detect execinfo library on Linux Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 04/17] build: remove redundant _GNU_SOURCE definitions Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 05/17] eal: fix build with musl Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 06/17] drivers: fix header includes for musl Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 08/17] bus/pci: support I/O port operations with musl Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 09/17] bus/dpaa: fix 64-bit arch detection Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 10/17] bus/dpaa: fix build with musl Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 11/17] common/dpaax/caamflib: " Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 13/17] net/cxgbe: remove use of uint type Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 14/17] net/igc: " Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 15/17] vdpa/mlx5: replace pthread functions unavailable in musl Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 16/17] app/testpmd: fix build with musl Thomas Monjalon
2021-02-28 12:53   ` [dpdk-stable] [PATCH v6 17/17] examples/bbdev: fix header include for musl Thomas Monjalon
     [not found] ` <20210319145730.3555384-1-thomas@monjalon.net>
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 01/17] eal: fix comment of OS-specific header files Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 02/17] buildtools: fix build with busybox Thomas Monjalon
2021-03-22  8:52     ` Kinsella, Ray
2021-03-22  8:55       ` Thomas Monjalon
2021-03-22  9:01         ` Kinsella, Ray
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 03/17] build: detect execinfo library on Linux Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 04/17] build: remove redundant _GNU_SOURCE definitions Thomas Monjalon
2021-03-19 14:57   ` Thomas Monjalon [this message]
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 07/17] common/dpaax/caamflib: fix build with musl Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 09/17] bus/dpaa: fix 64-bit arch detection Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 10/17] bus/dpaa: fix build with musl Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 11/17] bus/pci: support I/O port operations " Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 12/17] net/cxgbe: remove use of uint type Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 13/17] net/igc: " Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 14/17] vdpa/mlx5: replace pthread functions unavailable in musl Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 15/17] event/dlb: fix header includes for musl Thomas Monjalon
2021-03-19 15:47     ` McDaniel, Timothy
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 16/17] app/testpmd: fix build with musl Thomas Monjalon
2021-03-19 14:57   ` [dpdk-stable] [PATCH v7 17/17] examples/bbdev: fix header include for musl Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210319145730.3555384-6-thomas@monjalon.net \
    --to=thomas@monjalon.net \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=dmitry.kozliuk@gmail.com \
    --cc=dmitrym@microsoft.com \
    --cc=ferruh.yigit@intel.com \
    --cc=jerin.jacob@caviumnetworks.com \
    --cc=kevin.laatz@intel.com \
    --cc=navasile@linux.microsoft.com \
    --cc=ncopa@alpinelinux.org \
    --cc=pallavi.kadam@intel.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).