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. --- mingw-w64-crt/Makefile.am | 2 ++ mingw-w64-crt/lib-common/msvcrt.def.in | 2 +- mingw-w64-crt/misc/__p__winver.c | 29 ++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index 44193ebf86d4..877d1447af4e 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am @@ -541,6 +541,7 @@ src_msvcrtarm32=\ misc/__p__wcmdln.c \ misc/__p__winmajor.c \ misc/__p__winminor.c \ + misc/__p__winver.c \ misc/__p__wpgmptr.c \ misc/_getpid.c \ misc/__initenv.c \ @@ -654,6 +655,7 @@ src_msvcrtarm64=\ misc/__p__wcmdln.c \ misc/__p__winmajor.c \ misc/__p__winminor.c \ + misc/__p__winver.c \ misc/__p__wpgmptr.c \ misc/_getpid.c \ misc/__initenv.c \ diff --git a/mingw-w64-crt/lib-common/msvcrt.def.in b/mingw-w64-crt/lib-common/msvcrt.def.in index 479a6e1d95c1..540121a98cd3 100644 --- a/mingw-w64-crt/lib-common/msvcrt.def.in +++ b/mingw-w64-crt/lib-common/msvcrt.def.in @@ -494,7 +494,7 @@ F_I386(__p__wcmdln) ; x64, arm32 and arm64 __p__wcmdln provided by emu F_I386(__p__wenviron) ; x64 __p__wenviron provided by emu F_I386(__p__winmajor) ; x64, arm32 and arm64 __p__winmajor provided by emu F_I386(__p__winminor) ; x64, arm32 and arm64 __p__winminor provided by emu -F_I386(__p__winver) ; x64 __p__winver provided by emu +F_I386(__p__winver) ; x64, arm32 and arm64 __p__winver provided by emu F_I386(__p__wpgmptr) ; x64, arm32 and arm64 __p__wpgmptr provided by emu __pioinfo DATA __pxcptinfoptrs diff --git a/mingw-w64-crt/misc/__p__winver.c b/mingw-w64-crt/misc/__p__winver.c index 40f65b489eec..6bcc43055df4 100644 --- a/mingw-w64-crt/misc/__p__winver.c +++ b/mingw-w64-crt/misc/__p__winver.c @@ -6,6 +6,33 @@ #include <_mingw.h> +#if defined(__arm__) || defined(__aarch64__) || defined(_ARM_) || defined(_ARM64_) + +/* + * ARM versions of msvcrt.dll do not provide _winver global variable, so emulate + * __p__winver() pointer via private variable and fill _winver variable value + * from _winmajor and _winminor global variables. All ARM versions provide + * _winmajor and _winminor global variables, but do not provide __p__winmajor() + * and __p__winminor() functions. To avoid referencing mingw-w64 emulations of + * these __p_ functions, access global variables directly. + */ + +extern unsigned int* __MINGW_IMP_SYMBOL(_winmajor); +extern unsigned int* __MINGW_IMP_SYMBOL(_winminor); + +static unsigned int _winver; + +unsigned int* __cdecl __p__winver(void); +unsigned int* __cdecl __p__winver(void) +{ + if (!_winver) + _winver = (*__MINGW_IMP_SYMBOL(_winmajor) << 8) | *__MINGW_IMP_SYMBOL(_winminor); + return &_winver; +} +unsigned int* (__cdecl *__MINGW_IMP_SYMBOL(__p__winver))(void) = __p__winver; + +#else + extern unsigned int* __MINGW_IMP_SYMBOL(_winver); unsigned int* __cdecl __p__winver(void); @@ -14,3 +41,5 @@ unsigned int* __cdecl __p__winver(void) return __MINGW_IMP_SYMBOL(_winver); } unsigned int* (__cdecl *__MINGW_IMP_SYMBOL(__p__winver))(void) = __p__winver; + +#endif -- 2.20.1 _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public