Hello, in the attachment I'm sending changes which fixes running
mingw-w64 crt testsuite on older WinNT and Win9x systems.
>From 2de4fac3f4c381338ea158b839aa54d8b0684aa3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <[email protected]>
Date: Sat, 25 Apr 2026 12:43:51 +0200
Subject: [PATCH 1/8] crt: test: Use only the highest GetVersion bit for NT
detection
According to WinAPI GetVersion() documentation (before it was removed) the
only documented way for NT detection was via the highest bit. Second
highest bit is not documented at all, even that real windows use it and
also wine implementation use it.
---
mingw-w64-crt/testcases/t_stat.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mingw-w64-crt/testcases/t_stat.c b/mingw-w64-crt/testcases/t_stat.c
index 3fa4edd6f6c2..0202de8d95ff 100644
--- a/mingw-w64-crt/testcases/t_stat.c
+++ b/mingw-w64-crt/testcases/t_stat.c
@@ -21,7 +21,7 @@ int main(int argc, char *argv[])
struct stat64 st64;
DWORD raw_ver;
unsigned ver;
- unsigned type;
+ unsigned is_not_nt;
mingw_test_init ();
@@ -43,9 +43,9 @@ int main(int argc, char *argv[])
raw_ver = GetVersion();
ver = ((raw_ver & 0xff) << 8) | ((raw_ver & 0xff00) >> 8);
- type = (raw_ver >> 30) ^ 2;
+ is_not_nt = (raw_ver >> 31);
- if (type != VER_PLATFORM_WIN32_NT)
+ if (is_not_nt)
return 77;
snprintf(buffer, sizeof(buffer), "\\\\.\\%s", windows_dir_path);
--
2.20.1
>From 39826b539afdfff28a0694c0892c9859cae9ef89 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <[email protected]>
Date: Sat, 25 Apr 2026 13:37:42 +0200
Subject: [PATCH 2/8] crt: test: Fix t_safe_flush.c test to not crash on older
Windows versions
This test is indirectly using the IsWindowsVersionOrGreater() function
which does not work on older Windows versions on which are missing helper
functions.
Provide simple implementation via dynamic loading which allows to use
IsWindowsVersionOrGreater() (and other functions which depends on it) with
fallback to the implementation via GetVersion() for systems without the
IsWindowsVersionOrGreater function symbol.
---
mingw-w64-headers/include/versionhelpers.h | 23 ++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/mingw-w64-headers/include/versionhelpers.h
b/mingw-w64-headers/include/versionhelpers.h
index 35e4d917869d..b55d7471b759 100644
--- a/mingw-w64-headers/include/versionhelpers.h
+++ b/mingw-w64-headers/include/versionhelpers.h
@@ -19,8 +19,27 @@
VERSIONHELPERAPI IsWindowsVersionOrGreater(WORD major, WORD minor, WORD
servpack)
{
OSVERSIONINFOEXW vi = {sizeof(vi),major,minor,0,0,{0},servpack};
- return VerifyVersionInfoW(&vi,
VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR,
- VerSetConditionMask(VerSetConditionMask(VerSetConditionMask(0,
+ ULONGLONG (NTAPI*procVerSetConditionMask)(ULONGLONG,ULONG,UCHAR);
+ WINBOOL
(WINAPI*procVerifyVersionInfoW)(LPOSVERSIONINFOEXW,DWORD,DWORDLONG);
+#ifdef __i386__
+ HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll");
+ procVerSetConditionMask = kernel32 ?
(ULONGLONG(NTAPI*)(ULONGLONG,ULONG,UCHAR))(void(*)(void))GetProcAddress(kernel32,
"VerSetConditionMask") : NULL;
+ procVerifyVersionInfoW = kernel32 ?
(WINBOOL(WINAPI*)(LPOSVERSIONINFOEXW,DWORD,DWORDLONG))(void(*)(void))GetProcAddress(kernel32,
"VerifyVersionInfoW") : NULL;
+ if (!procVerSetConditionMask || !procVerifyVersionInfoW) {
+ /* Via GetVersion() check that this is NT-based system (the highest
bit is unset)
+ * and system version is greater or equal to the major/minor
parameters. */
+ DWORD verRaw = GetVersion();
+ BOOL verIsNT = !(verRaw >> 31);
+ BYTE verMajor = verRaw & 0xff;
+ BYTE verMinor = (verRaw >> 8) & 0xff;
+ return verIsNT && (verMajor > major || (verMajor == major && verMinor
>= minor));
+ }
+#else
+ procVerSetConditionMask = VerSetConditionMask;
+ procVerifyVersionInfoW = VerifyVersionInfoW;
+#endif
+ return procVerifyVersionInfoW(&vi,
VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR,
+
procVerSetConditionMask(procVerSetConditionMask(procVerSetConditionMask(0,
VER_MAJORVERSION,VER_GREATER_EQUAL),
VER_MINORVERSION,VER_GREATER_EQUAL),
VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL));
--
2.20.1
>From fa96b299962108e52a86aa6a5eef35c49f058d57 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <[email protected]>
Date: Tue, 6 Oct 2026 19:33:58 +0200
Subject: [PATCH 3/8] crt: test: Skip _fseeki64 and _lseeki64 64-bit offset
testcases when filesystem does not support large files
If the temporary file is created on a filesystem which does not support
files with size larger than 4GB then skip test cases which require to move
file pointer after the 4GB limit. This applies for example for FAT32 or for
SMB shared disks when server does not allow it.
This fixes _fseeki64 and _lseeki64 failures on Win9x systems which use FAT32.
---
mingw-w64-crt/testcases/t_fseeki64_ftelli64.c | 19 +++++++++++++++++++
mingw-w64-crt/testcases/t_lseeki64.c | 16 ++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/mingw-w64-crt/testcases/t_fseeki64_ftelli64.c
b/mingw-w64-crt/testcases/t_fseeki64_ftelli64.c
index f983298fef7a..6d667871960e 100644
--- a/mingw-w64-crt/testcases/t_fseeki64_ftelli64.c
+++ b/mingw-w64-crt/testcases/t_fseeki64_ftelli64.c
@@ -1,5 +1,7 @@
#include <assert.h>
#include <stdio.h>
+#include <io.h>
+#include <windows.h>
/* mingw-w64 headers */
#include "libtest.h"
@@ -13,6 +15,19 @@ int main() {
file = tmpfile();
assert(file);
+ /* check if the filesystem supports large files (>= 4GB) */
+ BOOL fs_supports_large_files = TRUE;
+ int fd = fileno(file);
+ assert(fd >= 0);
+ HANDLE handle = (HANDLE)_get_osfhandle(fd);
+ assert(handle != INVALID_HANDLE_VALUE);
+ LARGE_INTEGER li = { .QuadPart = 0x200000000 };
+ li.LowPart = SetFilePointer(handle, li.LowPart, &li.HighPart, FILE_BEGIN);
+ if (li.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR) {
+ fs_supports_large_files = FALSE;
+ }
+ SetFilePointer(handle, 0, NULL, FILE_BEGIN);
+
/* absolute offset which fits into 32-bit signed type */
assert(_fseeki64(file, 0x10, SEEK_SET) == 0);
assert(_ftelli64(file) == 0x10);
@@ -30,6 +45,8 @@ int main() {
assert(_fseeki64(file, 0x90000000, SEEK_SET) == 0);
assert(_ftelli64(file) == 0x90000000);
+ if (fs_supports_large_files) {
+
/* relative offset which fits into 32-bit unsigned type but absolute does
not */
assert(_fseeki64(file, 0xFFFFFFFF, SEEK_CUR) == 0);
assert(_ftelli64(file) == 0xFFFFFFFFLL + 0x90000000);
@@ -42,5 +59,7 @@ int main() {
assert(_fseeki64(file, 0x100000000, SEEK_CUR) == 0);
assert(_ftelli64(file) == 0x200000000);
+ }
+
return 0;
}
diff --git a/mingw-w64-crt/testcases/t_lseeki64.c
b/mingw-w64-crt/testcases/t_lseeki64.c
index 608d06e9dc3c..c8a3c4f7b59a 100644
--- a/mingw-w64-crt/testcases/t_lseeki64.c
+++ b/mingw-w64-crt/testcases/t_lseeki64.c
@@ -1,6 +1,7 @@
#include <assert.h>
#include <io.h>
#include <stdio.h>
+#include <windows.h>
/* mingw-w64 headers */
#include "libtest.h"
@@ -17,6 +18,17 @@ int main() {
fd = fileno(file);
assert(fd >= 0);
+ /* check if the filesystem supports large files (>= 4GB) */
+ BOOL fs_supports_large_files = TRUE;
+ HANDLE handle = (HANDLE)_get_osfhandle(fd);
+ assert(handle != INVALID_HANDLE_VALUE);
+ LARGE_INTEGER li = { .QuadPart = 0x200000000 };
+ li.LowPart = SetFilePointer(handle, li.LowPart, &li.HighPart, FILE_BEGIN);
+ if (li.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR) {
+ fs_supports_large_files = FALSE;
+ }
+ SetFilePointer(handle, 0, NULL, FILE_BEGIN);
+
/* absolute offset which fits into 32-bit signed type */
assert(_lseeki64(fd, 0x10, SEEK_SET) == 0x10);
assert(_lseeki64(fd, 0, SEEK_CUR) == 0x10);
@@ -29,6 +41,8 @@ int main() {
assert(_lseeki64(fd, 0x90000000, SEEK_SET) == 0x90000000);
assert(_lseeki64(fd, 0, SEEK_CUR) == 0x90000000);
+ if (fs_supports_large_files) {
+
/* relative offset which fits into 32-bit unsigned type but absolute does
not */
assert(_lseeki64(fd, 0xFFFFFFFF, SEEK_CUR) == 0xFFFFFFFFLL + 0x90000000);
assert(_lseeki64(fd, 0, SEEK_CUR) == 0xFFFFFFFFLL + 0x90000000);
@@ -41,5 +55,7 @@ int main() {
assert(_lseeki64(fd, 0x100000000, SEEK_CUR) == 0x200000000);
assert(_lseeki64(fd, 0, SEEK_CUR) == 0x200000000);
+ }
+
return 0;
}
--
2.20.1
>From ad042c77456219dd9e3078803744427ae11c2a70 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <[email protected]>
Date: Tue, 6 Oct 2026 19:24:09 +0200
Subject: [PATCH 4/8] crt: test: Fix cp1252 mbrtowc/wcrtomb/wctob tests when
run on WinNT3.x or Win95
WinNT3.x and Win95 systems have cp1252 without 0x80, 0x8E and 0x9E.
Adjust cp1252 tests to not check for these characters.
---
mingw-w64-crt/testcases/t_mbrtowc.c | 2 ++
mingw-w64-crt/testcases/t_wcrtomb.c | 2 ++
mingw-w64-crt/testcases/t_wctob.c | 2 ++
3 files changed, 6 insertions(+)
diff --git a/mingw-w64-crt/testcases/t_mbrtowc.c
b/mingw-w64-crt/testcases/t_mbrtowc.c
index cf55fc78c258..9414687de0d0 100644
--- a/mingw-w64-crt/testcases/t_mbrtowc.c
+++ b/mingw-w64-crt/testcases/t_mbrtowc.c
@@ -116,6 +116,8 @@ int main (void) {
assert (mbrtowc (&wc, (char *) &c, MB_CUR_MAX, &state) == 1);
if (c == 0x81 || c == 0x8D || c == 0x8F || c == 0x90 || c == 0x9D) {
assert (wc == c);
+ } else if (c == 0x80 || c == 0x8E || c == 0x9E) { /* Added in WinNT4 and
Win98 */
+ assert (wc != WEOF);
} else {
assert (wc != WEOF);
assert (wc != c);
diff --git a/mingw-w64-crt/testcases/t_wcrtomb.c
b/mingw-w64-crt/testcases/t_wcrtomb.c
index 713ff147164b..9df8b5a893c0 100644
--- a/mingw-w64-crt/testcases/t_wcrtomb.c
+++ b/mingw-w64-crt/testcases/t_wcrtomb.c
@@ -158,6 +158,8 @@ int main (void) {
if (length == 1) {
if (wc == 0x81 || wc == 0x8D || wc == 0x8F || wc == 0x90 || wc == 0x9D) {
assert ((unsigned char) c == wc);
+ } else if (wc == 0x80 || wc == 0x8E || wc == 0x9E) { /* Added in WinNT4
and Win98 */
+ assert (c != EOF);
} else {
assert (c != EOF);
assert ((unsigned char) c != wc);
diff --git a/mingw-w64-crt/testcases/t_wctob.c
b/mingw-w64-crt/testcases/t_wctob.c
index 31faa92e1085..424b24a4fcb7 100644
--- a/mingw-w64-crt/testcases/t_wctob.c
+++ b/mingw-w64-crt/testcases/t_wctob.c
@@ -65,6 +65,8 @@ int main (void) {
if (wc == 0x81 || wc == 0x8D || wc == 0x8F || wc == 0x90 || wc == 0x9D) {
assert ((unsigned char) c == wc);
+ } else if (wc == 0x80 || wc == 0x8E || wc == 0x9E) { /* Added in WinNT4
and Win98 */
+ /* for old versions c is wc, for new versions c is EOF */
} else {
assert (c == EOF || (unsigned char) c != wc);
}
--
2.20.1
>From 2b6ee9d9dd4b5f6c0665b2091571b03d5a5a32fa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <[email protected]>
Date: Tue, 6 Oct 2026 19:27:29 +0200
Subject: [PATCH 5/8] crt: test: Skip t_tls_exe_cxa_atexit_order test on Win9x
__mingw_cxa_atexit() does not work when linked to EXE binary on Win9x because
Win9x systems do not support PE TLS callbacks.
---
mingw-w64-crt/testcases/t_tls_exe_cxa_atexit_order.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/mingw-w64-crt/testcases/t_tls_exe_cxa_atexit_order.c
b/mingw-w64-crt/testcases/t_tls_exe_cxa_atexit_order.c
index 003b21247091..1b5efa3ddd93 100644
--- a/mingw-w64-crt/testcases/t_tls_exe_cxa_atexit_order.c
+++ b/mingw-w64-crt/testcases/t_tls_exe_cxa_atexit_order.c
@@ -43,6 +43,11 @@ int main(void)
{
mingw_test_init();
+ if (_osplatform == VER_PLATFORM_WIN32_WINDOWS) {
+ printf("__mingw_cxa_atexit in EXE is not supported on Win9x (due to PE TLS
callbacks)\n");
+ return 77;
+ }
+
/* Register two atexit callbacks, one before __mingw_cxa_atexit() call and
one after __mingw_cxa_atexit() call.
* The mingw_cxa_atexit callback must be called before any atexit callback
independently of the registration order. */
--
2.20.1
>From 317b2b3c1ac721d6e8649c50e21e8f79a7e7692e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <[email protected]>
Date: Tue, 6 Oct 2026 19:29:33 +0200
Subject: [PATCH 6/8] crt: test: Skip wide io functions on non-NT systems
Wide io functions are not supported on non-NT systems and always fails.
---
mingw-w64-crt/testcases/t_findfirst.c | 3 +++
mingw-w64-crt/testcases/t_stat_slash.c | 4 +++-
mingw-w64-crt/testcases/t_wreaddir.c | 6 ++++++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/mingw-w64-crt/testcases/t_findfirst.c
b/mingw-w64-crt/testcases/t_findfirst.c
index 0aff53a6c866..394cf00787ba 100644
--- a/mingw-w64-crt/testcases/t_findfirst.c
+++ b/mingw-w64-crt/testcases/t_findfirst.c
@@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <windows.h>
/* mingw-w64 headers */
#include "libtest.h"
@@ -59,11 +60,13 @@ int main(int argc, char **argv)
ret |= test32i64 ();
ret |= test64i32 ();
ret |= test64 ();
+ if (_osplatform == VER_PLATFORM_WIN32_NT) {
ret |= wtest ();
ret |= wtesti64 ();
ret |= wtest32 ();
ret |= wtest32i64 ();
ret |= wtest64i32 ();
ret |= wtest64 ();
+ }
return ret;
}
diff --git a/mingw-w64-crt/testcases/t_stat_slash.c
b/mingw-w64-crt/testcases/t_stat_slash.c
index c43bb3dd9f68..8982e739e527 100644
--- a/mingw-w64-crt/testcases/t_stat_slash.c
+++ b/mingw-w64-crt/testcases/t_stat_slash.c
@@ -25,7 +25,9 @@ void
wtest (wchar_t *path)
{
struct stat buf;
- if (wstat(path, &buf) == 0)
+ if (_osplatform != VER_PLATFORM_WIN32_NT)
+ wprintf (L"SKIP: wstat is not supported on non-NT systems\n");
+ else if (wstat(path, &buf) == 0)
wprintf (L"OK [%ls]\n", path);
else {
wprintf (L"ERROR [%ls]: %d\n", path, errno);
diff --git a/mingw-w64-crt/testcases/t_wreaddir.c
b/mingw-w64-crt/testcases/t_wreaddir.c
index 89b58e2a00ea..96cf166c818b 100644
--- a/mingw-w64-crt/testcases/t_wreaddir.c
+++ b/mingw-w64-crt/testcases/t_wreaddir.c
@@ -5,6 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <windows.h>
/* mingw-w64 headers */
#include "libtest.h"
@@ -16,6 +17,11 @@ int main(int argc, char **argv)
mingw_test_init ();
+ if (_osplatform != VER_PLATFORM_WIN32_NT) {
+ printf("_wopendir is not supported on non-NT systems\n");
+ return 77;
+ }
+
h = _wopendir (L".");
if (!h)
--
2.20.1
>From 63bb072a50f93503105ec47fecceec629f05f5b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <[email protected]>
Date: Tue, 6 Oct 2026 19:35:52 +0200
Subject: [PATCH 7/8] crt: test: Do not verify stat() / S_ISCHR() for "NUL" on
non-NT systems
On non-NT systems, stat() does not mark "NUL" as CHAR, but as REG.
---
mingw-w64-crt/testcases/t_stat.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/mingw-w64-crt/testcases/t_stat.c b/mingw-w64-crt/testcases/t_stat.c
index 0202de8d95ff..cc103bc36fe6 100644
--- a/mingw-w64-crt/testcases/t_stat.c
+++ b/mingw-w64-crt/testcases/t_stat.c
@@ -30,14 +30,6 @@ int main(int argc, char *argv[])
if (0 == stat64(argv[0], &st64))
printf("mode = %x\n", st64.st_mode);
- assert(stat("nul", &st) == 0);
- printf("nul: %s\n", type(st.st_mode));
- assert(S_ISCHR(st.st_mode));
-
- assert(stat("NUL", &st) == 0);
- printf("NUL: %s\n", type(st.st_mode));
- assert(S_ISCHR(st.st_mode));
-
if (!GetWindowsDirectoryA(windows_dir_path, MAX_PATH))
return 77;
@@ -48,6 +40,14 @@ int main(int argc, char *argv[])
if (is_not_nt)
return 77;
+ assert(stat("nul", &st) == 0);
+ printf("nul: %s\n", type(st.st_mode));
+ assert(S_ISCHR(st.st_mode));
+
+ assert(stat("NUL", &st) == 0);
+ printf("NUL: %s\n", type(st.st_mode));
+ assert(S_ISCHR(st.st_mode));
+
snprintf(buffer, sizeof(buffer), "\\\\.\\%s", windows_dir_path);
assert(stat(buffer, &st) == 0);
printf("%s: %s\n", buffer, type(st.st_mode));
--
2.20.1
>From f23edd51c93afb08a126d5939d5baa1cb440b2b7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <[email protected]>
Date: Tue, 6 Oct 2026 19:36:39 +0200
Subject: [PATCH 8/8] crt: test: Do not try to open directory via CreateFileA()
on non-NT systems
CreateFileA() for opening a directory is not supported on non-NT systems.
---
mingw-w64-crt/testcases/t_fstat.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/mingw-w64-crt/testcases/t_fstat.c
b/mingw-w64-crt/testcases/t_fstat.c
index 0a53f21d1bda..3fb9da459ff1 100644
--- a/mingw-w64-crt/testcases/t_fstat.c
+++ b/mingw-w64-crt/testcases/t_fstat.c
@@ -41,6 +41,11 @@ int main()
assert(atexit(remove_dirpath) == 0);
printf("mkdtemp(): path=%s\n", dirpath);
+ if (_osplatform != VER_PLATFORM_WIN32_NT) {
+ printf("CreateFileA() for opening a directory is not supported on
non-NT systems\n");
+ return 77;
+ }
+
handle = CreateFileA(dirpath, FILE_READ_ATTRIBUTES | DELETE,
FILE_SHARE_VALID_FLAGS, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS |
FILE_FLAG_DELETE_ON_CLOSE, NULL);
assert(handle != INVALID_HANDLE_VALUE);
--
2.20.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public