qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 REPOST] oslib-win32: only provide localtime_r


From: Daniel P. Berrange
Subject: Re: [Qemu-devel] [PATCH v2 REPOST] oslib-win32: only provide localtime_r/gmtime_r if missing
Date: Wed, 23 Sep 2015 09:33:24 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

On Tue, Sep 22, 2015 at 07:49:40PM +0200, Stefan Weil wrote:
> Hi,
> 
> I suggest cleaning some comments, mostly using the "official"
> spellings for MinGW and Mingw-w64.
> 
> Am 22.09.2015 um 16:13 schrieb Daniel P. Berrange:
> > The oslib-win32 file currently provides a localtime_r and
> > gmtime_r replacement unconditionally. Some versions of
> > Mingw64 would provide crude macros for localtime_r/gmtime_r
> 
> MinGW / Mingw-w64
> 
> > which QEMU takes care to disable. Latest versions of Mingw64
> 
> Mingw-w64
> 
> > now provide actual functions for localtime_r/gmtime_r, but
> > with a twist that you have to include unistd.h or pthread.h
> > before including time.h.  By luck some files in QEMU have
> > such an include order, resulting in compile errors:
> > 
> >   CC    util/osdep.o
> > In file included from include/qemu-common.h:48:0,
> >                  from util/osdep.c:48:
> > include/sysemu/os-win32.h:77:12: error: redundant redeclaration of 
> > 'gmtime_r' [-Werror=redundant-decls]
> >  struct tm *gmtime_r(const time_t *timep, struct tm *result);
> >             ^
> > In file included from include/qemu-common.h:35:0,
> >                  from util/osdep.c:48:
> > /usr/i686-w64-mingw32/sys-root/mingw/include/time.h:272:107: note: previous 
> > definition of 'gmtime_r' was here
> > In file included from include/qemu-common.h:48:0,
> >                  from util/osdep.c:48:
> > include/sysemu/os-win32.h:79:12: error: redundant redeclaration of 
> > 'localtime_r' [-Werror=redundant-decls]
> >  struct tm *localtime_r(const time_t *timep, struct tm *result);
> >             ^
> > In file included from include/qemu-common.h:35:0,
> >                  from util/osdep.c:48:
> > /usr/i686-w64-mingw32/sys-root/mingw/include/time.h:269:107: note: previous 
> > definition of 'localtime_r' was here
> > 
> > This change adds a configure test to see if localtime_r
> > exits, and only enables the QEMU impl if missing. We also
> > re-arrange qemu-common.h try attempt to guarantee that all
> > source files get unistd.h before time.h and thus see the
> > localtime_r/gmtime_r defs.
> > 
> > Signed-off-by: Daniel P. Berrange <address@hidden>
> > ---
> >  configure                 | 34 ++++++++++++++++++++++++++++++++++
> >  include/qemu/osdep.h      |  4 +++-
> >  include/sysemu/os-win32.h |  2 ++
> >  util/oslib-win32.c        |  2 ++
> >  4 files changed, 41 insertions(+), 1 deletion(-)
> > 
> > diff --git a/configure b/configure
> > index 52f5b79..4654be8 100755
> > --- a/configure
> > +++ b/configure
> > @@ -1737,6 +1737,37 @@ else
> >  fi
> >  
> >  ##########################################
> > +# Mingw64 localtime_r/gmtime_r check
> 
> MinGW / Mingw-w64
> 
> > +
> > +if test "$mingw32" = "yes"; then
> > +    # Some versions of Mingw32/64 lack localtime_r
> 
> MinGW / Mingw-w64
> 
> > +    # and gmtime_r entirely
> 
> Missing .
> 
> > +    #
> > +    # Some versions of Mingw64 define a macro for
> 
> Mingw-w64
> 
> > +    # localtime_r/gmtime_r/etc
> 
> Why etc? Missing .

They also define macros for some other functions, but they
don't cause us problems, so we're not dealing with them
here. Simpler to just remove the /etc though.

> 
> > +    #
> > +    # Some versions of Ming64 will define functions
> > +    # for localtime_r/gmtime_r, but only if you have
> > +    # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
> > +    # though, unistd.h and pthread.h both define
> > +    # that for you.
> > +    #
> > +    # So this #undef localtime_r and #include <unistd.h>
> > +    # are not in fact redundant
> 
> 
> Otherwise this patch looks good.
> 
> If you agree, I'd clean the comments before I add
> the patch to my patch queue for Windows
> (git://qemu.weilnetz.de/qemu.git wxx).

Yes, I'm fine with you applying it to your queue and adding the fixes
mentioned.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|



reply via email to

[Prev in Thread] Current Thread [Next in Thread]