winpthreads: do not allow Win9x support when minimal Windows version is Vista or higher Pre-Vista and Win9x systems share many functions that may be missing and are looked up at runtime. The higher the value of `WINPTHREADS_WINNT` macro the fewer functions we need to lookup at runtime. It makes very little sense to configure winpthreads with the minimal Windows version being Vista or higher, and with Win9x support enabled at the same time. Almost all functions that were added after XP are not available on Win9x systems and would require a runtime check with such configuration. To make runtime checks logic easier to maintain, only allow to enable Win9x support when minimal Windows version is XP or lower. This allows us to neglect Win9x when checking for function introduced in Windows Vista or higher. Signed-off-by: Kirill Makurin <maiddaisuki@outlook.com> Signed-off-by: LIU Hao <lh_mouse@126.com>
diff --git a/mingw-w64-libraries/winpthreads/README b/mingw-w64-libraries/winpthreads/README index 2e40da2..bdbb2cb 100644 --- a/mingw-w64-libraries/winpthreads/README +++ b/mingw-w64-libraries/winpthreads/README
@@ -42,7 +42,11 @@ `winpthreads` with Win9x support. This macro is only meaningful for x86 and is ignored on other targets. -By default, it is enabled with mingw-w64 and disabled with MSVC. +This macro can be defined to non-zero value only when `WINPTHREADS_WINNT` macro +is defined to value of `_WIN32_WINNT_WS03` or lower. + +By default, it is enabled with mingw-w64 (if the above condition is true) and +disabled with MSVC. ## Linking Against Winpthreads
diff --git a/mingw-w64-libraries/winpthreads/src/misc.h b/mingw-w64-libraries/winpthreads/src/misc.h index 57966e7..8c84fbe 100644 --- a/mingw-w64-libraries/winpthreads/src/misc.h +++ b/mingw-w64-libraries/winpthreads/src/misc.h
@@ -146,8 +146,7 @@ #endif /** - * For x86 build with mingw-w64, use NT 3.1 as the minimal version and enable - * Win9x support if not disabled explicitly. + * For x86 build with mingw-w64, use NT 3.1 as the minimal version. */ #else /* mingw-w64 */ @@ -155,12 +154,20 @@ #define WINPTHREADS_WINNT WINPTHREADS_WINNT_NT_3_1 #endif -#ifndef WINPTHREADS_WIN9X +/** + * Enable Win9x support if not disabled explicitly, and minimal Windows version + * to be supported is not greater than Windows XP x64. + */ +#if !defined(WINPTHREADS_WIN9X) && WINPTHREADS_WINNT <= WINPTHREADS_WINNT_2003 #define WINPTHREADS_WIN9X 1 #endif #endif /* mingw-w64 */ +#if defined(WINPTHREADS_WIN9X) && WINPTHREADS_WIN9X && WINPTHREADS_WINNT > WINPTHREADS_WINNT_2003 +#error Win9x support cannot be enabled when WINPTHREADS_WINNT is defined to a value higher than _WIN32_WINNT_WS03 +#endif + /** * Native x64, not arm64ec. * Support for x64 is only available since Windows Server 2003 SP1 / XP x64.