summaryrefslogtreecommitdiffstats
path: root/include/qemu
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2016-03-07 20:25:19 +0000
committerTimothy Pearson <tpearson@raptorengineering.com>2019-11-29 19:49:36 -0600
commita5eb62c65213eeb3e0a576696e650c8cb19c8b5b (patch)
tree13dc45bac6938fd0583fd7a678011cf443918862 /include/qemu
parenta6049fb19dd122cb32b3d1b2a3eed00c5510112a (diff)
downloadhqemu-a5eb62c65213eeb3e0a576696e650c8cb19c8b5b.zip
hqemu-a5eb62c65213eeb3e0a576696e650c8cb19c8b5b.tar.gz
osdep: add wrappers for socket functions
The windows socket functions look identical to the normal POSIX sockets functions, but instead of setting errno, the caller needs to call WSAGetLastError(). QEMU has tried to deal with this incompatibility by defining a socket_error() method that callers must use that abstracts the difference between WSAGetLastError() and errno. This approach is somewhat error prone though - many callers of the sockets functions are just using errno directly because it is easy to forget the need use a QEMU specific wrapper. It is not always immediately obvious that a particular function will in fact call into Windows sockets functions, so the dev may not even realize they need to use socket_error(). This introduces an alternative approach to portability inspired by the way GNULIB fixes portability problems. We use a macro to redefine the original socket function names to refer to a QEMU wrapper function. The wrapper function calls the original Win32 sockets method and then sets errno from the WSAGetLastError() value. Thus all code can simply call the normal POSIX sockets APIs are have standard errno reporting on error, even on Windows. This makes the socket_error() method obsolete. We also bring closesocket & ioctlsocket into this approach. Even though they are non-standard Win32 names, we can't wrap the normal close/ioctl methods since there's no reliable way to distinguish between a file descriptor and HANDLE in Win32. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'include/qemu')
-rw-r--r--include/qemu/sockets.h14
1 files changed, 0 insertions, 14 deletions
diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h
index 49499f2..1bd9218 100644
--- a/include/qemu/sockets.h
+++ b/include/qemu/sockets.h
@@ -3,23 +3,9 @@
#define QEMU_SOCKET_H
#ifdef _WIN32
-#include <windows.h>
-#include <winsock2.h>
-#include <ws2tcpip.h>
int inet_aton(const char *cp, struct in_addr *ia);
-#else
-
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <sys/un.h>
-
-#define closesocket(s) close(s)
-
#endif /* !_WIN32 */
#include "qapi-types.h"
OpenPOWER on IntegriCloud