summaryrefslogtreecommitdiff
path: root/oslib-win32.c
diff options
context:
space:
mode:
authorStefan Weil <sw@weilnetz.de>2012-09-22 22:26:19 +0200
committerBlue Swirl <blauwirbel@gmail.com>2012-09-23 17:09:30 +0000
commitd3e8f95753114a827f9cd8e819b1d5cc8333f76b (patch)
treec8f6703442308046bc43d6107793e9367959aa89 /oslib-win32.c
parent93b6599734f81328ee3d608f57667742cafeea72 (diff)
downloadqemu-d3e8f95753114a827f9cd8e819b1d5cc8333f76b.tar.gz
w32: Add implementation of gmtime_r, localtime_r
Those functions are missing in MinGW. Some versions of MinGW-w64 include defines for gmtime_r and localtime_r. Older versions of these macros are buggy (they return a pointer to a static variable), therefore we don't want them. Newer versions are similar to the code used here, but without the memset. The implementation which is used here is not strictly reentrant, but sufficiently good for QEMU on w32 or w64. Signed-off-by: Stefan Weil <sw@weilnetz.de> [blauwirbel@gmail.com: added comment about locking] Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'oslib-win32.c')
-rw-r--r--oslib-win32.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/oslib-win32.c b/oslib-win32.c
index ffbc6d0c9f..51b33e8b20 100644
--- a/oslib-win32.c
+++ b/oslib-win32.c
@@ -74,6 +74,30 @@ void qemu_vfree(void *ptr)
VirtualFree(ptr, 0, MEM_RELEASE);
}
+/* FIXME: add proper locking */
+struct tm *gmtime_r(const time_t *timep, struct tm *result)
+{
+ struct tm *p = gmtime(timep);
+ memset(result, 0, sizeof(*result));
+ if (p) {
+ *result = *p;
+ p = result;
+ }
+ return p;
+}
+
+/* FIXME: add proper locking */
+struct tm *localtime_r(const time_t *timep, struct tm *result)
+{
+ struct tm *p = localtime(timep);
+ memset(result, 0, sizeof(*result));
+ if (p) {
+ *result = *p;
+ p = result;
+ }
+ return p;
+}
+
void socket_set_block(int fd)
{
unsigned long opt = 0;