From: Bruno Haible Date: Thu, 14 Nov 2024 03:32:09 +0000 (+0100) Subject: ftruncate: Accept lengths > 2 GiB on 32-bit mingw. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=478a687710f577554856ba02b2310aa6bd93565d;p=gnulib.git 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'. --- diff --git a/ChangeLog b/ChangeLog index 97a99b7264..6c524e98d6 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)