headers: Fix declaration of POSIX ftw/nftw functions
Fix declaration of POSIX ftw() and nftw() functions to follow all
combinations of _FILE_OFFSET_BITS and _USE_32BIT_TIME_T settings.
Use __MINGW_ASM_CALL as a redirection to correct ABI symbol.
Do not declare these two functions when building the mingw-w64 runtime
itself as it is not clear which of those ftw/nftw symbol should be used.
Instead the mingw-w64 source file should call the appropriate ABI
compatible ftw[size] or nftw[size] function with corresponding ABI
compatible struct _stat[size].
Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-headers/crt/ftw.h b/mingw-w64-headers/crt/ftw.h
index a5e23e0..8dca99b 100644
--- a/mingw-w64-headers/crt/ftw.h
+++ b/mingw-w64-headers/crt/ftw.h
@@ -53,10 +53,34 @@
/* Continue with FTW_DP callback for current directory (if FTW_DEPTH) and then its siblings. */
#define FTW_SKIP_SIBLINGS 3
- int ftw (const char *, int (*) (const char *, const struct stat *, int), int);
- int ftw64 (const char *, int (*) (const char *, const struct stat64 *, int), int);
+/*
+ * When building mingw-w64 CRT files it is required that the ftw and
+ * nftw functions are not declared with __MINGW_ASM_CALL redirection.
+ * Otherwise the mingw-w64 would provide broken ftw and nftw symbols.
+ * To prevent ABI issues, the mingw-w64 runtime should not call the ftw,
+ * and nftw functions, instead it should call the fixed-size variants.
+ */
+#ifndef _CRTBLD
+#if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
+#ifdef _USE_32BIT_TIME_T
+ int ftw (const char *, int (*) (const char *, const struct stat *, int), int) __MINGW_ASM_CALL(ftw32i64);
+ int nftw (const char *, int (*) (const char *, const struct stat *, int , struct FTW *), int, int) __MINGW_ASM_CALL(nftw32i64);
+#else
+ int ftw (const char *, int (*) (const char *, const struct stat *, int), int) __MINGW_ASM_CALL(ftw64);
+ int nftw (const char *, int (*) (const char *, const struct stat *, int , struct FTW *), int, int) __MINGW_ASM_CALL(nftw64);
+#endif
+#else
+#ifdef _USE_32BIT_TIME_T
+ int ftw (const char *, int (*) (const char *, const struct stat *, int), int) __MINGW_ASM_CALL(ftw32);
+ int nftw (const char *, int (*) (const char *, const struct stat *, int , struct FTW *), int, int) __MINGW_ASM_CALL(nftw32);
+#else
+ int ftw (const char *, int (*) (const char *, const struct stat *, int), int) __MINGW_ASM_CALL(ftw64i32);
+ int nftw (const char *, int (*) (const char *, const struct stat *, int , struct FTW *), int, int) __MINGW_ASM_CALL(nftw64i32);
+#endif
+#endif
+#endif
- int nftw (const char *, int (*) (const char *, const struct stat *, int , struct FTW *), int, int);
+ int ftw64 (const char *, int (*) (const char *, const struct stat64 *, int), int);
int nftw64 (const char *, int (*) (const char *, const struct stat64 *, int , struct FTW *), int, int);
#ifdef __cplusplus