mbox series

[v6,0/4] Fixes curses on msys2/mingw

Message ID 20201001173230.829-1-luoyonggang@gmail.com
Headers show
Series Fixes curses on msys2/mingw | expand

Message

罗勇刚(Yonggang Luo) Oct. 1, 2020, 5:32 p.m. UTC
And also convert related configure script to meson.
V5-V6
Dropping configure: Fixes ncursesw detection under msys2/mingw by convert the=
m to meson first.
That need the meson 0.56 upstream to fixes the curses detection.
Add
* configure: fixes indent of $meson setup

Yonggang Luo (4):
  configure: fixes indent of $meson setup
  curses: Fixes compiler error that complain don't have langinfo.h on
    msys2/mingw
  curses: Fixes curses compiling errors.
  win32: Simplify gmtime_r detection not depends on if  _POSIX_C_SOURCE
    are defined on msys2/mingw

 configure                 | 42 ++++-----------------------------------
 include/sysemu/os-win32.h |  4 ++--
 ui/curses.c               | 14 ++++++-------
 util/oslib-win32.c        |  4 ++--
 4 files changed, 15 insertions(+), 49 deletions(-)

--=20
2.28.0.windows.1

Comments

Paolo Bonzini Oct. 1, 2020, 5:39 p.m. UTC | #1
On 01/10/20 19:32, Yonggang Luo wrote:
> And also convert related configure script to meson.
> V5-V6
> Dropping configure: Fixes ncursesw detection under msys2/mingw by convert the=
> m to meson first.
> That need the meson 0.56 upstream to fixes the curses detection.
> Add
> * configure: fixes indent of $meson setup
> 
> Yonggang Luo (4):
>   configure: fixes indent of $meson setup
>   curses: Fixes compiler error that complain don't have langinfo.h on
>     msys2/mingw
>   curses: Fixes curses compiling errors.
>   win32: Simplify gmtime_r detection not depends on if  _POSIX_C_SOURCE
>     are defined on msys2/mingw
> 
>  configure                 | 42 ++++-----------------------------------
>  include/sysemu/os-win32.h |  4 ++--
>  ui/curses.c               | 14 ++++++-------
>  util/oslib-win32.c        |  4 ++--
>  4 files changed, 15 insertions(+), 49 deletions(-)
> 
> --=20
> 2.28.0.windows.1
> 
> 

Looks good (though there is no conversion to meson yet in this version).

Not trivial, but perhaps Gerd can take it?

Paolo
Gerd Hoffmann Oct. 2, 2020, 12:47 p.m. UTC | #2
On Thu, Oct 01, 2020 at 07:39:33PM +0200, Paolo Bonzini wrote:
> On 01/10/20 19:32, Yonggang Luo wrote:

> > And also convert related configure script to meson.

> > V5-V6

> > Dropping configure: Fixes ncursesw detection under msys2/mingw by convert the=

> > m to meson first.

> > That need the meson 0.56 upstream to fixes the curses detection.

> > Add

> > * configure: fixes indent of $meson setup

> > 

> > Yonggang Luo (4):

> >   configure: fixes indent of $meson setup

> >   curses: Fixes compiler error that complain don't have langinfo.h on

> >     msys2/mingw

> >   curses: Fixes curses compiling errors.

> >   win32: Simplify gmtime_r detection not depends on if  _POSIX_C_SOURCE

> >     are defined on msys2/mingw

> > 

> >  configure                 | 42 ++++-----------------------------------

> >  include/sysemu/os-win32.h |  4 ++--

> >  ui/curses.c               | 14 ++++++-------

> >  util/oslib-win32.c        |  4 ++--

> >  4 files changed, 15 insertions(+), 49 deletions(-)

> > 

> > --=20

> > 2.28.0.windows.1

> > 

> > 

> 

> Looks good (though there is no conversion to meson yet in this version).

> 

> Not trivial, but perhaps Gerd can take it?


Sure, series looks good.

Can't finish this today due to -ENOTIME and I'm offline next week so
this has to wait a bit in the UI patch queue ...

take care,
  Gerd
Daniel P. Berrangé Oct. 2, 2020, 3:34 p.m. UTC | #3
On Fri, Oct 02, 2020 at 01:32:27AM +0800, Yonggang Luo wrote:
> convert these line from tab to space
> 
> Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> ---
>  configure | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

Regards,
Daniel
Daniel P. Berrangé Oct. 2, 2020, 3:36 p.m. UTC | #4
On Fri, Oct 02, 2020 at 01:32:30AM +0800, Yonggang Luo wrote:
> We remove the CONFIG_LOCALTIME_R detection option in configure, and move the check
> existence of gmtime_r from configure into C header and source directly by using macro
> `_POSIX_THREAD_SAFE_FUNCTIONS`.
> Before this patch, the configure script are always assume the compiler doesn't define
> _POSIX_C_SOURCE macro at all, but that's not true, because thirdparty library such
> as ncursesw may define -D_POSIX_C_SOURCE in it's pkg-config file. And that C Flags will
> added -D_POSIX_C_SOURCE into each QEMU_CFLAGS. And that's causing the following compiling error:
> n file included from C:/work/xemu/qemu/include/qemu/osdep.h:119,
>                  from ../softmmu/main.c:25:
> C:/work/xemu/qemu/include/sysemu/os-win32.h:53:12: error: redundant redeclaration of 'gmtime_r' [-Werror=redundant-decls]
>    53 | struct tm *gmtime_r(const time_t *timep, struct tm *result);
>       |            ^~~~~~~~
> In file included from C:/work/xemu/qemu/include/qemu/osdep.h:94,
>                  from ../softmmu/main.c:25:
> C:/CI-Tools/msys64/mingw64/x86_64-w64-mingw32/include/time.h:284:36: note: previous definition of 'gmtime_r' was here
>   284 | __forceinline struct tm *__CRTDECL gmtime_r(const time_t *_Time, struct tm *_Tm) {
>       |                                    ^~~~~~~~
> In file included from C:/work/xemu/qemu/include/qemu/osdep.h:119,
>                  from ../softmmu/main.c:25:
> C:/work/xemu/qemu/include/sysemu/os-win32.h:55:12: error: redundant redeclaration of 'localtime_r' [-Werror=redundant-decls]
>    55 | struct tm *localtime_r(const time_t *timep, struct tm *result);
>       |            ^~~~~~~~~~~
> In file included from C:/work/xemu/qemu/include/qemu/osdep.h:94,
>                  from ../softmmu/main.c:25:
> C:/CI-Tools/msys64/mingw64/x86_64-w64-mingw32/include/time.h:281:36: note: previous definition of 'localtime_r' was here
>   281 | __forceinline struct tm *__CRTDECL localtime_r(const time_t *_Time, struct tm *_Tm) {
>       |                                    ^~~~~~~~~~~
> Compiling C object libcommon.fa.p/hw_gpio_zaurus.c.obj
> In file included from C:/work/xemu/qemu/include/qemu/osdep.h:119,
>                  from ../hw/i2c/smbus_slave.c:16:
> C:/work/xemu/qemu/include/sysemu/os-win32.h:53:12: error: redundant redeclaration of 'gmtime_r' [-Werror=redundant-decls]
>    53 | struct tm *gmtime_r(const time_t *timep, struct tm *result);
>       |            ^~~~~~~~
> In file included from C:/work/xemu/qemu/include/qemu/osdep.h:94,
>                  from ../hw/i2c/smbus_slave.c:16:
> C:/CI-Tools/msys64/mingw64/x86_64-w64-mingw32/include/time.h:284:36: note: previous definition of 'gmtime_r' was here
>   284 | __forceinline struct tm *__CRTDECL gmtime_r(const time_t *_Time, struct tm *_Tm) {
>       |                                    ^~~~~~~~
> In file included from C:/work/xemu/qemu/include/qemu/osdep.h:119,
>                  from ../hw/i2c/smbus_slave.c:16:
> C:/work/xemu/qemu/include/sysemu/os-win32.h:55:12: error: redundant redeclaration of 'localtime_r' [-Werror=redundant-decls]
>    55 | struct tm *localtime_r(const time_t *timep, struct tm *result);
>       |            ^~~~~~~~~~~
> In file included from C:/work/xemu/qemu/include/qemu/osdep.h:94,
>                  from ../hw/i2c/smbus_slave.c:16:
> C:/CI-Tools/msys64/mingw64/x86_64-w64-mingw32/include/time.h:281:36: note: previous definition of 'localtime_r' was here
>   281 | __forceinline struct tm *__CRTDECL localtime_r(const time_t *_Time, struct tm *_Tm) {
>       |                                    ^~~~~~~~~~~
> Compiling C object libcommon.fa.p/hw_dma_xilinx_axidma.c.obj
> 
> After this patch, whenever ncursesw or other thirdparty libraries tried to define or not
> define  _POSIX_C_SOURCE, the source will building properly. Because now, we don't make any
> assumption if _POSIX_C_SOURCE are defined. We solely relied on if the macro `_POSIX_THREAD_SAFE_FUNCTIONS`
> are defined in msys2/mingw header.
> 
> The _POSIX_THREAD_SAFE_FUNCTIONS are defined in mingw header like this:
> 
> ```
> #if defined(_POSIX_C_SOURCE) && !defined(_POSIX_THREAD_SAFE_FUNCTIONS)
> #define _POSIX_THREAD_SAFE_FUNCTIONS 200112L
> #endif
> 
> #ifdef _POSIX_THREAD_SAFE_FUNCTIONS
> __forceinline struct tm *__CRTDECL localtime_r(const time_t *_Time, struct tm *_Tm) {
>   return localtime_s(_Tm, _Time) ? NULL : _Tm;
> }
> __forceinline struct tm *__CRTDECL gmtime_r(const time_t *_Time, struct tm *_Tm) {
>   return gmtime_s(_Tm, _Time) ? NULL : _Tm;
> }
> __forceinline char *__CRTDECL ctime_r(const time_t *_Time, char *_Str) {
>   return ctime_s(_Str, 0x7fffffff, _Time) ? NULL : _Str;
> }
> __forceinline char *__CRTDECL asctime_r(const struct tm *_Tm, char * _Str) {
>   return asctime_s(_Str, 0x7fffffff, _Tm) ? NULL : _Str;
> }
> #endif
> ```
> 
> Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> ---
>  configure                 | 34 ----------------------------------
>  include/sysemu/os-win32.h |  4 ++--
>  util/oslib-win32.c        |  4 ++--
>  3 files changed, 4 insertions(+), 38 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
Daniel P. Berrangé Oct. 2, 2020, 3:38 p.m. UTC | #5
On Fri, Oct 02, 2020 at 02:47:44PM +0200, Gerd Hoffmann wrote:
> On Thu, Oct 01, 2020 at 07:39:33PM +0200, Paolo Bonzini wrote:

> > On 01/10/20 19:32, Yonggang Luo wrote:

> > > And also convert related configure script to meson.

> > > V5-V6

> > > Dropping configure: Fixes ncursesw detection under msys2/mingw by convert the=

> > > m to meson first.

> > > That need the meson 0.56 upstream to fixes the curses detection.

> > > Add

> > > * configure: fixes indent of $meson setup

> > > 

> > > Yonggang Luo (4):

> > >   configure: fixes indent of $meson setup

> > >   curses: Fixes compiler error that complain don't have langinfo.h on

> > >     msys2/mingw

> > >   curses: Fixes curses compiling errors.

> > >   win32: Simplify gmtime_r detection not depends on if  _POSIX_C_SOURCE

> > >     are defined on msys2/mingw

> > > 

> > >  configure                 | 42 ++++-----------------------------------

> > >  include/sysemu/os-win32.h |  4 ++--

> > >  ui/curses.c               | 14 ++++++-------

> > >  util/oslib-win32.c        |  4 ++--

> > >  4 files changed, 15 insertions(+), 49 deletions(-)

> > > 

> > > --=20

> > > 2.28.0.windows.1

> > > 

> > > 

> > 

> > Looks good (though there is no conversion to meson yet in this version).

> > 

> > Not trivial, but perhaps Gerd can take it?

> 

> Sure, series looks good.

> 

> Can't finish this today due to -ENOTIME and I'm offline next week so

> this has to wait a bit in the UI patch queue ...


Patch 2 needs more work I think, as its missing the corresponding
configure change.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Gerd Hoffmann Oct. 12, 2020, 6:49 a.m. UTC | #6
On Fri, Oct 02, 2020 at 04:38:01PM +0100, Daniel P. Berrangé wrote:
> On Fri, Oct 02, 2020 at 02:47:44PM +0200, Gerd Hoffmann wrote:

> > On Thu, Oct 01, 2020 at 07:39:33PM +0200, Paolo Bonzini wrote:

> > > On 01/10/20 19:32, Yonggang Luo wrote:

> > > > And also convert related configure script to meson.

> > > > V5-V6

> > > > Dropping configure: Fixes ncursesw detection under msys2/mingw by convert the=

> > > > m to meson first.

> > > > That need the meson 0.56 upstream to fixes the curses detection.

> > > > Add

> > > > * configure: fixes indent of $meson setup

> > > > 

> > > > Yonggang Luo (4):

> > > >   configure: fixes indent of $meson setup

> > > >   curses: Fixes compiler error that complain don't have langinfo.h on

> > > >     msys2/mingw

> > > >   curses: Fixes curses compiling errors.

> > > >   win32: Simplify gmtime_r detection not depends on if  _POSIX_C_SOURCE

> > > >     are defined on msys2/mingw

> > > > 

> > > >  configure                 | 42 ++++-----------------------------------

> > > >  include/sysemu/os-win32.h |  4 ++--

> > > >  ui/curses.c               | 14 ++++++-------

> > > >  util/oslib-win32.c        |  4 ++--

> > > >  4 files changed, 15 insertions(+), 49 deletions(-)

> > > > 

> > > > --=20

> > > > 2.28.0.windows.1

> > > > 

> > > > 

> > > 

> > > Looks good (though there is no conversion to meson yet in this version).

> > > 

> > > Not trivial, but perhaps Gerd can take it?

> > 

> > Sure, series looks good.

> > 

> > Can't finish this today due to -ENOTIME and I'm offline next week so

> > this has to wait a bit in the UI patch queue ...

> 

> Patch 2 needs more work I think, as its missing the corresponding

> configure change.


Also the series must be adapted to latest master, auto-rebase didn't work ...

take care,
  Gerd