eal/windows: support building with MinGW-w64
authorDmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Thu, 27 Feb 2020 04:25:33 +0000 (07:25 +0300)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 18 Mar 2020 00:20:08 +0000 (01:20 +0100)
Disable bundled getopt implementation and GNU extensions shim when
building in GNU environment.

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Tested-by: William Tu <u9012063@gmail.com>
Tested-by: Pallavi Kadam <pallavi.kadam@intel.com>
Acked-by: Pallavi Kadam <pallavi.kadam@intel.com>
lib/librte_eal/meson.build
lib/librte_eal/windows/eal/eal.c
lib/librte_eal/windows/eal/include/getopt.h
lib/librte_eal/windows/eal/include/rte_os.h

index 4be5118..1730d60 100644 (file)
@@ -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
index 34852d4..e4b50df 100644 (file)
@@ -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>
index 2eebe54..6f57af4 100644 (file)
 #ifndef NEED_USUAL_GETOPT
 
 /* Use system getopt */
+#ifdef RTE_TOOLCHAIN_GCC
+#include_next <getopt.h>
+#else
 #include <getopt.h>
+#endif
 
 #else /* NEED_USUAL_GETOPT */
 
index 95a19b2..e1e0378 100644 (file)
@@ -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)