From patchwork Fri Jan 11 10:30:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 211292 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 9D7422C0223 for ; Fri, 11 Jan 2013 21:32:50 +1100 (EST) Received: from localhost ([::1]:41992 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ttbuq-0002GY-NS for incoming@patchwork.ozlabs.org; Fri, 11 Jan 2013 05:32:48 -0500 Received: from eggs.gnu.org ([208.118.235.92]:54823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ttbud-0002GJ-J5 for qemu-devel@nongnu.org; Fri, 11 Jan 2013 05:32:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ttbua-0001xm-Vh for qemu-devel@nongnu.org; Fri, 11 Jan 2013 05:32:35 -0500 Received: from e28smtp03.in.ibm.com ([122.248.162.3]:33974) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ttbua-0001vk-A5 for qemu-devel@nongnu.org; Fri, 11 Jan 2013 05:32:32 -0500 Received: from /spool/local by e28smtp03.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 11 Jan 2013 16:01:11 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp03.in.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 11 Jan 2013 16:01:08 +0530 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id 55C743940051 for ; Fri, 11 Jan 2013 16:02:20 +0530 (IST) Received: from d28av05.in.ibm.com (d28av05.in.ibm.com [9.184.220.67]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r0BAWIVI20316328 for ; Fri, 11 Jan 2013 16:02:18 +0530 Received: from d28av05.in.ibm.com (loopback [127.0.0.1]) by d28av05.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r0BAWHnl020915 for ; Fri, 11 Jan 2013 21:32:18 +1100 Received: from RH63Wenchao (wenchaox.cn.ibm.com [9.115.122.237]) by d28av05.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r0BAUWfT013193; Fri, 11 Jan 2013 21:32:15 +1100 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Fri, 11 Jan 2013 18:30:26 +0800 Message-Id: <1357900227-5228-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13011110-3864-0000-0000-0000065C8C23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.3 Cc: aliguori@us.ibm.com, quintela@redhat.com, stefanha@gmail.com, sw@weilnetz.de, pbonzini@redhat.com, Wenchao Xia Subject: [Qemu-devel] [PATCH V2 1/2] oslib-win32: add lock for gmtime_r() 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 Signed-off-by: Wenchao Xia --- v2: better comments and removed the code change gmtime() to gmtime_r(). --- oslib-win32.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/oslib-win32.c b/oslib-win32.c index e7e283e..9a443da 100644 --- a/oslib-win32.c +++ b/oslib-win32.c @@ -32,6 +32,8 @@ #include "trace.h" #include "qemu/sockets.h" +static GStaticMutex time_lock = G_STATIC_MUTEX_INIT; + void *qemu_oom_check(void *ptr) { if (ptr == NULL) { @@ -74,15 +76,17 @@ void qemu_vfree(void *ptr) VirtualFree(ptr, 0, MEM_RELEASE); } -/* FIXME: add proper locking */ +/* FIXME: make it thread safe in MinGW, remove the lock in qemu. */ struct tm *gmtime_r(const time_t *timep, struct tm *result) { + g_static_mutex_lock(&time_lock); struct tm *p = gmtime(timep); memset(result, 0, sizeof(*result)); if (p) { *result = *p; p = result; } + g_static_mutex_unlock(&time_lock); return p; }