[Qemu-devel] [PATCH 14/27] slirp: improve windows headers inclusion

Marc-André Lureau posted 27 patches 6 years, 8 months ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Jason Wang <jasowang@redhat.com>, Jan Kiszka <jan.kiszka@siemens.com>, Samuel Thibault <samuel.thibault@ens-lyon.org>
[Qemu-devel] [PATCH 14/27] slirp: improve windows headers inclusion
Posted by Marc-André Lureau 6 years, 8 months ago
Our API usage requires Vista, set WIN32_LEAN_AND_MEAN to fix a number
of issues (winsock2.h include order for ex, which is better to include
first for legacy reasons).

While at it, group redundants #ifndef _WIN32 blocks.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 slirp/slirp.h | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/slirp/slirp.h b/slirp/slirp.h
index 8d9d72ca9d0..5a830ddcb86 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -3,10 +3,19 @@
 
 #ifdef _WIN32
 
+/* as defined in sdkddkver.h */
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0600 /* Vista */
+#endif
+/* reduces the number of implicitly included headers */
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+
 typedef char *caddr_t;
 
-# include <windows.h>
 # include <winsock2.h>
+# include <windows.h>
 # include <ws2tcpip.h>
 # include <sys/timeb.h>
 # include <iphlpapi.h>
@@ -19,19 +28,10 @@ typedef char *caddr_t;
 
 #ifndef _WIN32
 #include <sys/uio.h>
-#endif
-
-#ifndef _WIN32
 #include <netinet/in.h>
 #include <arpa/inet.h>
-#endif
-
-#ifndef _WIN32
 #include <sys/socket.h>
-#endif
-
-#ifndef _WIN32
-# include <sys/ioctl.h>
+#include <sys/ioctl.h>
 #endif
 
 #ifdef __APPLE__
-- 
2.20.1.98.gecbdaf0899


Re: [Qemu-devel] [PATCH 14/27] slirp: improve windows headers inclusion
Posted by Samuel Thibault 6 years, 8 months ago
Marc-André Lureau, le jeu. 17 janv. 2019 15:43:46 +0400, a ecrit:
> Our API usage requires Vista, set WIN32_LEAN_AND_MEAN to fix a number
> of issues (winsock2.h include order for ex, which is better to include
> first for legacy reasons).
> 
> While at it, group redundants #ifndef _WIN32 blocks.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Applied, thanks!