mingw on Fedora 22 replaces localtime_r and gmtime_r
macros with posix compliant functions in time.h.
These conflict with QEMU supplied ones.
Detect this and avoid overriding them.
We also need to define POSIX_C_SOURCE before including
time.h for the first time, to make sure these
are available to all users.
Reported-by: Stefan Hajnoczi <address@hidden>
Cc: Stefan Weil <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
include/qemu/osdep.h | 1 +
include/sysemu/os-win32.h | 6 ++++++
util/oslib-win32.c | 4 ++++
3 files changed, 11 insertions(+)
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index ab3c876..9920ac3 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -25,6 +25,7 @@
#ifndef QEMU_OSDEP_H
#define QEMU_OSDEP_H
+#define _POSIX_C_SOURCE 200809L
#include "config-host.h"
#include "qemu/compiler.h"
#include <stdarg.h>
diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h
index 706d85a..74230e7 100644
--- a/include/sysemu/os-win32.h
+++ b/include/sysemu/os-win32.h
@@ -72,11 +72,17 @@
#define sigsetjmp(env, savemask) setjmp(env)
#define siglongjmp(env, val) longjmp(env, val)
+#ifdef gmtime_r
/* Missing POSIX functions. Don't use MinGW-w64 macros. */
#undef gmtime_r
+#define QEMU_NEED_GMTIME_R
struct tm *gmtime_r(const time_t *timep, struct tm *result);
+#endif