On Sat, 6 Dec 2025, Pali Rohár wrote:
An alternative change instead of 06/12 which tries to address the ABI issue in dirent.h header file is below.I verified that this change is correct by _Static_assert code injected into mingw-w64-crt build: #include <dirent.h> #include <tchar.h> #ifdef _WIN64 _Static_assert(__builtin_types_compatible_p(typeof(_tfindfirst), typeof(_tfindfirst64i32)), "Functions are compatible"); #else _Static_assert(__builtin_types_compatible_p(typeof(_tfindfirst), typeof(_tfindfirst32)), "Functions are compatible"); #endif crt: dirent: Use fixed size findfirst/findnext symbols For 64-bit builds *find* is replaced by *find*64i32. For 32-bit builds *find* is replaced by *find32. This is what are current definitions during the mingw-w64-crt build time. So this change does not modify any emitted symbol or strucure usage. This ensures that ABI of mingw-w64 dirent function would not change. Also this ensures that applications including the dirent.h would use ABI-same struct DIR as was defined at the mingw-w64 build time. diff --git a/mingw-w64-crt/misc/dirent.c b/mingw-w64-crt/misc/dirent.c index 4897cf492fa1..f65fdea3234b 100644 --- a/mingw-w64-crt/misc/dirent.c +++ b/mingw-w64-crt/misc/dirent.c @@ -152,7 +152,13 @@ _treaddir (_TDIR * dirp) { /* We haven't started the search yet. */ /* Start the search */ - dirp->dd_handle = _tfindfirst (dirp->dd_name, &(dirp->dd_dta)); + dirp->dd_handle = +#ifdef _WIN64 + _tfindfirst64i32 +#else + _tfindfirst32 +#endif + (dirp->dd_name, &(dirp->dd_dta)); if (dirp->dd_handle == -1) { @@ -168,7 +174,13 @@ _treaddir (_TDIR * dirp) else { /* Get the next search entry. */ - if (_tfindnext (dirp->dd_handle, &(dirp->dd_dta))) + if ( +#ifdef _WIN64 + _tfindnext64i32 +#else + _tfindnext32 +#endif + (dirp->dd_handle, &(dirp->dd_dta))) { /* We are off the end or otherwise error. _findnext sets errno to ENOENT if no more file diff --git a/mingw-w64-headers/crt/dirent.h b/mingw-w64-headers/crt/dirent.h index 2d7a1b73f71e..e9a4d1ba1c27 100644 --- a/mingw-w64-headers/crt/dirent.h +++ b/mingw-w64-headers/crt/dirent.h @@ -38,7 +38,11 @@ struct dirent typedef struct { /* disk transfer area for this dir */ - struct _finddata_t dd_dta; +#ifdef _WIN64 + struct _finddata64i32_t dd_dta; +#else + struct _finddata32_t dd_dta; +#endif /* dirent struct to return from dir (NOTE: this makes this thread * safe as long as only one thread uses a particular DIR struct at @@ -85,7 +89,11 @@ struct _wdirent typedef struct { /* disk transfer area for this dir */ - struct _wfinddata_t dd_dta; +#ifdef _WIN64 + struct _wfinddata64i32_t dd_dta; +#else + struct _wfinddata32_t dd_dta; +#endif
I think this looks like the cleaner and more correct change here (I guess this is the change that you suggest in a comment in the other version of patch 06/12, that would be the right future change instead?).
// Martin _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
