Commit Graph

7860 Commits

Author SHA1 Message Date
Biswapriyo Nath
189b6fbdfa crt: Add new APIs in cfgmgr32 import library
Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-10-12 23:11:06 +08:00
LIU Hao
50e9503928 headers/winerror: Move TBS_SUCCESS to tbs.h
45629c13ef added this macro in tbs.h, causing
a warning about redefinition:

   mingw-w64-headers/include/tbs.h:63: warning: "TBS_SUCCESS" redefined
      63 | #define TBS_SUCCESS 0

No Windows SDK has this macro in winerror.h, so this macro in winerror.h
should be removed, and the one in tbs.h is preferred.

Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-10-12 09:05:05 +08:00
Biswapriyo Nath
45629c13ef headers: Add new symbols in tbs.h
Fixes https://github.com/mingw-w64/mingw-w64/issues/62

Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-10-12 09:01:58 +08:00
Biswapriyo Nath
737142b23d crt: Add new API in tbs import library
Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-10-12 09:00:44 +08:00
Martin Storsjö
797b4a6b51 headers: Expose the wchar ctype _l functions for msvcrt.dll for Vista
The _l suffixed wchar ctype functions, such as _iswalpha_l,
are available in msvcrt.dll, but only since Vista. They're also
available in the properly versioned msvcrt versions since
msvcr80.dll.

This fixes building libc++ for msvcrt.dll, after the recent
changes in f1df976e39.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-10-12 00:55:33 +03:00
Martin Storsjö
544f756363 crt: Regenerate Makefile.in
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-10-11 11:13:26 +03:00
Pali Rohár
766949b899 crt: Rename file ucrt_compat.c to ucrt_tzset.c
Now this file contains only tzset() and _tzset() functions and
tzname/timezone/daylight global variables.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-10-11 11:13:26 +03:00
Pali Rohár
7cdac1f6d6 crt: Remove -Winline from ucrt_compat.c
In ucrt_compat.c there is no included or used inline function anymore.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-10-11 11:13:26 +03:00
Pali Rohár
bb938a7a4b crt: Split UCRT _amsg_exit() into separate file
Also add missing __MINGW_ATTRIB_NORETURN attribute into header file
internal.h where is function _amsg_exit() declared.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-10-11 11:13:26 +03:00
Pali Rohár
51f5fd310f crt: Split UCRT __ms_fwprintf() into separate file
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-10-11 11:13:26 +03:00
Pali Rohár
200b20f657 crt: Use common mingw-w64 implementation of _get_output_format() also for UCRT builds
Pre-msvcr80.dll builds, including msvcrt.dll builds use _get_output_format()
implementation from mingw-w64 output_format.c source file. Use it also for
UCRT builds instead of current stub in ucrt_compat.c.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-10-11 11:13:26 +03:00
LIU Hao
f1df976e39 headers/{ctype,wchar}: Only declare _*_l for MSVCRT >= 0x800 and UCRT
These functions and macros were added in MSVCR80.DLL and were not available
in MSVCRT.DLL from Windows XP.

This closes https://github.com/mingw-w64/mingw-w64/issues/60.

Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-10-10 21:44:55 +08:00
Pali Rohár
01b3e6261b headers: Fix compile warning: D2DERR_* redefined
For more D2DERR_* macros defined in d2derr.h, warnings is:

  In file included from mingw-w64-headers/include/d2d1.h:20,
                   from mingw-w64-headers/include/d2d1_1.h:10,
                   from libsrc/uuid.c:29:
  mingw-w64-headers/include/d2derr.h:16: warning: "D2DERR_BAD_NUMBER" redefined
   #define D2DERR_BAD_NUMBER 0x88990011

  In file included from mingw-w64-headers/include/winbase.h:2816,
                   from mingw-w64-headers/include/windows.h:70,
                   from mingw-w64-headers/include/rpc.h:16,
                   from mingw-w64-headers/include/credentialprovider.h:7,
                   from libsrc/uuid.c:17:
  mingw-w64-headers/include/winerror.h:4713: note: this is the location of the previous definition
   #define D2DERR_BAD_NUMBER                            _HRESULT_TYPEDEF_(0x88990011)

Add guards in winerror.h and d2derr.h to not define same macros multiple times.

Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-10-10 09:12:36 +08:00
Pali Rohár
3e3fc0eaf4 crt: Remove _ftime_s symbol alias from msvcrt.def.in
Header file sys/timeb_s.h defines _ftime_s only as a macro which expands
either to _ftime32_s or _ftime64_s based on _USE_32BIT_TIME_T setting.
MS VC++ 2005+ header files also defines only _ftime_s as a macro and do not
provide any _ftime_s function declaration or symbol alias in import library.

_ftime_s symbol alias is currently defined only in mingw-w64 msvcrt.def.in
file, not in any other .def file, neither in UCRT ones.

So _ftime_s symbol alias is not needed in msvcrt.def.in file, remove it.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-10-09 23:46:15 +03:00
Jacek Caban
6cd6fee9c0 headers: Update imported headers to Wine version 5b06663a59d5.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2024-10-09 16:42:14 +02:00
Biswapriyo Nath
893f14bb28 crt: Add new ioring apis
Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-10-09 22:36:19 +08:00
Biswapriyo Nath
d56dc481cf headers: Add new ioring symbols and apis
Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-10-09 22:36:19 +08:00
Jacek Caban
77eaa959e2 headers: Update imported headers to Wine version 312d442200e6403.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2024-10-08 18:24:36 +02:00
Biswapriyo Nath
8700091928 headers: Add more Set member template in HString class
This fixes the following compiler error with gecko.

mozilla-unified/widget/windows/ToastNotification.cpp:832:14: error: no matching member function for call to 'Set'
  832 |   hr = aumid.Set(mAumid.ref().get());
      |        ~~~~~~^~~
corewrappers.h:58:25: note: candidate function not viable: no known conversion from
'typename raw_type<char16_t, int>::type' (aka 'char16ptr_t') to 'const HSTRING' (aka 'HSTRING__ *const') for 1st argument
corewrappers.h:53:25: note: candidate function not viable: requires 2 arguments, but 1 was provided

Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-10-08 11:33:39 +08:00
Biswapriyo Nath
6f8b78ccf6 headers: Add HString class in corewrappers.h
Required for 0ac09833d9/intl/locale/windows/OSPreferences_win.cpp (L47)

Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-10-06 21:15:08 +08:00
Nikolay Sivov
8f7b5ce363 include: Fix ID2D1Geometry methods macros.
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-10-04 15:03:08 +08:00
LIU Hao
aa7bbd5e2d crt: Regenerate Makefile.in
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-10-04 12:07:11 +08:00
Biswapriyo Nath
f34de05bc4 crt: Add new APIs in wscapi import library
Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-10-04 12:06:09 +08:00
Biswapriyo Nath
30824af933 headers: Add wscapi.h
Required for f0b3dafb55/xpcom/base/nsSystemInfo.cpp (L34)

Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-10-03 22:17:38 +08:00
LIU Hao
39cf854b05 headers/iwscapi: Generate H from IDL
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-10-03 15:20:07 +08:00
LIU Hao
f8f3441243 headers: Regenerate Makefile.in
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-10-03 15:15:28 +08:00
Biswapriyo Nath
55a0686b04 headers: Add iwscapi.idl
Required for 7e0ae4372c/xpcom/base/nsSystemInfo.cpp (L28)

Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-10-03 15:09:25 +08:00
Biswapriyo Nath
1467c99071 headers: Add new symbols in winbase.h
Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-10-02 18:03:13 +08:00
Biswapriyo Nath
f97a2fa19a headers: Add new symbols in winnt.h
Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-10-02 11:24:56 +08:00
Jacek Caban
335ffe5b71 headers: Update imported headers to Wine version 658df7f2121d4d.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2024-09-29 21:13:07 +02:00
Jacek Caban
8fd8946db8 headers: Regenerate headers with current widl version.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2024-09-29 21:11:59 +02:00
Jacek Caban
e83d045c23 widl: Update to Wine version 658df7f2121d4d.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2024-09-29 21:11:46 +02:00
Pali Rohár
d2491a9358 crt: Provide onexit symbol alias
Now when there is working _onexit() function, provide also onexit() aliased
function, which already has declaration in stdlib.h header file.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-28 00:07:24 +03:00
Martin Storsjö
23414487df crt: Regenerate Makefile.in
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-28 00:07:24 +03:00
Pali Rohár
e36d0410e8 crt: Fix _onexit() function for DLL builds
MS documentation for _onexit function says:

  In the case when _onexit is called from within a DLL, routines registered
  with _onexit run when the DLL is unloaded, after DllMain is called with
  DLL_PROCESS_DETACH.

And for this functionality msvc statically links _onexit functionality for
DLL builds, and do not let applications to use msvcrt.dll's _onexit symbol
directly.

Fix this issue in mingw-w64 by redefining _onexit function to calls private
mingw-w64 atexit() function, which already distinguish between EXE and DLL
builds. Include this _onexit function into every CRT import library and
disable original _onexit symbol in all def files.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-28 00:05:36 +03:00
Pali Rohár
37bda501ce headers: Fix ftime function for __CRT__NO_INLINE
When __CRT__NO_INLINE is enabled then ftime function ignored the
_USE_32BIT_TIME_T settings.

Fix this problem by declaring ftime function with __MINGW_ASM_CALL
attribute with correct alias based on _USE_32BIT_TIME_T settings.

With this change the inline variant of ftime function is not needed
anymore as it was just wrapper around aliased function, which is now
correctly resolved via __MINGW_ASM_CALL.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-27 23:52:58 +03:00
Martin Storsjö
4121f43d8f crt: Regenerate Makefile.in
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-27 23:50:16 +03:00
Pali Rohár
ee481ee939 crt: Move ftime symbol definition from _ftime.c to crt-aliases.def.in
This simplify symbol definition and move it to the common place into
crt-aliases.def.in file where are also other symbol aliases.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-27 23:48:15 +03:00
Pali Rohár
41626f0d8c crt: msvcrtd.def.in: Include 64-bit fixed size and time function aliases
File msvcrtd.def.in contains only symbols from Microsoft Visual C++ 6.0
version of msvcrtd.dll as opposite of msvcrt.def.in which contains also
other symbols available in later OS system versions of msvcrt.dll versions.
There is no OS system versions of msvcrtd.dll.

File msvcrt.def.in already contains 64-bit fixed size and time function
aliases which are defined per-architecture, as msvcrt.dll contains
different set of symbols for different architectures, and so cannot use
some common aliases from include file crt-aliases.def.in.

On the other hand, msvcrtd.dll is i386-only library, fixed to VC++ 6.0
version and can use all common aliases from crt-aliases.def.in.

Currently msvcrtd.def.in do not have defined custom 64-bit fixed size and
time function aliases and neither from crt-aliases.def.in file. Fix this
problem and enable these aliases from crt-aliases.def.in file.

This change allows to use functions like _findfirst32(), _fstat32() or
_ctime32() in applications linking with msvcrtd.dll library.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-27 23:46:08 +03:00
Pali Rohár
3f7c8f53ad crt: Enable HUGE symbol alias
It is available in msvc, so enable it also in mingw-w64 import libraries

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-27 23:36:07 +03:00
Pali Rohár
469e8e419b crt: Provide __daylight(), __dstbias(), __timezone() and __tzname() functions for pre-msvcr80 builds
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.

Functions __daylight(), __dstbias() are also available in later versions of
i386 and x64 msvcrt.dll and are available in all ARM versions of msvcrt.dll.

Functions __p__daylight(), __p__timezone() and __p__tzname() are available
since msvcrt20.dll and are present in all later msvcrt versions except the
UCRT and non-i386 OS system version of msvcrt.dll.

Function __p__dstbias() is available since msvcrt40.dll and is present also
in all later msvcrt versions except the UCRT and non-i386 OS system version
of msvcrt.dll.

Global variables _daylight, _timezone and _tzname are available in all
msvcrt versions except UCRT.

Global variable _dstbias is present since msvcrt40.dll, except UCRT and
non-i386 OS system versions of msvcrt.dll.

Define __daylight, __dstbias, __timezone and __tzname for all CRT import
libraries either as aliases to __p__daylight, __p__dstbias, __p__timezone,
and __p__tzname or as function wrappers around variables _daylight,
_dstbias, _timezone and _tzname, based on what each DLL library provides.

With this change also unifies time.h file to define _daylight, _dstbias,
_timezone and _tzname for all CRT builds via functions. This removes
another ifdef _UCRT and improves ABI compatibility between UCRT and
non-UCRT builds.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-27 15:01:17 +03:00
Martin Storsjö
4517417c01 headers: Use asm() to redirect symbols towards extern __mingw vararg functions
This avoids having to rely on inline functions for capturing
the variable arguments into a va_list and passing it to the
other v- prefixed function.

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.

This also fixes https://github.com/mstorsjo/llvm-mingw/issues/438:

The fact that the inlines are non-static in C++ mode also can
cause other problems. The inline functions redirect towards the
__mingw_*printf functions, which do the formatting, and finally
call __ms_fwprintf to do the outputting. With short import libraries,
the import library redirect from __ms_fwprintf towards the imported
function fwprintf, is handled with a weak alias. But as we already
had a nonstatic function "fwprintf" (the inline function), this gets
linked and used instead of actually importing the "fwprintf" function
from msvcrt.dll.

By not using an inline function for the toplevel redirect, it doesn't
interfere with the import library __ms_fwprintf alias.

This doesn't seem to have been an issue for regular fprintf, as those
inline functions aren't wrapped in extern "C" {}, which causes the
inline function to get mangled differently, avoiding that problem.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-27 00:30:15 +03:00
Martin Storsjö
4e83914fe6 headers: Use asm() for function redirects where we already had them conditionally
For these cases, we already had a declaration with asm() for use with
the fortify inline function; use the same declaration when not using
fortify too, to simplify things.

Add the missing format attributes on these declarations.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-27 00:29:57 +03:00
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