[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ftruncate: Accept lengths > 2 GiB on 32-bit mingw
From: |
Bruno Haible |
Subject: |
Re: ftruncate: Accept lengths > 2 GiB on 32-bit mingw |
Date: |
Thu, 14 Nov 2024 07:45:22 +0100 |
> 2024-11-14 Bruno Haible <bruno@clisp.org>
>
> ftruncate: Accept lengths > 2 GiB on 32-bit mingw.
Oops, this added support for mingw broke the support for MSVC.
We need to have support for both.
2024-11-14 Bruno Haible <bruno@clisp.org>
ftruncate, ftello: Make them work again for large files on MSVC.
* lib/ftruncate.c: Test _GL_WINDOWS_64_BIT_OFF_T again.
* lib/ftello.c: Likewise.
diff --git a/lib/ftello.c b/lib/ftello.c
index 37fe93a34e..cfb46cfbba 100644
--- a/lib/ftello.c
+++ b/lib/ftello.c
@@ -34,7 +34,10 @@ ftello (FILE *fp)
# undef ftell
# define ftello ftell
#endif
-#if (defined _WIN32 && !defined __CYGWIN__) && _FILE_OFFSET_BITS == 64
+#if (defined _WIN32 && !defined __CYGWIN__) \
+ /* We need to test _FILE_OFFSET_BITS for mingw-w64 */ \
+ /* and _GL_WINDOWS_64_BIT_OFF_T for MSVC. */ \
+ && (_FILE_OFFSET_BITS == 64 || _GL_WINDOWS_64_BIT_OFF_T)
# undef ftello
# if HAVE__FTELLI64 /* msvc, mingw64 */
# define ftello _ftelli64
diff --git a/lib/ftruncate.c b/lib/ftruncate.c
index 0566c32d0e..29a5ae96c5 100644
--- a/lib/ftruncate.c
+++ b/lib/ftruncate.c
@@ -24,7 +24,9 @@
# include <errno.h>
-# if _FILE_OFFSET_BITS == 64 /* set by module 'largefile' on all platforms */
+/* We need to test _FILE_OFFSET_BITS for mingw-w64
+ and _GL_WINDOWS_64_BIT_OFF_T for MSVC. */
+# if (_FILE_OFFSET_BITS == 64 || _GL_WINDOWS_64_BIT_OFF_T)
/* Large File Support: off_t is 64-bit, but _chsize() takes only a 32-bit
argument. Some newer versions of the Windows CRT have a _chsize_s function