From patchwork Mon Apr 22 15:04:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 238574 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 58D0B2C0122 for ; Tue, 23 Apr 2013 01:14:19 +1000 (EST) Received: from localhost ([::1]:52884 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUIJg-0000Pn-MC for incoming@patchwork.ozlabs.org; Mon, 22 Apr 2013 11:06:04 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53166) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUIIt-0000Ap-1Y for qemu-devel@nongnu.org; Mon, 22 Apr 2013 11:05:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UUIIq-0001V5-Nm for qemu-devel@nongnu.org; Mon, 22 Apr 2013 11:05:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14958) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUIIq-0001Ut-Em for qemu-devel@nongnu.org; Mon, 22 Apr 2013 11:05:12 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3MF5B6p022414 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 22 Apr 2013 11:05:11 -0400 Received: from localhost.localdomain (vpn1-6-224.ams2.redhat.com [10.36.6.224]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r3MF4xGp020026; Mon, 22 Apr 2013 11:05:10 -0400 From: Alon Levy To: qemu-devel@nongnu.org Date: Mon, 22 Apr 2013 18:04:36 +0300 Message-Id: <1366643098-2566-7-git-send-email-alevy@redhat.com> In-Reply-To: <1366643098-2566-1-git-send-email-alevy@redhat.com> References: <1366643098-2566-1-git-send-email-alevy@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id r3MF5B6p022414 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: mlureau@redhat.com Subject: [Qemu-devel] [PATCH v3 06/28] util: move socket_init() to osdep.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Marc-André Lureau vscclient needs to call socket_init() for portability. Moving to osdep.c since it has no internal dependency. Signed-off-by: Marc-André Lureau --- util/osdep.c | 23 +++++++++++++++++++++++ util/qemu-sockets.c | 24 ------------------------ 2 files changed, 23 insertions(+), 24 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; +} diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 94581aa..fdd8dc4 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -974,27 +974,3 @@ int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp) qemu_opts_del(opts); return fd; } - -#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; -}