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>
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index b1b34b9..c5dcfbe 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am
@@ -361,6 +361,7 @@ misc/__badioinfo.c \ misc/__p___initenv.c \ misc/__p___winitenv.c \ + misc/__p__osplatform_emul.c \ misc/__p__osver_emul.c \ misc/__initenv.c \ misc/__winitenv.c \ @@ -534,6 +535,7 @@ misc/__p__fmode.c \ misc/__p__mbcasemap.c \ misc/__p__mbctype.c \ + misc/__p__osplatform_emul.c \ misc/__p__osver.c \ misc/__p__pctype.c \ misc/__p__pgmptr.c \ @@ -648,6 +650,7 @@ misc/__p__fmode.c \ misc/__p__mbcasemap.c \ misc/__p__mbctype.c \ + misc/__p__osplatform_emul.c \ misc/__p__osver.c \ misc/__p__pctype.c \ misc/__p__pgmptr.c \ @@ -681,6 +684,7 @@ misc/__p__environ.c \ misc/__p__fmode.c \ misc/__p__mbctype.c \ + misc/__p__osplatform_emul.c \ misc/__p__osver.c \ misc/__p__pgmptr.c \ misc/__p__pctype.c \ @@ -742,6 +746,7 @@ misc/__p__commode.c \ misc/__p__environ.c \ misc/__p__fmode.c \ + misc/__p__osplatform_emul.c \ misc/__p__osver.c \ misc/__p__pctype.c \ misc/__p__pgmptr.c \ @@ -795,6 +800,7 @@ misc/msvcrt20__wgetmainargs.c \ misc/___mb_cur_max_func.c \ misc/__badioinfo.c \ + misc/__p__osplatform_emul.c \ misc/__pctype_func.c \ misc/__pwctype_func.c \ misc/__set_app_type.c \ @@ -838,6 +844,7 @@ src_msvcrt40=\ misc/___mb_cur_max_func.c \ misc/__badioinfo.c \ + misc/__p__osplatform_emul.c \ misc/__pctype_func.c \ misc/__pwctype_func.c \ misc/__sys_errlist.c \ @@ -933,6 +940,7 @@ misc/wctype.c src_msvcr90=\ + misc/__p__osplatform_emul.c \ misc/__p__osver_emul.c \ misc/imaxdiv.c \ misc/isblank.c \ @@ -941,6 +949,7 @@ misc/wctype.c src_msvcr100=\ + misc/__p__osplatform_emul.c \ misc/__p__osver_emul.c \ misc/isblank.c \ misc/iswblank.c \ @@ -948,6 +957,7 @@ misc/wctype.c src_msvcr110=\ + misc/__p__osplatform_emul.c \ misc/__p__osver_emul.c \ misc/isblank.c \ misc/iswblank.c \ @@ -955,6 +965,7 @@ misc/wctype.c src_msvcr120=\ + misc/__p__osplatform_emul.c \ misc/__p__osver_emul.c src_msvcr120_app=\
diff --git a/mingw-w64-crt/misc/__p__osplatform_emul.c b/mingw-w64-crt/misc/__p__osplatform_emul.c new file mode 100644 index 0000000..5e6f008 --- /dev/null +++ b/mingw-w64-crt/misc/__p__osplatform_emul.c
@@ -0,0 +1,24 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the mingw-w64 runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ + +#include <windows.h> + +#undef _osplatform +static unsigned int _osplatform; + +unsigned int* __cdecl __p__osplatform(void); +unsigned int* __cdecl __p__osplatform(void) +{ + if (!_osplatform) + { + OSVERSIONINFOA osvi; + osvi.dwOSVersionInfoSize = sizeof(osvi); + if (GetVersionExA(&osvi)) + _osplatform = osvi.dwPlatformId; + } + return &_osplatform; +} +unsigned int* (__cdecl *__MINGW_IMP_SYMBOL(__p__osplatform))(void) = __p__osplatform;