[v5,05/17] eal/linux: fix build with musl

Message ID 20210225182250.1149592-6-thomas@monjalon.net (mailing list archive)
State Superseded, archived
Headers
Series Alpine/musl build support |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Thomas Monjalon Feb. 25, 2021, 6:22 p.m. UTC
  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 _GNU_SOURCE is not defined,
cpu_set_t related definitions are skipped.
Note: such definitions are unneeded in eal_common_errno.c.

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>
---
 lib/librte_eal/linux/include/rte_os.h | 2 ++
 lib/librte_eal/unix/eal_file.c        | 1 +
 2 files changed, 3 insertions(+)
  

Patch

diff --git a/lib/librte_eal/linux/include/rte_os.h b/lib/librte_eal/linux/include/rte_os.h
index 390b87b3a1..f3f9982f40 100644
--- a/lib/librte_eal/linux/include/rte_os.h
+++ b/lib/librte_eal/linux/include/rte_os.h
@@ -12,6 +12,7 @@ 
 
 #include <sched.h>
 
+#ifdef _GNU_SOURCE
 typedef cpu_set_t rte_cpuset_t;
 #define RTE_CPU_AND(dst, src1, src2) CPU_AND(dst, src1, src2)
 #define RTE_CPU_OR(dst, src1, src2) CPU_OR(dst, src1, src2)
@@ -28,5 +29,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>