Runtime library msvcrt10.dll like crtdll.dll does not provide support for
64-bit printf/scanf modifiers. So do not define them for msvcrt10.dll too.
Signed-off-by: LIU Hao <lh_mouse@126.com>
These are CRT runtime libraries for Visual Studio 2002 and 2003. These
libraries need to be installed separately via redistributable packages.
Signed-off-by: LIU Hao <lh_mouse@126.com>
This is CRT runtime library for Visual C++ 4.0 (MSVC 10.00) and 4.1 (10.10).
It is present in every 32-bit x86 Windows as a system library.
msvcrt40.def file was generated from the original redistributable version
of Visual C++ 4.1 library.
Signed-off-by: LIU Hao <lh_mouse@126.com>
This is CRT runtime library for Visual C++ 2.0 (MSVC 9.00) and is present
in every 32-bit x86 Windows as a system library.
Signed-off-by: LIU Hao <lh_mouse@126.com>
This is CRT runtime library for Visual C++ 1.x (MSVC 8.00). It should be
distributed as a part of the application which use it. msvcrt10.def file
was generated from the original redistributable version of this library.
Signed-off-by: LIU Hao <lh_mouse@126.com>
crtdll.dll and ucrt needs same implementation of __initenv and __winitenv
symbols. Deduplicate code and move it into a new misc/__initenv.c file.
Signed-off-by: LIU Hao <lh_mouse@126.com>
These could also possibly be made non-inline if we'd be providing
the comsupp library. However, that could break existing code that
calls _com_issue_error (implicitly via _com_ptr_t in comip.h)
and don't currently explicitly link in any comsupp library (which
doesn't exist currently either).
In the corresponding MSVC setups, the comsupp library is linked
in automatically via '#pragma comment(lib, "comsupp.lib")' in
the comdef.h header.
Signed-off-by: Martin Storsjö <martin@martin.st>
Microsoft defines this to the same value on x64, ARM, and ARM64, so do
the same.
This constant is used by Cairo. See
https://github.com/msys2/MINGW-packages/issues/11053
Signed-off-by: Jeremy Drake <jeremyd2019@users.sourceforge.net>
Signed-off-by: Martin Storsjö <martin@martin.st>
x86_64-w64-mingw32-gcc throws following -Wsign-compare warning when
compiling 64-bit NT kernel drivers which include ddk/ntddk.h file:
ddk/wdm.h: In function ‘RtlExtendedMagicDivide’:
ddk/wdm.h:9531:32: warning: operand of ?: changes signedness from ‘long long int’ to ‘ULONG64’ {aka ‘long long unsigned int’} due to unsignedness of other operand [-Wsign-compare]
ret.QuadPart = Pos ? ret64 : -(LONG64)ret64;
^~~~~~~~~~~~~~
Member ret.QuadPart is of type LONGLONG, so explicitly cast both parts of
ret64 ternary operator to LONG64.
Signed-off-by: LIU Hao <lh_mouse@126.com>
The possible values are
* SECURITY_ANONYMOUS which is 0<<16 aka 0x00000000
* SECURITY_IDENTIFICATION which is 1<<16 aka 0x00010000
* SECURITY_IMPERSONATION which is 2<<16 aka 0x00020000
* SECURITY_DELEGATION which is which is 3<<16 aka 0x00030000
* SECURITY_CONTEXT_TRACKING which is 0x00040000
* SECURITY_EFFECTIVE_ONLY which is 0x00080000
So the proper mask should be 0x000F0000 instead of 0x000F00000. There's an extra 0.
Signed-off-by: Steve Lhomme <robux4@ycbcr.xyz>
Signed-off-by: LIU Hao <lh_mouse@126.com>
crtdll.dll runtime does not suppport 64-bit printf/scanf modifiers. So when
targeting crtdll.dll runtime and not using MinGW-w64 stdio functions then
do not define any 64-bit modifier in inttypes.h header file.
crtdll.dll does not interpret %I64d modifier and does not read next
argument from variadic function call. So usage of this modifier cause
shifting of all variadic arguments.
This change will cause compile errors for crtdll.dll application which are
going to use PRId64 without __USE_MINGW_ANSI_STDIO. Compile error is better
than random runtime crashes or wrong behavior by corruption of printf/scanf
stack.
gcc automatically predefines macro __CRTDLL__ when compiling for crtdll.dll
runtime, so use it in inttypes.h checks.
crtdll.dll based applications which use 64-bit int stdio support had to use
-D__USE_MINGW_ANSI_STDIO=1 compile flag even prior this change.
Non-crtdll.dll based applications (msvcrt.dll or ucrt; which is the
majority) are not affected by this change.
So there there should not be any issue with this change and it should help
to prevent stdio function overflows for crtdll.dll applications.
Signed-off-by: Martin Storsjö <martin@martin.st>
When gcc was compiled with crtdll config then it links binaries with
-lcrtdll instead of -lmsvcrt and predefines macro __CRTDLL__.
So when __MSVCRT_VERSION__ was not manually set and gcc is not going to use
-lmsvcrt then set __MSVCRT_VERSION__ to 0x00 to indicate that msvcrt.dll is
not used.
Signed-off-by: Martin Storsjö <martin@martin.st>
MinGW-w64 (v)snprintf() implementation uses windows functions _(v)snprintf()
and _(v)scprintf(). Runtime library crtdll.dll provides only _(v)snprintf(),
so include MinGW-w64 emulation of _(v)scprintf() functions into libcrtdll.a
import library.
As <msvcrt.h> header file and __mingw_get_msvcrt_handle() function depend
on msvcrtl.dll library do not use them in _scprintf.c and _vscprintf.c
source files when building object files for libcrtdll.a import library.
With this change it is possible to use snprintf() function in application
which uses crtdll.dll runtime library.
Signed-off-by: Martin Storsjö <martin@martin.st>
Object files in archive libcrtdll_extra.a (which are linked into import
library for crtdll.dll) cannot use msvcrt.h as it tries to load symbols at
runtime from msvcrt.dll using GetProcAddress().
So avoid using msvcrt.h and __mingw_get_msvcrt_handle() in crtdll.dll
runtime and directly use "setlocale_codepage_hack" implementation.
This fixes building of lc_locale_func.c for libcrtdll_extra.a archive.
Signed-off-by: Martin Storsjö <martin@martin.st>
Currently macro __LIBMSVCRT__ is defined when building any libmsvcr*.a
import library. But header file msvcrt.h contains inline function
__mingw_get_msvcrt_handle() which should be used only from import library
for runtime msvcrt.dll (and not for any other runtime msvcr*.dll) as code
from that header file directly uses msvcrt.dll library.
Protect header file msvcrt.h by a new macro __LIBMSVCRT_OS__ and fix error
message as this header file is for libmsvcrt-os.a import library.
libmsvcrt.a is import library for some msvcr*.dll runtime specified at
MinGW-w64 compile time and does not have to be msvcrt.dll.
Archive libmsvcrt_extra.a is linked only to the libmsvcrt-os.a (import
library for msvcrt.dll) by msvcrt-os.mri script, so define this new macro
__LIBMSVCRT_OS__ when building object files for archive libmsvcrt_extra.a.
Signed-off-by: Martin Storsjö <martin@martin.st>
Redirect (v)snprintf() call with n==0 arg directly to _(v)scprintf() call
at compile time. With this change gcc can optimize out __ms_(v)snprintf()
call even when MinGW-w64 runtime was not compiled with LTO.
Signed-off-by: LIU Hao <lh_mouse@126.com>
When assigning function pointer to variable, both function and variable
should have same signature. Fix it.
Signed-off-by: Martin Storsjö <martin@martin.st>