For 64-bit builds *find* is replaced by *find*64i32.
For 32-bit builds *find* is replaced by *find*32.
These are current definitions during the mingw-w64-crt build time.
It was verified by injecting this code into mingw-w64-crt source files:
#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
So this change does not modify any emitted symbol or structure 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-crt build time.
---
mingw-w64-crt/misc/dirent.c | 16 ++++++++++++++--
mingw-w64-headers/crt/dirent.h | 12 ++++++++++--
2 files changed, 24 insertions(+), 4 deletions(-)
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
/* dirent struct to return from dir (NOTE: this makes this thread
* safe as long as only one thread uses a particular DIR struct at
--
2.20.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public