Commit Graph

7917 Commits

Author SHA1 Message Date
Martin Storsjö
fd5c6d72c7 headers: Use asm() for trivial __mingw_* stdio function redirects
This avoids having to rely on inline functions.

Most of these are function calls that call another function with
exactly the same signature, these work well with a plain rename
with asm().

Some of them are cases where we used to call the more generalized
function inline, e.g. vscanf() calling __mingw_vfscanf, with
the first parameter hardcoded to stdin. When switching this to use
an asm() rename, this ends up calling __mingw_vscanf instead.

This is the case for __mingw_vscanf, __mingw_vprintf,
__mingw_vwscanf and __mingw_vwprintf; we already do have such
symbols in libmingwex.a even if they weren't actually ever
exercised before.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-27 00:29:00 +03:00
Martin Storsjö
79a80f7f4e headers: Use asm() to redirect symbols towards __ms_* stdio functions
This avoids having to rely on inline functions.

For the inline functions, in C++ we used plain C++ inline, while
we use static inline in C. (We need to use non-static inline in
C++ mode, for C++ module builds, where such stdio functions are
reexported by the C++ module.)

Using non-static inline functions can cause conflicts, if some
object files are built with __USE_MINGW_ANSI_STDIO enabled, and
others with it disabled. In such a case, both object files would
define a global comdat symbol e.g. "wprintf", and the linker would
pick either definition and use for all callers.

By redirecting the symbols with asm(), via __MINGW_ASM_CALL, there's
no conflict.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-27 00:28:56 +03:00
Martin Storsjö
f4f972fed3 crt: Use (void*) casts to silence warnings about function pointer casts
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-function-type-mismatch]
   20 |         f = (errno_t __cdecl (*)(int, long long))
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   21 |             GetProcAddress (__mingw_get_msvcrt_handle (), "_chsize_s");
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

By casting to (void*) instead, we can let the compiler do the second
cast to the target function type implicitly, and also silencing these
warnings.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-27 00:27:28 +03:00
Jacek Caban
87a12996ef widl: Updated to Wine version a4e77b33f6897d930261634c1b3ba5e4edc209f3.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2024-09-25 12:22:29 +02:00
LIU Hao
93f3505a75 winpthreads: Add missing __stdcall on lazy-binding function pointers
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-09-24 10:41:30 +08:00
Martin Storsjö
0b7a22bea5 crt: Mark _wassert with __MINGW_ATTRIB_NORETURN
This avoids warnings from Clang, pointing out that this function
could be marked noreturn.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-23 13:32:48 +03:00
LIU Hao
28f661db4b headers: Fix include guard for functiondiscoverykeys_devpkey.h
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-09-20 22:25:16 +08:00
LIU Hao
bc2e948f80 crt: Include functiondiscoverykeys.h in uuid library
Suggested-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-09-20 22:25:16 +08:00
Biswapriyo Nath
d08d56ea1f headers: Add new symbols in functiondiscoverykeys.h
Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-09-20 22:25:16 +08:00
Pali Rohár
0be496546a headers: Disable gcc warning that __INTRINSIC_PROLOG is not portable
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 inclusion  (ISO WG14 N2176 (C17) 6.10.1/4).

Disable this gcc warning via localized GCC pragmas to prevent 300 lines of
warnings for every application.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-19 13:31:36 +03:00
Biswapriyo Nath
b9cacd918c crt: Add new APIs in user32 import library
Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-09-19 15:18:25 +08:00
Martin Storsjö
663355341b crt: Regenerate Makefile.in
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-18 13:59:02 +03:00
Pali Rohár
694c52ba74 crt: Provide __p__osplatform() for all CRT import libraries
_osplatform is available only in i386 and x64 versions of msvcrt.dll,
msvcr70.dll, msvcr71.dll and msvcr80.dll.

Include emulation of __p__osplatform() functions for all other CRT
libraries, including UCRT.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-18 13:58:15 +03:00
Pali Rohár
5f9f1d2e8c crt: Provide __p__osver(), __p__winmajor(), __p__winminor() and __p__winver() for msvcr90+ and UCRT
_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.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-18 13:58:15 +03:00
Pali Rohár
811ff2774b crt: Provide __p__winver() function also for ARM msvcrt.dll import library
ARM32 and ARM64 OS system version of msvcrt.dll do not have neither _winver
global variable, nor __p__winver() function. But they have _winmajor and
_winminor global variables.

Provide __p__winver() function emulation for ARM msvcrt import library via
via values of _winmajor and _winminor global variables.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-18 13:57:43 +03:00
Martin Storsjö
d5d0722b53 crt: Regenerate Makefile.in
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-18 13:43:32 +03:00
Pali Rohár
4751f2753a crt: Define and use __p_ function for _osplatform
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 global variable
_osplatform is provided only in i386 and x64 versions of msvcr80.dll.

On ARM systems there is no _osplatform platform variable and neither
__p__osplatform() function. UCRT does not provide them for any arch.

Provide missing function __p__osplatform() for i386 and x64 versions of
msvcrt.dll, then for i386 msvcr70.dll and msvcr71.dll and change definition
of _osplatform in header file to use __p__osplatform() function.

This aligns definition with msvc and avoid referencing another global
variable from mingw-w64 header files.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-18 13:42:29 +03:00
Martin Storsjö
4a3a91e603 crt: Regenerate Makefile.in
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-18 13:39:28 +03:00
Pali Rohár
0fc345169f crt: Fix stat, _stat, _stat32, fstat, _fstat and _fstat32 for crtdll.dll builds
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 around crtdll.dll's _stat() and _fstat() functions. And then
redefining _stat, _fstat and fstat symbol aliases to the wrapper functions.

Advantage of this approach over adding #ifdef for crtdll builds into header
file for dev_t type is ABI compatibility between crtdll builds and other
CRT builds, at the expense of a bit more glue code in crtdll.dll import
library.

Note that mingw-w64 already provides custom stat() implantation which calls
_stat32() and therefore it already resolves to the correct function. No
need to update stat() function or its alias.

This change makes it possible to use stat functions from mingw-w64 header
files also with crtdll.dll library (via wrappers in crtdll import library).

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-18 13:38:52 +03:00
Pali Rohár
e81c74532a crt: Disable gcc warning for imaxdiv function alias
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 <anonymous>(long long int,  long long int)’} and ‘imaxdiv_t(intmax_t,  intmax_t)’ {aka ‘struct <anonymous>(long long int,  long long int)’} [-Wattribute-alias]
    lldiv (long long, long long);
    ^~~~~
  misc/imaxdiv.c:23:1: note: aliased declaration here
    imaxdiv(intmax_t numer, intmax_t denom)

lldiv_t and imaxdiv_t structures are compatible, they have same members,
just defined for each function separately. This is how they are defined
also in MS VC++ header files.

Warning could be avoided by using typedef between structures, but this may
cause problems for C++ applications which overloaded functions which have
lldiv_t or imaxdiv_t parameters.

So rather locally disable this warning for gcc. Current code should be OK.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-18 12:18:30 +03:00
LIU Hao
22a2510bef crt: Fix libscrnsave
1. Remove trailing whitespace.
2. Silence warnings about conversion between function pointers.
3. Silence warnings about unused parameters.
4. For 64-bit targets, parse handle values as 64-bit integers.
5. Handle `WM_ACTIVATE` properly. Previously it fell through to `WM_MOUSEMOVE`
   which worked by accident.

Reference: https://learn.microsoft.com/en-us/windows/win32/api/scrnsave/nf-scrnsave-defscreensaverproc
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-09-17 21:52:45 +08:00
Jacek Caban
20331109d1 headers: Update imported headers to current Wine version.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2024-09-17 00:47:21 +02:00
Jacek Caban
b70f247443 headers: Regenerate headers with current widl version.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2024-09-17 00:46:07 +02:00
Jacek Caban
a5027b0943 widl: Remove no longer used pathtools.c.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2024-09-17 00:44:14 +02:00
Jacek Caban
340bd632cf widl: Remove no longer needed BIN_TO_INCLUDEDIR.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2024-09-17 00:44:14 +02:00
Jacek Caban
a5150c011f widl: Update to current Wine version.
Includes adjustments to relocable patch to use upstream relocable install support.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2024-09-17 00:43:21 +02:00
Pali Rohár
a4679991ed headers: Fix wspiapi.h warning: cast between incompatible function types
When casting from function pointer which takes some parameters and returns
void to function pointer which returns non-void and may take some
parameters, then gcc throws following warning:

  warning: wspiapi.h:50:20: warning: cast between incompatible function types from ‘void (__attribute__((stdcall)) *)(struct addrinfo *)’ to ‘int (__attribute__((stdcall)) *)()’ [-Wcast-function-type]

Avoid this warning by first casting to (void(*)(void)) pointer and then to
final (FARPROC) function pointer. Casting from and to (void(*)(void)) gcc
and clang does not throw incompatible cast warnings.

See: https://gcc.gnu.org/gcc-14/porting_to.html#incompatible-pointer-types
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-17 00:11:51 +03:00
Martin Storsjö
a328601030 crt: Regenerate Makefile.in
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-14 23:32:48 +03:00
Pali Rohár
bf26669a86 crt: Define and use __p_ functions for _osver, _winmajor, _winminor and _winver
_osver, _winmajor, _winminor and _winver global variables are available
since the first crtdll.dll library up to the msvcr80.dll (both i386 and
x64), including OS system version of msvcrt.dll. ARM versions of msvcrt.dll
is missing _winver variable (but others are present). __p_ functions which
return pointers to these variables are missing just in crtdll.dll,
msvcrt10.dll and non-i386 versions of msvcrt.dll.

Provide missing __p_ functions for libraries which provides global
variables and defines _osver, _winmajor, _winminor and _winver via
__p_ functions in header files.

This aligns definitions of these version macros with msvc (which also
defines them via __p_ functions) and also with other definitions in
mingw-w64 header files (which also use __p_ functions instead of global
__MINGW_IMP_SYMBOL).

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-14 23:32:10 +03:00
Martin Storsjö
79197aa4bc crt: Regenerate Makefile.in
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-14 23:26:18 +03:00
Pali Rohár
df662961ab crt: Include __p__iob() symbol into x64 and ARM versions of msvcrt.dll
In file msvcrt.def.in is mentioned that symbol __p__iob is provided by
mingw-w64 emulation. But it is not yet. Functions __p__iob() and
__iob_func() returns same pointer to first member of _iob[] array, so
define __p__iob symbol for non-i386 builds as alias to __iob_func symbol.
Symbol __iob_func is present in all non-i386 versions of msvcrt.dll
library.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-14 23:25:11 +03:00
Pali Rohár
afea8d03f4 crt: Include __p___mb_cur_max, __p__pctype and __p__pwctype symbols into x64 and ARM versions of msvcrt.dll
In file msvcrt.def.in is mentioned that symbols __p___mb_cur_max,
__p__pctype and __p__pwctype are provided by mingw-w64 emulation, but
source files which provide them are missing in Makefile.am sections for
building msvcrt.dll import libraries. Fix this problem.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-14 23:25:11 +03:00
Pali Rohár
d60139ca1a headers: Avoid false-positive -Wconversion warnings in isnan() macro
Test case:

  #include <math.h>
  int isnan_wrapper(double value) { return isnan(value); }

Output:

  $ g++ -Wconversion -c snippet.cpp
  warning: conversion to 'float' from 'double' may alter its value
  warning: conversion to 'int' from 'double' may alter its value

First warning is caused by the fact in C++ mode __mingw_choose_expr is
using ternary operator and warning is triggered also by the case which is
not executed.

Second warning is caused by the fact that type of expression
(__builtin_trap(),x) for isnan(x) is double, but return value of
isnan_wrapper() is int. But this expression never returns.

Fix the first problem to use explicit cast for __isnan* calls which
correspondents to matched __mingw_types_compatible_p types.

And fix second problem by changing expression to something which has type
of int.

Bug: https://sourceforge.net/p/mingw-w64/bugs/481/
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-09-14 20:08:38 +08:00
Biswapriyo Nath
39e229d50e headers: Add new symbols in minwinbase.h
Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-09-13 15:50:48 +08:00
LIU Hao
26595c6e7c headers: Don't include SSE intrinsic headers for windres
Windres makes no use of SSE intrinsics, but produces warnings:

   C:/MSYS64/mingw32/lib/gcc/i686-w64-mingw32/14.2.1/include/xmmintrin.h:126: digit exceeds base
    126 |  return __extension__ (__m128){ 0.0f, 0.0f, 0.0f, 0.0f };

Reference: https://gitlab.gnome.org/GNOME/gimp/-/issues/11655
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-09-13 08:57:20 +08:00
Biswapriyo Nath
e38459032f headers: Add new _Ret macros in sal.h
Required for https://sourceforge.net/p/mingw-w64/mailman/message/58813005/

Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-09-11 22:34:41 +08:00
Biswapriyo Nath
474e2744ae headers: Add new macros in specstrings.h
Required for https://sourceforge.net/p/mingw-w64/mailman/message/58813005/

Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-09-11 22:34:40 +08:00
Pali Rohár
37a5ac28da crt: Fix atexit() function for every import library
mingw-w64 startup code already provides its own atexit() functions.
Implementation for DLL and EXE builds differs because version for DLL
builds has to be called at the time when unloading DLL library whereas
version for EXE builds is called at process termination. DLL version of
atexit() stores atexit's function pointers into own table which is called
from DLL unload hook. EXE version just calls CRT's _onexit() function.

Some msvcrt def files provide atexit function symbol without DATA keyword,
which is than exported from msvcrt import library. And so it conflicts with
the atexit symbol from startup file and makes atexit function unusable.

UCRT libraries do not have this problem because they provide atexit
function under different name _crt_atexit.

Fix msvcrt symbol conflicts by renaming atexit function to _crt_atexit in
every CRT def file. This will ensure compatibility with UCRT and also that
applications would call atexit function from mingw-w64 startup file and not
from CRT import library.

Also change atexit implementation in exe startup file to directly call
_crt_atexit() function instead of _onexit(). This will simplify usage as
UCRT does not have _onexit() function (mingw-w64 provides only _onexit
wrapper around _crt_atexit) and msvcrt's atexit() function (renamed to
_crt_atexit() in def file) is doing same thing as msvcrt _onexit().

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2024-09-11 00:13:30 +02:00
Le Philousophe
251fc7e1c3 winpthreads: Fix constructor priority to make it run first
Here is a patch which fixes bugs #988 and #992 following the commit
7b3379.

This commit introduced a new function winpthreads_init in charge of
setting up the _pthread_get_system_time_best_as_file_time and _pthread_get_tick_count_64
pointers using a runtime detection.

This function is defined with the constructor attribute. The problem is
that every static object making use of a constructor is also tagged with
this constructor attribute and the call ordering is unspecified.

For example, when linking code making use of C++11 chrono objects the
libstdc++ code is called before winpthreads_init but makes of the
clock_gettime function which causes a crash.

A minimal reproduction code can be found here in bug #992.

This bug can be fixed by setting a priority of 0 to the
winpthreads_constructor. It is then called before the static
constructors.

Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-09-10 10:02:04 +08:00
Daniel Verkamp
648f257038 dwmapi.h: Use DWMAPI in function declarations
DWMAPI was already defined by dwmapi.h, but it was not actually used
when declaring the functions in that header, so they were missing
DECLSPEC_IMPORT.

This patch replaces HRESULT WINAPI with DWMAPI, and WINBOOL WINAPI with
DWMAPI_(WINBOOL) for the DwmDefWindowProc function that does not return
HRESULT.

Signed-off-by: Daniel Verkamp <daniel@drv.nu>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-09-06 22:09:25 +08:00
Daniel Verkamp
4c2ff89b54 dwmapi.h: Add explicit DwmFlush void param
The DwmFlush() function takes zero parameters, not an undefined number
of parameters.

Signed-off-by: Daniel Verkamp <daniel@drv.nu>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-09-06 22:09:25 +08:00
Biswapriyo Nath
e33940a2ad headers: Add new symbols in wingdi.h
Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-09-06 22:09:23 +08:00
Martin Storsjö
5c63f0a966 headers: Enable _CRT_INTERNAL_PRINTF_STANDARD_ROUNDING by default
This is supported by UCRT 10.0.19041.0 and newer. Older versions
ignore the unknown flag silently.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-06 13:49:07 +03:00
Martin Storsjö
ff3f23c078 crt: Use _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS in narrow printfs
Currently, _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS only affects the
format for wide strings, but include it everywhere for consistency.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-06 13:49:07 +03:00
Martin Storsjö
b3c0901564 headers: Add missing cases of _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS for narrow printfs
Currently, _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS only affects the
format for wide strings, but include it everywhere for consistency.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-06 13:49:07 +03:00
Martin Storsjö
f7bfb9a505 headers: Add a missed case of _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS in _vscwprintf
Our _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS define contains
_CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS, which affects how
wide strings are formatted - so this should have a functional
effect, fixing an earlier inconsistency with this function.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-06 13:49:07 +03:00
Martin Storsjö
5f8ddf1c43 headers: Add the new define _CRT_INTERNAL_PRINTF_STANDARD_ROUNDING
This was added in UCRT 10.0.19041.0.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-06 13:49:07 +03:00
Biswapriyo Nath
47df1ba34c headers: Add enum operators in d2d1.h
This fixes compiler error as following.

JUCE/modules/juce_graphics/native/juce_Direct2DResources_windows.cpp:56:81:
error: assigning to 'D2D1_PRESENT_OPTIONS' from incompatible type 'unsigned int'
56 |         hwndRenderTargetProps.presentOptions = D2D1_PRESENT_OPTIONS_IMMEDIATELY | D2D1_PRESENT_OPTIONS_RETAIN_CONTENTS;
   |                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-09-05 23:03:11 +08:00
Jacek Caban
b4eadf324c headers: Import webservices.h and weakreference.idl from Wine.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2024-09-04 15:04:48 +02:00
Jacek Caban
88991b6e55 headers: Update imported headers to current Wine version.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2024-09-04 15:04:48 +02:00