From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Yonggang Luo <luoyonggang@gmail.com>
Cc: Kevin Wolf <kwolf@redhat.com>, Ed Maste <emaste@freebsd.org>,
qemu-block@nongnu.org, Stefan Weil <sw@weilnetz.de>,
Xie Changlong <xiechanglong.d@gmail.com>,
Peter Lieven <pl@kamp.de>,
qemu-devel@nongnu.org, Michael Roth <mdroth@linux.vnet.ibm.com>,
Richard Henderson <richard.henderson@linaro.org>,
Gerd Hoffmann <kraxel@redhat.com>,
Wen Congyang <wencongyang2@huawei.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Max Reitz <mreitz@redhat.com>, Li-Wen Hsu <lwhsu@freebsd.org>,
Markus Armbruster <armbru@redhat.com>
Subject: Re: [PATCH v9 04/26] win32: Simplify gmtime_r detection direct base on _POSIX_THREAD_SAFE_FUNCTIONS.
Date: Tue, 15 Sep 2020 14:00:01 +0100 [thread overview]
Message-ID: <20200915130001.GG1502912@redhat.com> (raw)
In-Reply-To: <20200915121318.247-5-luoyonggang@gmail.com>
On Tue, Sep 15, 2020 at 08:12:56PM +0800, Yonggang Luo wrote:
> First, this reduce the size of configure, configure are tending to removal in future,
> and this didn't introduce any new feature or remove any exist feature.
> Second, the current localtime_r detection are conflict with ncursesw detection in
> mingw, when ncursesw detected, it will provide the following compile flags
> pkg-config --cflags ncursesw
> -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC:/CI-Tools/msys64/mingw64/include/ncursesw
> And the compile flag _POSIX_C_SOURCE will always cause _POSIX_THREAD_SAFE_FUNCTIONS to
> be defined, in new version of mingw, that's will cause localtime_r to be defined.
> But the configure script didn't provide _POSIX_C_SOURCE macro, and that's will result
> localtime_r not detected because localtime_r are defined in forceinline manner.
ncursesw is just one of the three curses impls we can select for
building against, so it doesn't feel right to make an assumption
that _POSIX_C_SOURCE is always defined.
>
> And finally cause conflict between QEMU defined localtime_r
> struct tm *localtime_r(const time_t *timep, struct tm *result);
> with mingw defined localtime_r
>
> ```
> #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
> ```
>
> So I suggest remove this configure script, and restrict msys2/mingw version to easy to maintain.
> And use _POSIX_THREAD_SAFE_FUNCTIONS to guard the localtime_r and counterpart functions
>
> Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> ---
> configure | 34 ----------------------------------
> include/sysemu/os-win32.h | 4 ++--
> util/oslib-win32.c | 2 +-
> 3 files changed, 3 insertions(+), 37 deletions(-)
>
> diff --git a/configure b/configure
> index dc4b7a2e55..bac48b5b49 100755
> --- a/configure
> +++ b/configure
> @@ -2496,37 +2496,6 @@ if test "$vhost_net" = ""; then
> test "$vhost_kernel" = "yes" && vhost_net=yes
> fi
>
> -##########################################
> -# MinGW / Mingw-w64 localtime_r/gmtime_r check
> -
> -if test "$mingw32" = "yes"; then
> - # Some versions of MinGW / Mingw-w64 lack localtime_r
> - # and gmtime_r entirely.
> - #
> - # Some versions of Mingw-w64 define a macro for
> - # localtime_r/gmtime_r.
> - #
> - # Some versions of Mingw-w64 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.
> -cat > $TMPC << EOF
> -#include <unistd.h>
> -#include <time.h>
> -#undef localtime_r
> -int main(void) { localtime_r(NULL, NULL); return 0; }
> -EOF
> - if compile_prog "" "" ; then
> - localtime_r="yes"
> - else
> - localtime_r="no"
> - fi
> -fi
> -
> ##########################################
> # pkg-config probe
>
> @@ -7088,9 +7057,6 @@ if [ "$bsd" = "yes" ] ; then
> echo "CONFIG_BSD=y" >> $config_host_mak
> fi
>
> -if test "$localtime_r" = "yes" ; then
> - echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
> -fi
> if test "$qom_cast_debug" = "yes" ; then
> echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
> fi
> diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h
> index d8978e28c0..3ac8a53bac 100644
> --- a/include/sysemu/os-win32.h
> +++ b/include/sysemu/os-win32.h
> @@ -48,12 +48,12 @@
> #define siglongjmp(env, val) longjmp(env, val)
>
> /* Missing POSIX functions. Don't use MinGW-w64 macros. */
> -#ifndef CONFIG_LOCALTIME_R
> +#ifndef _POSIX_THREAD_SAFE_FUNCTIONS
> #undef gmtime_r
> struct tm *gmtime_r(const time_t *timep, struct tm *result);
> #undef localtime_r
> struct tm *localtime_r(const time_t *timep, struct tm *result);
> -#endif /* CONFIG_LOCALTIME_R */
> +#endif
>
> static inline void os_setup_signal_handling(void) {}
> static inline void os_daemonize(void) {}
> diff --git a/util/oslib-win32.c b/util/oslib-win32.c
> index c654dafd93..f2fa9a3549 100644
> --- a/util/oslib-win32.c
> +++ b/util/oslib-win32.c
> @@ -106,7 +106,7 @@ void qemu_anon_ram_free(void *ptr, size_t size)
> }
> }
>
> -#ifndef CONFIG_LOCALTIME_R
> +#ifndef _POSIX_THREAD_SAFE_FUNCTIONS
> /* FIXME: add proper locking */
> struct tm *gmtime_r(const time_t *timep, struct tm *result)
> {
> --
> 2.28.0.windows.1
>
>
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 :|
next prev parent reply other threads:[~2020-09-15 13:14 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-15 12:12 [PATCH v9 00/26] W32, W64 msys2/mingw patches Yonggang Luo
2020-09-15 12:12 ` [PATCH v9 01/26] rcu: Implement drain_call_rcu Yonggang Luo
2020-09-15 12:12 ` [PATCH v9 02/26] ci: fixes msys2 build by upgrading capstone to 4.0.2 Yonggang Luo
2020-09-15 12:12 ` [PATCH v9 03/26] configure: Fixes ncursesw detection under msys2/mingw and enable curses Yonggang Luo
2020-09-15 12:12 ` [PATCH v9 04/26] win32: Simplify gmtime_r detection direct base on _POSIX_THREAD_SAFE_FUNCTIONS Yonggang Luo
2020-09-15 13:00 ` Daniel P. Berrangé [this message]
2020-09-15 13:23 ` 罗勇刚(Yonggang Luo)
2020-09-15 12:12 ` [PATCH v9 05/26] curses: Fixes curses compiling errors Yonggang Luo
2020-09-15 12:12 ` [PATCH v9 06/26] tests: disable /char/stdio/* tests in test-char.c on win32 Yonggang Luo
2020-09-15 12:12 ` [PATCH v9 07/26] tests: Fixes test-replication.c on msys2/mingw Yonggang Luo
2020-09-15 12:13 ` [PATCH v9 08/26] tests: test-replication disable /replication/secondary/* " Yonggang Luo
2020-09-15 12:13 ` [PATCH v9 09/26] osdep: file locking functions are not available on Win32 Yonggang Luo
2020-09-15 12:13 ` [PATCH v9 10/26] meson: Use -b to ignore CR vs. CR-LF issues on Windows Yonggang Luo
2020-09-15 12:13 ` [PATCH v9 11/26] gcrypt: test_tls_psk_init should write binary file instead text file Yonggang Luo
2020-09-15 12:13 ` [PATCH v9 12/26] tests: Enable crypto tests under msys2/mingw Yonggang Luo
2020-09-15 13:11 ` Daniel P. Berrangé
2020-09-15 12:13 ` [PATCH v9 13/26] meson: remove empty else and duplicated gio deps Yonggang Luo
2020-09-15 12:13 ` [PATCH v9 14/26] vmstate: Fixes test-vmstate.c on msys2/mingw Yonggang Luo
2020-09-15 12:13 ` [PATCH v9 15/26] cirrus: Building freebsd in a single short Yonggang Luo
2020-09-15 12:13 ` [PATCH v9 16/26] tests: Convert g_free to g_autofree macro in test-logging.c Yonggang Luo
2020-09-15 12:13 ` [PATCH v9 17/26] tests: Fixes test-io-channel-socket.c tests under msys2/mingw Yonggang Luo
2020-09-15 12:13 ` [PATCH v9 18/26] tests: fixes aio-win32 about aio_remove_fd_handler, get it consistence with aio-posix.c Yonggang Luo
2020-09-15 12:13 ` [PATCH v9 19/26] tests: Fixes test-io-channel-file by mask only owner file state mask bits Yonggang Luo
2020-09-15 13:15 ` Daniel P. Berrangé
2020-09-15 12:13 ` [PATCH v9 20/26] tests: fix test-util-sockets.c Yonggang Luo
2020-09-15 12:13 ` [PATCH v9 21/26] tests: Fixes test-qdev-global-props.c Yonggang Luo
2020-09-15 12:13 ` [PATCH v9 22/26] rcu: fixes test-logging.c by call drain_call_rcu before rmdir_full Yonggang Luo
2020-09-15 12:13 ` [PATCH v9 23/26] meson: upgrade meson for execute custom ninjatool under msys2 properly Yonggang Luo
2020-09-15 12:13 ` [PATCH v9 24/26] ci: Enable msys2 ci in cirrus Yonggang Luo
2020-09-15 12:13 ` [PATCH v9 25/26] block: Fixes nfs compiling error on msys2/mingw Yonggang Luo
2020-09-15 12:13 ` [PATCH v9 26/26] block: enable libnfs on msys2/mingw in cirrus.yml Yonggang Luo
2020-09-15 13:00 ` [PATCH v9 00/26] W32, W64 msys2/mingw patches no-reply
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=20200915130001.GG1502912@redhat.com \
--to=berrange@redhat.com \
--cc=armbru@redhat.com \
--cc=emaste@freebsd.org \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=luoyonggang@gmail.com \
--cc=lwhsu@freebsd.org \
--cc=mdroth@linux.vnet.ibm.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=pl@kamp.de \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=sw@weilnetz.de \
--cc=wencongyang2@huawei.com \
--cc=xiechanglong.d@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.