在 2026-6-28 22:16, Pali Rohár 写道:
Move common code from __p__osplatform.c and __p__osplatform_emul.c into new helper function get_osplatform_helper which deduplicate code.Do not treat zero value in _osplatform as uninitialized value as it is a valid platform id value. Use additional variable for checking whether _osplatform is initialized or not. When function GetVersionExA on non-i386 systems fails then return value 2 (WinNT) which is better default than the value 0 (Win32s) as Win32s is i386-only. On i386 builds use GetVersion function as GetVersionExA is not available on older Windows NT systems. --- mingw-w64-crt/misc/__p__osplatform.c | 16 +++--- mingw-w64-crt/misc/__p__osplatform_emul.c | 59 +++++++++++++++++++++-- 2 files changed, 62 insertions(+), 13 deletions(-)
The changes in code look good; however there are many many grammatical errors in comments, so I have pushed this one with this change:
diff --git a/mingw-w64-crt/misc/__p__osplatform_emul.c
b/mingw-w64-crt/misc/__p__osplatform_emul.c
index 34141e5e7..ae4b309ea 100644
--- a/mingw-w64-crt/misc/__p__osplatform_emul.c
+++ b/mingw-w64-crt/misc/__p__osplatform_emul.c
@@ -20,11 +20,12 @@ static unsigned int get_osplatform_helper(void)
osvi.dwOSVersionInfoSize = sizeof(osvi);
#ifdef __i386__
- /* GetVersionExA is not available on older WinNT and Win32s versions but
- * returns full 32-bit for platform id (2^32 possible values).
- * GetVersion returns in highest bit identification if system is WinNT and
- * in low 8 bits returns major os system version (Win9x starts at 4).
- * So load GetVersionExA dynamically and on failure fallback to GetVersion.
+ /* GetVersionExA is not available on older WinNT and Win32s versions. When
+ * it is available, it returns a full 32-bit platform ID (2^32 possible
values).
+ * GetVersion uses its highest bit to identify whether the system is WinNT
+ * and its low 8 bits to return the major OS system version (Win9x starts
+ * at 4). So load GetVersionExA dynamically, and on failure fall back to
+ * GetVersion.
*/
kernel32 = GetModuleHandleA("kernel32.dll");
kernel32_GetVersionExA = kernel32 ? GetProcAddress(kernel32,
"GetVersionExA") : NULL;
@@ -41,8 +42,8 @@ static unsigned int get_osplatform_helper(void)
else
return VER_PLATFORM_WIN32s;
#else
- /* On non-i386 platforms is GetVersionExA always available.
- * In case of failures return value 2 (WinNT) which is sane default.
+ /* On non-i386 platforms, GetVersionExA is always available.
+ * In case of failure, return value 2 (WinNT) which is a sane default.
* Value 0 (Win32s) is not a sane default as Win32s is i386-only.
*/
if (GetVersionExA(&osvi))
--
Best regards,
LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
