_wctype is global variable exported from DLL library, so mark it with
DATA and removes false-positive function stdcall @size decoration.
Signed-off-by: Martin Storsjö <martin@martin.st>
_wctype is a global variable exported from CRT library and therefore has to
be always accessed by the import symbol via __MINGW_IMP_SYMBOL(_wctype).
There is no CRT function which could return pointer to this variable.
_wctype variable is present since msvcr70.dll and also since Windows Server
2003 version of msvcrt.dll. It is present also in UCRT. For older versions
there is no fallback or emulation.
Signed-off-by: Martin Storsjö <martin@martin.st>
Global variable _pwctype is not available in UCRT. Instead UCRT has only
__pwctype_func() function which returns value of _pwctype variable.
Function __pwctype_func() is available also in msvcrt since VC70. For
previous i386 msvcrt versions there is a __p__pwctype() function which
returns pointer to the _pwctype variable.
Like for _pctype changes, add fallback versions of __pwctype_func() and
__p__pwctype() functions suitable for older CRT versions. And change
definition of _pwctype in header file from the global variable to macro
which calls __pwctype_func() function.
This change allows to use _pwctype with all CRT libraries, including UCRT.
Fix also type of _pwctype. In msvc its type is wctype_t and not unsigned
short. Note that wctype_t is just typedef for unsigned short, so this
should be just a cosmetic change to align with msvc.
Signed-off-by: Martin Storsjö <martin@martin.st>
__pctype_func is available in msvcrt since VC70. __p__pctype is available
in i386 msvcrt version since VC20. _pctype is available in all versions
except in UCRT.
Define fallback __pctype_func() function implementation via __p__pctype()
function. And define __p__pctype() via _pctype variable.
With this change every CRT import library provides __pctype_func()
function. So remove #ifdefs for _pctype declarations in header files and
unifies _pctype definitions between different CRT libraries.
Signed-off-by: Martin Storsjö <martin@martin.st>
Provide fallback ___mb_cur_max_func() implementation via __p___mb_cur_max()
function. __p___mb_cur_max() is available since VC20. For earlier version
import libraries provide fallback __p___mb_cur_max() implementation via
global variable __mb_cur_max.
With this change every CRT import library provides ___mb_cur_max_func()
function. So remove #ifdefs for __mb_cur_max declarations in header files.
Signed-off-by: Martin Storsjö <martin@martin.st>
Both functions __iob_func() and __p__iob() returns same constant value -
pointer to the first member of _iob[] array. Symbol for _iob[] array is
present in every msvcrt DLL library.
Function __p__iob() is provided by every i386 version of msvcrt DLL library
since VC20. But it is not available in any non-i386 version. Function
__iob_func() is provided by every version of msvcrt DLL library since VC70
for every architecture. __iob_func() is provided also by every X64 and ARM
versions of OS system version msvcrt.dll.
Note that UCRT does not provide neither __iob_func(), nor __p__iob()
function.
So for all msvcrt versions before VC70 define __iob_func symbol as an alias
to __p__iob symbol. And for versions before VC20 provide custom mingw-w64
implementation of __iob_func() function which returns pointer to the first
member of _iob[] array.
This change allows to remove #ifdef around _iob declaration in stdio.h and
wchar.h header files as now the __iob_func() function is provided by every
version of msvcrt import library.
Signed-off-by: Martin Storsjö <martin@martin.st>
Existent enumerators have been updated a little to prevent a trailing comma.
Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
This commit reveals names in three categories:
1) Names that start with an underscore and a letter in uppercase are reserved
for implementations. These can be revealed even with strict standard
conformance.
2) Names that start with an underscore and a letter in lowercase are reserved
for implementations in file scopes (i.e. they are not eligible for macros).
These can be revealed even with strict standard conformance.
3) Some names reference POSIX functions. These are revealed when a POSIX, GNU
or BSD feature test macro is defined.
Signed-off-by: LIU Hao <lh_mouse@126.com>
This fixes build errors with GCC, after
e5ac8c5509cd729b97065733cf4b0df0ec732797; GCC doesn't accept
__asm__(), expanded from __MINGW_ASM_CALL(), after
__attribute__((deprecated())), while Clang accepts both orders.
By default, __MINGW_ATTRIB_DEPRECATED_SEC_WARN doesn't expand
to anything, but if built with defines that makes this expand to
a deprecation attribute, the build would fail with GCC.
Signed-off-by: Martin Storsjö <martin@martin.st>
Add once-guard to ensure that the file is processed only once.
Add arch-guard to ensure that DEF_<ARCH> is always defined to prevent an
issue that symbols defined via F32() macro completely disappeared and which
was fixed in previous change.
This change applied before the previous change cause compile errors.
Signed-off-by: Martin Storsjö <martin@martin.st>
Having -DDEF_<ARCH> is required by func.def.in which is used either
directly or indirectly by crt-aliases.def.in in all CRT def.in files.
Some symbols in crt-aliases.def.in are defined via F* macros and these
symbols are currently missing in versioned non-os msvcrt import libraries.
This change is fixing missing symbols in all CRT import libraries.
Signed-off-by: Martin Storsjö <martin@martin.st>
Currently __MINGW_IMP_SYMBOL symbols for aliased functions are defined as
a new plain global variable, just like for an original function.
GCC supports declaring global variable as an alias to other global
variable.
Change all aliases of import __MINGW_IMP_SYMBOL symbols via alias
attribute. This reduce memory usage as original symbol and aliased symbol
will share same global variable. Also it makes it clear that the aliased
import symbol is an alias to another import symbol.
Note that aliased symbol has to be declared with "extern" keyword even it
is not extern and gcc will emit this symbol (as described in documentation).
So for example:
int var_non_alias = 1;
int var_target = 2;
extern int __attribute__ ((alias ("var_target"))) var_alias;
Emits symbols:
SYMBOL TABLE:
[ 0](sec -2)(fl 0x00)(ty 0)(scl 103) (nx 1) 0x00000000 test.c
File
[ 2](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .text
AUX scnlen 0x0 nreloc 0 nlnno 0
[ 4](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .data
AUX scnlen 0x8 nreloc 0 nlnno 0
[ 6](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .bss
AUX scnlen 0x0 nreloc 0 nlnno 0
[ 8](sec 4)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .rdata$zzz
AUX scnlen 0x1e nreloc 0 nlnno 0
[ 10](sec 2)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _var_non_alias
[ 11](sec 2)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000004 _var_target
[ 12](sec 2)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000004 _var_alias
Contents of section .data:
0000 01000000 02000000 ........
Signed-off-by: Martin Storsjö <martin@martin.st>
WinMain() entry point provided by the application is called by mingw-w64
startup code, more precisely by function main() from crtexewin.c file.
mingw-w64 startup code in file crtexewin.c calls _ismbblead() function.
Function _ismbblead() is not available in some versions of crtdll.dll
and is completely missing in msvcrt10.dll library.
Version of crtdll.dll library stored in its PE resource directory is not
meaningful as two different libraries, one with _ismbblead symbol and one
without _ismbblead symbol has same version.
Seems that there are MBCS aware crtdll.dll versions with _ismbblead symbol
and versions which are not MBCS aware without _ismbblead symbol.
All checked msvcrt10.dll files do not have _ismbblead symbols, so
msvcrt10.dll is not MBCS awre.
For msvcrt10.dll import library provides simple dummy _ismbblead() function
which always returns false to satisfy mingw-w64 startup file crtexewin.c.
For crtdll.dll import library provides _ismbblead() wrapper function and
disable the real function in the def file to prevent symbol conflicts. The
wrapper function via GetProcAddress() checks if the real crtdll.dll
provides _ismbblead() function. If real function exists then it is called.
If not then wrapper function returns false like the msvcrt10.dll one.
This fixes linking WinMain() entry point with msvcrt10.dll.
ld: /usr/local/lib/libmingw32.a(lib32_libmingw32_a-crtexewin.o): in function `main':
mingw-w64/mingw-w64-crt/crt/crtexewin.c:43: undefined reference to `_ismbblead'
collect2: error: ld returned 1 exit status
And fixes runtime error about missing _ismbblead symbol with some versions of crtdll.dll.
Entry Point Not Found
The procedure entry point _ismbblead could not be located in the
dynamic link library CRTDLL.dll.
Signed-off-by: Martin Storsjö <martin@martin.st>
API for __getmainargs() and __wgetmainargs() functions in msvcrt20.dll is
slightly different than in new msvcrt versions. In msvcrt20.dll these
functions return void and take new_mode parameter instead of the pointer to
the _startupinfo structure.
So for compatibility with mingw-w64 startup code, in msvcrt20 import
library rename exported __getmainargs/__wgetmainargs symbols to
__msvcrt20_getmainargs/__msvcrt20_wgetmainargs and provide mingw-w64
compatible wrappers named __getmainargs/__wgetmainargs around the
renamed symbols __msvcrt20_getmainargs/__msvcrt20_wgetmainargs.
See wine implementation for details:
https://gitlab.winehq.org/wine/wine/-/blob/wine-9.8/dlls/msvcrt20/msvcrt20.c7f1e74a97a
Signed-off-by: Martin Storsjö <martin@martin.st>
API for __getmainargs() function in msvcrt10.dll is same as __GetMainArgs()
function in crtdll.dll. It is slightly different than in any other msvcrt
versions. It returns void and does not the pointer to the _startupinfo
structure as a last argument.
So for compatibility with mingw-w64 startup code, in msvcrt10 import
library rename the real __getmainargs symbol to __GetMainArgs and use
mingw-w64 crtdll.dll's wrapper __getmainargs around the __GetMainArgs for
providing the compatible __getmainargs() function.
Signed-off-by: Martin Storsjö <martin@martin.st>
For 32-bit time_t (detected by _USE_32BIT_TIME_T), functions _fstat32(),
_fstat() and fstat() are same. So fstat() can be defined as simple alias
in def file.
Same applies for functions _fstat64i32(), _fstat() and fstat() when time_t
is 64-bit.
Simplify fstat() function, remove it from mingw-w64-crt/stdio/_fstat.c file
and provide it via aliases in api-ms-win-crt-filesystem-l1-1-0.def.in and
crt-aliases.def.in for all CRT import libraries.
This fixes FIXME issue described in the fstat.c.
This change also ensures that fstat and _fstat symbols would results in the
same function calls.
Signed-off-by: Martin Storsjö <martin@martin.st>
All CRT import libraries provides UCRT-compatible *stat* symbols since
commit b463875615.
So define all stat* macros consistently with definitions of aliases in def
files based on UCRT. There is no need to have ifdef for non-UCRT version
anymore.
Signed-off-by: Martin Storsjö <martin@martin.st>