* [Qemu-devel] [PATCH V2 1/2] oslib-win32: add lock for gmtime_r()
@ 2013-01-11 10:30 Wenchao Xia
2013-01-11 10:30 ` [Qemu-devel] [PATCH V2 2/2] oslib-win32: add lock for localtime_r() Wenchao Xia
0 siblings, 1 reply; 2+ messages in thread
From: Wenchao Xia @ 2013-01-11 10:30 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, quintela, stefanha, sw, pbonzini, Wenchao Xia
Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
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;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Qemu-devel] [PATCH V2 2/2] oslib-win32: add lock for localtime_r()
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
0 siblings, 0 replies; 2+ messages in thread
From: Wenchao Xia @ 2013-01-11 10:30 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, quintela, stefanha, sw, pbonzini, Wenchao Xia
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-01-11 10:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [Qemu-devel] [PATCH V2 2/2] oslib-win32: add lock for localtime_r() Wenchao Xia
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).