summaryrefslogtreecommitdiffstats
path: root/util/osdep.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2013-02-25 23:31:11 +0100
committerAlon Levy <alevy@redhat.com>2013-04-24 11:47:37 +0300
commitd3bf825e59125bc6a0accec0dca119ea0155cb82 (patch)
tree4a104664d41c423d4bd5c697b84af46cc33da71a /util/osdep.c
parente2d9c5e769d59f2bca649b8286892d49bdcfc2b1 (diff)
downloadhqemu-d3bf825e59125bc6a0accec0dca119ea0155cb82.zip
hqemu-d3bf825e59125bc6a0accec0dca119ea0155cb82.tar.gz
util: move socket_init() to osdep.c
vscclient needs to call socket_init() for portability. Moving to osdep.c since it has no internal dependency. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Alon Levy <alevy@redhat.com>
Diffstat (limited to 'util/osdep.c')
-rw-r--r--util/osdep.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/util/osdep.c b/util/osdep.c
index bd59ac9..6ae5aaf 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -406,3 +406,26 @@ bool fips_get_state(void)
return fips_enabled;
}
+#ifdef _WIN32
+static void socket_cleanup(void)
+{
+ WSACleanup();
+}
+#endif
+
+int socket_init(void)
+{
+#ifdef _WIN32
+ WSADATA Data;
+ int ret, err;
+
+ ret = WSAStartup(MAKEWORD(2, 2), &Data);
+ if (ret != 0) {
+ err = WSAGetLastError();
+ fprintf(stderr, "WSAStartup: %d\n", err);
+ return -1;
+ }
+ atexit(socket_cleanup);
+#endif
+ return 0;
+}
OpenPOWER on IntegriCloud