[dpdk-dev] [PATCH v3 3/7] eal/windows: support builing with MinGW-w64

Dmitry Kozlyuk dmitry.kozliuk at gmail.com
Tue Feb 18 01:02:25 CET 2020


Disable bundled getopt implementation and GNU extensions shim when
building in GNU environment.

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk at gmail.com>
---
 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 4be5118ce..1730d603f 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 <unistd.h>')
 	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 34852d42c..e4b50df3b 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 <sys/stat.h>
-#include <io.h>
 #include <fcntl.h>
+#include <io.h>
+#include <share.h>
+#include <sys/stat.h>
+
 #include <rte_debug.h>
 #include <rte_eal.h>
 #include <eal_memcfg.h>
diff --git a/lib/librte_eal/windows/eal/include/getopt.h b/lib/librte_eal/windows/eal/include/getopt.h
index 2eebe54e3..6f57af454 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 <getopt.h>
+#else
 #include <getopt.h>
+#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 c351f2c84..4b9117dc0 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, ...)
 {
@@ -80,6 +81,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.25.0



More information about the dev mailing list