eal: fix build with musl
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:11b57c6980
("eal: fix error string function") Fixes:176bb37ca6
("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>
This commit is contained in:
parent
e0ae50c687
commit
e0473c6d5b
@ -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
|
||||
|
@ -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; \
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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.
|
||||
|
@ -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_ */
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <sys/file.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <rte_errno.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)))
|
||||
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user