qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, quintela@redhat.com, stefanha@gmail.com,
	sw@weilnetz.de, pbonzini@redhat.com,
	Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH V2 2/2] oslib-win32: add lock for localtime_r()
Date: Fri, 11 Jan 2013 18:30:27 +0800	[thread overview]
Message-ID: <1357900227-5228-2-git-send-email-xiawenc@linux.vnet.ibm.com> (raw)
In-Reply-To: <1357900227-5228-1-git-send-email-xiawenc@linux.vnet.ibm.com>

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>

---
v2:
   better comments and removed the code change localtime() to localtime_r().
---
 oslib-win32.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/oslib-win32.c b/oslib-win32.c
index 9a443da..aa1268c 100644
--- a/oslib-win32.c
+++ b/oslib-win32.c
@@ -90,15 +90,17 @@ struct tm *gmtime_r(const time_t *timep, struct tm *result)
     return p;
 }
 
-/* FIXME: add proper locking */
+/* FIXME: make it thread safe in MinGW, remove the lock in qemu. */
 struct tm *localtime_r(const time_t *timep, struct tm *result)
 {
+    g_static_mutex_lock(&time_lock);
     struct tm *p = localtime(timep);
     memset(result, 0, sizeof(*result));
     if (p) {
         *result = *p;
         p = result;
     }
+    g_static_mutex_unlock(&time_lock);
     return p;
 }
 
-- 
1.7.1

      reply	other threads:[~2013-01-11 10:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-11 10:30 [Qemu-devel] [PATCH V2 1/2] oslib-win32: add lock for gmtime_r() Wenchao Xia
2013-01-11 10:30 ` Wenchao Xia [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1357900227-5228-2-git-send-email-xiawenc@linux.vnet.ibm.com \
    --to=xiawenc@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanha@gmail.com \
    --cc=sw@weilnetz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).