From f3874012c64542a4ec967be175608214ed9a7079 Mon Sep 17 00:00:00 2001 From: Dmitry Kozlyuk Date: Thu, 27 Feb 2020 07:25:33 +0300 Subject: [PATCH] eal/windows: support building with MinGW-w64 Disable bundled getopt implementation and GNU extensions shim when building in GNU environment. Signed-off-by: Dmitry Kozlyuk Tested-by: William Tu Tested-by: Pallavi Kadam Acked-by: Pallavi Kadam --- lib/librte_eal/meson.build | 3 +++ lib/librte_eal/windows/eal/eal.c | 6 ++++-- lib/librte_eal/windows/eal/include/getopt.h | 4 ++++ lib/librte_eal/windows/eal/include/rte_os.h | 2 ++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/meson.build b/lib/librte_eal/meson.build index 4be5118ce1..1730d603fc 100644 --- a/lib/librte_eal/meson.build +++ b/lib/librte_eal/meson.build @@ -20,6 +20,9 @@ endif if cc.has_function('getentropy', prefix : '#include ') cflags += '-DRTE_LIBEAL_USE_GETENTROPY' endif +if cc.has_header('getopt.h') + cflags += ['-DHAVE_GETOPT_H', '-DHAVE_GETOPT', '-DHAVE_GETOPT_LONG'] +endif sources = common_sources + env_sources objs = common_objs + env_objs headers = common_headers + env_headers diff --git a/lib/librte_eal/windows/eal/eal.c b/lib/librte_eal/windows/eal/eal.c index 34852d42c1..e4b50df3b7 100644 --- a/lib/librte_eal/windows/eal/eal.c +++ b/lib/librte_eal/windows/eal/eal.c @@ -2,9 +2,11 @@ * Copyright(c) 2019 Intel Corporation */ -#include -#include #include +#include +#include +#include + #include #include #include diff --git a/lib/librte_eal/windows/eal/include/getopt.h b/lib/librte_eal/windows/eal/include/getopt.h index 2eebe54e35..6f57af454b 100644 --- a/lib/librte_eal/windows/eal/include/getopt.h +++ b/lib/librte_eal/windows/eal/include/getopt.h @@ -26,7 +26,11 @@ #ifndef NEED_USUAL_GETOPT /* Use system getopt */ +#ifdef RTE_TOOLCHAIN_GCC +#include_next +#else #include +#endif #else /* NEED_USUAL_GETOPT */ diff --git a/lib/librte_eal/windows/eal/include/rte_os.h b/lib/librte_eal/windows/eal/include/rte_os.h index 95a19b2d3a..e1e0378e6f 100644 --- a/lib/librte_eal/windows/eal/include/rte_os.h +++ b/lib/librte_eal/windows/eal/include/rte_os.h @@ -57,6 +57,7 @@ int eal_thread_create(pthread_t *thread); */ void eal_create_cpu_map(void); +#ifndef RTE_TOOLCHAIN_GCC static inline int asprintf(char **buffer, const char *format, ...) { @@ -83,6 +84,7 @@ asprintf(char **buffer, const char *format, ...) } return ret; } +#endif /* RTE_TOOLCHAIN_GCC */ /* cpu_set macros implementation */ #define RTE_CPU_AND(dst, src1, src2) CPU_AND(dst, src1, src2) -- 2.20.1