From 98853be6af7408133a97c879172a2066ca8d2e8a Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 14 Nov 2024 04:32:09 +0100 Subject: [PATCH] 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'. --- ChangeLog | 6 ++++++ lib/ftruncate.c | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 55504d69b6..e783a82c61 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-11-14 Bruno Haible + + 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 gnulib-tool.py: Fix logic of --remove-import option. diff --git a/lib/ftruncate.c b/lib/ftruncate.c index 6394725781..29a5ae96c5 100644 --- a/lib/ftruncate.c +++ b/lib/ftruncate.c @@ -24,10 +24,14 @@ # include -# 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 declares GetFileSizeEx. */ # if !defined _WIN32_WINNT || (_WIN32_WINNT < _WIN32_WINNT_WIN2K) -- 2.39.5