qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Igor Mammedov <imammedo@redhat.com>,
	Stefan Hajnoczi <stefanha@gmail.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Stefan Weil <sw@weilnetz.de>, "Denis V. Lunev" <den@openvz.org>
Subject: [Qemu-devel] [PATCH] mingw: fix build on Fedora 22
Date: Tue, 22 Sep 2015 16:38:31 +0300	[thread overview]
Message-ID: <1442928883-4119-1-git-send-email-mst@redhat.com> (raw)

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 <stefanha@gmail.com>
Cc: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 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
+#ifdef localtime_r
 #undef localtime_r
+#define QEMU_NEED_LOCALTIME_R
 struct tm *localtime_r(const time_t *timep, struct tm *result);
+#endif
 
 
 static inline void os_setup_signal_handling(void) {}
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index 730a670..abd710a 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -95,6 +95,7 @@ void qemu_anon_ram_free(void *ptr, size_t size)
     }
 }
 
+#ifdef QEMU_NEED_GMTIME_R
 /* FIXME: add proper locking */
 struct tm *gmtime_r(const time_t *timep, struct tm *result)
 {
@@ -106,7 +107,9 @@ struct tm *gmtime_r(const time_t *timep, struct tm *result)
     }
     return p;
 }
+#endif
 
+#ifdef QEMU_NEED_LOCALTIME_R
 /* FIXME: add proper locking */
 struct tm *localtime_r(const time_t *timep, struct tm *result)
 {
@@ -118,6 +121,7 @@ struct tm *localtime_r(const time_t *timep, struct tm *result)
     }
     return p;
 }
+#endif
 
 void qemu_set_block(int fd)
 {
-- 
MST

             reply	other threads:[~2015-09-22 13:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-22 13:38 Michael S. Tsirkin [this message]
2015-09-22 13:48 ` [Qemu-devel] [PATCH] mingw: fix build on Fedora 22 Daniel P. Berrange
2015-09-22 14:08   ` Michael S. Tsirkin
2015-09-22 14:14     ` Daniel P. Berrange
2015-09-22 14:09   ` Denis V. Lunev

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=1442928883-4119-1-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=den@openvz.org \
    --cc=imammedo@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=stefanha@redhat.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).