]> Savannah Git Hosting - gnulib.git/commitdiff
ftruncate: Accept lengths > 2 GiB on 32-bit mingw.
authorBruno Haible <bruno@clisp.org>
Thu, 14 Nov 2024 03:32:09 +0000 (04:32 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 1 Dec 2024 06:55:37 +0000 (07:55 +0100)
* lib/ftruncate.c: Test whether module 'largefile' is in use, not only
whether it had to override 'off_t'.

ChangeLog
lib/ftruncate.c

index 55504d69b6b8093d6bbb20d0f1ea1449ca3d625a..e783a82c61c00aaae5b54f3b3d4bff7dc9903150 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-11-14  Bruno Haible  <bruno@clisp.org>
+
+       ftruncate: Accept lengths > 2 GiB on 32-bit mingw.
+       * lib/ftruncate.c: Test whether module 'largefile' is in use, not only
+       whether it had to override 'off_t'.
+
 2024-11-12  Bruno Haible  <bruno@clisp.org>
 
        gnulib-tool.py: Fix logic of --remove-import option.
index 6394725781b4e10d597fd97667b1c74be3a32669..29a5ae96c515746c3cbfab4cef9a0974f1bffe7b 100644 (file)
 
 # include <errno.h>
 
-# if _GL_WINDOWS_64_BIT_OFF_T
+/* 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.  So, define a 64-bit safe SetFileSize function ourselves.  */
+   argument.  Some newer versions of the Windows CRT have a _chsize_s function
+   that takes a 64-bit argument, but we cannot rely on that.
+   So, define a 64-bit safe SetFileSize function ourselves.  */
 
 /* Ensure that <windows.h> declares GetFileSizeEx.  */
 #  if !defined _WIN32_WINNT || (_WIN32_WINNT < _WIN32_WINNT_WIN2K)