[Mingw-w64-public] [PATCH] crt: Add new APIs in user32 import library

2024-09-18 Thread Biswapriyo Nath
From 2e8560af35032bdb0a158e3bba5d9c41a7785a1b Mon Sep 17 00:00:00 2001 From: Biswapriyo Nath Date: Thu, 19 Sep 2024 05:31:19 + Subject: [PATCH] crt: Add new APIs in user32 import library Signed-off-by: Biswapriyo Nath --- mingw-w64-crt/lib-common/user32.def.in | 20 mi

[Mingw-w64-public] [PATCH] crt: Provide __daylight(), __dstbias(), __timezone() and __tzname() functions for pre-msvcr80 builds

2024-09-18 Thread Pali Rohár
These functions return pointer to global variables with same name but without the first leading underscore. These functions are available also under name with leading "__p" prefix. Functions __daylight(), __dstbias(), __timezone() and __tzname() are available in msvcr80+ libraries and also in UCRT

Re: [Mingw-w64-public] [PATCH 2/2] crt: Add (void(*)(void)) casts to silence warnings about function pointer casts

2024-09-18 Thread Jacek Caban
On 18.09.2024 16:16, LIU Hao wrote: Maybe, but in practice it's pretty well defined behavior. Yes; my suggestion about casting via `intptr_t` also just happens to work in practice. So far there are two compilers which are known to warn sometimes about conversion between a function pointer a

Re: [Mingw-w64-public] [PATCH 2/4] headers: Disable gcc warning that __INTRINSIC_PROLOG is not portable

2024-09-18 Thread Pali Rohár
On Wednesday 18 September 2024 12:05:44 Martin Storsjö wrote: > On Sun, 15 Sep 2024, Pali Rohár wrote: > > > When compiling any application with flags under gcc 7+ with flags > > -D__MINGW_INTRIN_INLINE -Wall -Wextra, it throws about 300 lines of > > preprocessor warnings for __INTRINSIC_PROLOG us

Re: [Mingw-w64-public] [PATCH 2/2] crt: Add (void(*)(void)) casts to silence warnings about function pointer casts

2024-09-18 Thread LIU Hao
在 2024-09-18 22:07, Jacek Caban 写道: If it's just about -Wpedantic, I think we could just ignore it. For crt, we control default flags and if user explicitly specifies flags like that, a warning is not the worst thing to get... (It would be different for headers, that may be exposed to any user c

Re: [Mingw-w64-public] [PATCH 2/2] crt: Add (void(*)(void)) casts to silence warnings about function pointer casts

2024-09-18 Thread Jacek Caban
On 18.09.2024 15:25, LIU Hao wrote: 在 2024-09-18 21:02, Martin Storsjö 写道: Hmm, can you give a godbolt example or similar, for where the compilers diverge about warnings here? With Clang, I don't seem to be able to get any warnings for either casts via (void(*)(void)) or (void*), with either

Re: [Mingw-w64-public] [PATCH 2/2] crt: Add (void(*)(void)) casts to silence warnings about function pointer casts

2024-09-18 Thread LIU Hao
在 2024-09-18 21:02, Martin Storsjö 写道: Hmm, can you give a godbolt example or similar, for where the compilers diverge about warnings here? With Clang, I don't seem to be able to get any warnings for either casts via (void(*)(void)) or (void*), with either C or C++, with -Wall -Wextra -pedanti

Re: [Mingw-w64-public] [PATCH 2/2] crt: Add (void(*)(void)) casts to silence warnings about function pointer casts

2024-09-18 Thread Martin Storsjö
On Wed, 18 Sep 2024, LIU Hao wrote: 在 2024-09-18 20:36, Jacek Caban 写道: That warning seems very impractical in code dealing with GetProcAddress. In Wine, we usually just cast it to (void *), but I recall that it was problematic for mingw-w64-crt for some reason too. Maybe we could just disabl

Re: [Mingw-w64-public] [PATCH 2/2] crt: Add (void(*)(void)) casts to silence warnings about function pointer casts

2024-09-18 Thread LIU Hao
在 2024-09-18 20:36, Jacek Caban 写道: That warning seems very impractical in code dealing with GetProcAddress. In Wine, we usually just cast it to (void *), but I recall that it was problematic for mingw-w64-crt for some reason too. Maybe we could just disable that warning in the configure script?

Re: [Mingw-w64-public] [PATCH 1/2] crt: Mark _wassert with __MINGW_ATTRIB_NORETURN

2024-09-18 Thread Jacek Caban
On 18.09.2024 14:06, Martin Storsjö wrote: This avoids warnings from Clang, pointing out that this function could be marked noreturn. --- mingw-w64-crt/misc/wassert.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mingw-w64-crt/misc/wassert.c b/mingw-w64-crt/misc/wassert.c index d342048ec

Re: [Mingw-w64-public] [PATCH 2/2] crt: Add (void(*)(void)) casts to silence warnings about function pointer casts

2024-09-18 Thread Martin Storsjö
On Wed, 18 Sep 2024, Jacek Caban wrote: On 18.09.2024 14:06, Martin Storsjö wrote: Modern GCC and Clang warn for these casts, with warnings like these: ../secapi/_chsize_s.c:20:6: warning: cast from 'FARPROC' (aka 'long long (*)()') to 'errno_t ((*))(int, long long) __attribute__((cdecl))' (

Re: [Mingw-w64-public] [PATCH 2/2] crt: Add (void(*)(void)) casts to silence warnings about function pointer casts

2024-09-18 Thread Jacek Caban
On 18.09.2024 14:06, Martin Storsjö wrote: Modern GCC and Clang warn for these casts, with warnings like these: ../secapi/_chsize_s.c:20:6: warning: cast from 'FARPROC' (aka 'long long (*)()') to 'errno_t ((*))(int, long long) __attribute__((cdecl))' (aka 'int (*)(int, lo ng long)') converts t

[Mingw-w64-public] [PATCH 1/2] crt: Mark _wassert with __MINGW_ATTRIB_NORETURN

2024-09-18 Thread Martin Storsjö
This avoids warnings from Clang, pointing out that this function could be marked noreturn. --- mingw-w64-crt/misc/wassert.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mingw-w64-crt/misc/wassert.c b/mingw-w64-crt/misc/wassert.c index d342048ec..b43ddaf20 100644 --- a/mingw-w64-crt/misc/was

[Mingw-w64-public] [PATCH 2/2] crt: Add (void(*)(void)) casts to silence warnings about function pointer casts

2024-09-18 Thread Martin Storsjö
Modern GCC and Clang warn for these casts, with warnings like these: ../secapi/_chsize_s.c:20:6: warning: cast from 'FARPROC' (aka 'long long (*)()') to 'errno_t ((*))(int, long long) __attribute__((cdecl))' (aka 'int (*)(int, lo ng long)') converts to incompatible function type [-Wcast-functio

Re: [Mingw-w64-public] [PATCH] headers: Disable gcc warning that __INTRINSIC_PROLOG is not portable

2024-09-18 Thread LIU Hao
在 2024-09-18 17:16, Martin Storsjö 写道: From: Pali Rohár If the mingw-w64 headers are included in a way that doesn't mute warnings in system headers, this header causes lots of warnings like: warning: this use of "defined" may not be portable It is caused by the fact that this macro __INTRINSIC

Re: [Mingw-w64-public] [PATCH 2/3] crt: Provide __p__osver(), __p__winmajor(), __p__winminor() and __p__winver() for msvcr90+ and UCRT

2024-09-18 Thread Martin Storsjö
On Sun, 15 Sep 2024, Pali Rohár wrote: _osver, _winmajor, _winminor and _winver are exported from CRT DLL library up to the msvcr80.dll version. Add support for __p_ functions also for msvcr90+ and UCRT import libraries. --- mingw-w64-crt/Makefile.am | 27 +++--- mingw-w64-crt

Re: [Mingw-w64-public] [PATCH v2] crt: Define and use __p_ function for _osplatform

2024-09-18 Thread Martin Storsjö
On Sun, 15 Sep 2024, Pali Rohár wrote: Global variable _osplatform for i386 is provided in new versions of msvcrt.dll and then also in msvcr70.dll, msvcr71.dll and msvcr80.dll. For x64 it is provided in all msvcrt.dll and msvcr80.dll versions. Function __p__osplatform() which returns pointer to

Re: [Mingw-w64-public] [PATCH v2] crt: Fix stat, _stat, _stat32, fstat, _fstat and _fstat32 for crtdll.dll builds

2024-09-18 Thread Martin Storsjö
On Sun, 15 Sep 2024, Pali Rohár wrote: crtdll.dll's struct _stat is different than msvcrt.dll's struct _stat. crtdll.dll's dev_t type (used in struct _stat) is short but msvcrt.dll's dev_t type is unsigned int. Fix this problem by providing mingw-w64 _stat32() and _fstat32() compatible wrappers

Re: [Mingw-w64-public] [PATCH 4/4] crt: Disable gcc warning for imaxdiv function alias

2024-09-18 Thread Martin Storsjö
On Sun, 15 Sep 2024, Pali Rohár wrote: gcc 8+ throws warning during imaxdiv.c compilation: misc/imaxdiv.c:34:1: warning: ‘lldiv’ alias between functions of incompatible types ‘lldiv_t(long long int, long long int)’ {aka ‘struct (long long int, long long int)’} and ‘imaxdiv_t(intmax_t, int

[Mingw-w64-public] [PATCH] headers: Disable gcc warning that __INTRINSIC_PROLOG is not portable

2024-09-18 Thread Martin Storsjö
From: Pali Rohár If the mingw-w64 headers are included in a way that doesn't mute warnings in system headers, this header causes lots of warnings like: warning: this use of "defined" may not be portable It is caused by the fact that this macro __INTRINSIC_PROLOG uses non-portable Conditional inc

Re: [Mingw-w64-public] [PATCH 2/4] headers: Disable gcc warning that __INTRINSIC_PROLOG is not portable

2024-09-18 Thread Martin Storsjö
On Sun, 15 Sep 2024, Pali Rohár wrote: When compiling any application with flags under gcc 7+ with flags -D__MINGW_INTRIN_INLINE -Wall -Wextra, it throws about 300 lines of preprocessor warnings for __INTRINSIC_PROLOG usage: warning: this use of "defined" may not be portable This isn't actuall