aboutsummaryrefslogtreecommitdiff
path: root/include/sysemu/os-win32.h
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2016-03-07 11:19:18 +0000
committerDaniel P. Berrange <berrange@redhat.com>2016-03-10 17:10:17 +0000
commitc619644067f98098dcdbc951e2dda79e97560afa (patch)
tree6187a6e5a3dc67c8a071825dec10b19d5cfce613 /include/sysemu/os-win32.h
parenta648c137383d84bc4f95696e5293978d9541a26e (diff)
downloadqemu-c619644067f98098dcdbc951e2dda79e97560afa.zip
qemu-c619644067f98098dcdbc951e2dda79e97560afa.tar.gz
qemu-c619644067f98098dcdbc951e2dda79e97560afa.tar.bz2
osdep: fix socket_error() to work with Mingw64
Historically QEMU has had a socket_error() macro that was defined to map to WSASocketError(). The os-win32.h header file would define errno constants that mapped to the WSA error constants. This worked fine with Mingw32 since its header files never defined any errno values, nor did it even provide an errno.h. So callers of socket_error() could match on traditional Exxxx constants and it would all "just work". With Mingw64 though, things work rather differently. First there is an errno.h file which defines all the traditional errno constants you'd expect from a UNIX platform. There is then a winerror.h which defined the WSA error constants. Crucially the WSAExxxx errno values in winerror.h do not match the Exxxx errno values in error.h. If QEMU had only imported winerror.h it would still work, but the qemu/osdep.h file unconditionally imports errno.h. So callers of socket_error() will get now WSAExxxx values back and compare them to the Exxx constants. This will always fail silently at runtime. To solve this QEMU needs to stop assuming the WSAExxxx constant values match the Exxx constant values. Thus the socket_error() macro is turned into a small function that re-maps WSAExxxx values into Exxx. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'include/sysemu/os-win32.h')
-rw-r--r--include/sysemu/os-win32.h27
1 files changed, 1 insertions, 26 deletions
diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h
index fbed346..239771d 100644
--- a/include/sysemu/os-win32.h
+++ b/include/sysemu/os-win32.h
@@ -29,32 +29,6 @@
#include <winsock2.h>
#include <windows.h>
-/* Workaround for older versions of MinGW. */
-#ifndef ECONNREFUSED
-# define ECONNREFUSED WSAECONNREFUSED
-#endif
-#ifndef EINPROGRESS
-# define EINPROGRESS WSAEINPROGRESS
-#endif
-#ifndef EHOSTUNREACH
-# define EHOSTUNREACH WSAEHOSTUNREACH
-#endif
-#ifndef EINTR
-# define EINTR WSAEINTR
-#endif
-#ifndef EINPROGRESS
-# define EINPROGRESS WSAEINPROGRESS
-#endif
-#ifndef ENETUNREACH
-# define ENETUNREACH WSAENETUNREACH
-#endif
-#ifndef ENOTCONN
-# define ENOTCONN WSAENOTCONN
-#endif
-#ifndef EWOULDBLOCK
-# define EWOULDBLOCK WSAEWOULDBLOCK
-#endif
-
#if defined(_WIN64)
/* On w64, setjmp is implemented by _setjmp which needs a second parameter.
* If this parameter is NULL, longjump does no stack unwinding.
@@ -80,6 +54,7 @@ struct tm *gmtime_r(const time_t *timep, struct tm *result);
struct tm *localtime_r(const time_t *timep, struct tm *result);
#endif /* CONFIG_LOCALTIME_R */
+int socket_error(void);
static inline void os_setup_signal_handling(void) {}
static inline void os_daemonize(void) {}