diff options
| author | Jörg Frings-Fürst <debian@jff.email> | 2026-03-10 13:24:07 +0100 |
|---|---|---|
| committer | Jörg Frings-Fürst <debian@jff.email> | 2026-03-10 13:24:07 +0100 |
| commit | cfd1f17f1a85d95ea12bca8dae42add7dad1ad11 (patch) | |
| tree | 8016486f8ee7157213f2d09ff2491bfa9c94638a /tests/ftruncate.c | |
| parent | 14e4d584d0121031ec40e6c35869745f1747ff29 (diff) | |
| parent | 1403307d6e2fb4e7b5d97a35f40d1e95134561ab (diff) | |
Merge branch 'release/debian/1.4.2-1'HEADdebian/1.4.2-1master
Diffstat (limited to 'tests/ftruncate.c')
| -rw-r--r-- | tests/ftruncate.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/tests/ftruncate.c b/tests/ftruncate.c index 63947257..8e8bad8d 100644 --- a/tests/ftruncate.c +++ b/tests/ftruncate.c @@ -1,5 +1,5 @@ /* ftruncate emulations for native Windows. - Copyright (C) 1992-2024 Free Software Foundation, Inc. + Copyright (C) 1992-2026 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,10 +24,14 @@ # 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) @@ -92,14 +96,13 @@ SetFileSize (HANDLE h, LONGLONG size) static char zero_bytes[1024]; LONG pos_hi = 0; LONG pos_lo = SetFilePointer (tmph, (LONG) 0, &pos_hi, FILE_END); - LONGLONG pos; if (pos_lo == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR) { CloseHandle (tmph); return FALSE; } - pos = ((LONGLONG) pos_hi << 32) | (ULONGLONG) (ULONG) pos_lo; + LONGLONG pos = ((LONGLONG) pos_hi << 32) | (ULONGLONG) (ULONG) pos_lo; while (pos < size) { DWORD written; |
