Merge #17988: [0.19] Final backports for 0.19.1
daf2fff236
test: add missing #include to fix compiler errors (Karl-Johan Alm)c8ad23c529
bug-fix macos: give free bytes to F_PREALLOCATE (Karl-Johan Alm) Pull request description: We're about ready to do a [0.19.1 release](https://github.com/bitcoin/bitcoin/milestone/44); so I've opened this to collect the last remaining backports. If there's something that's been missed / or isn't tagged ["Needs backport (0.19)"](https://github.com/bitcoin/bitcoin/issues?q=is%3Aopen+label%3A%22Needs+backport+%280.19%29%22) that you think should be, please comment. Currently backports: * #17887 - bug-fix macos: give free bytes to F_PREALLOCATE * #17980 - test: add missing #include to fix compiler errors ACKs for top commit: laanwj: ACKdaf2fff236
Tree-SHA512: 8438f992d0c39315a4da4c3f8ab5c92acefada4b0ba5a5cec3775dea2541492d386bf4e7c9e76e1494a6d4cf16a9205287d27ffd23d9c3056f213d733605eeee
This commit is contained in:
commit
178a834687
2 changed files with 5 additions and 2 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <test/setup_common.h>
|
||||
#include <random.h>
|
||||
#include <thread>
|
||||
#include <deque>
|
||||
|
||||
/** Test Suite for CuckooCache
|
||||
*
|
||||
|
|
|
@ -1088,17 +1088,19 @@ void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length) {
|
|||
SetEndOfFile(hFile);
|
||||
#elif defined(MAC_OSX)
|
||||
// OSX specific version
|
||||
// NOTE: Contrary to other OS versions, the OSX version assumes that
|
||||
// NOTE: offset is the size of the file.
|
||||
fstore_t fst;
|
||||
fst.fst_flags = F_ALLOCATECONTIG;
|
||||
fst.fst_posmode = F_PEOFPOSMODE;
|
||||
fst.fst_offset = 0;
|
||||
fst.fst_length = (off_t)offset + length;
|
||||
fst.fst_length = length; // mac os fst_length takes the # of free bytes to allocate, not desired file size
|
||||
fst.fst_bytesalloc = 0;
|
||||
if (fcntl(fileno(file), F_PREALLOCATE, &fst) == -1) {
|
||||
fst.fst_flags = F_ALLOCATEALL;
|
||||
fcntl(fileno(file), F_PREALLOCATE, &fst);
|
||||
}
|
||||
ftruncate(fileno(file), fst.fst_length);
|
||||
ftruncate(fileno(file), static_cast<off_t>(offset) + length);
|
||||
#else
|
||||
#if defined(__linux__)
|
||||
// Version using posix_fallocate
|
||||
|
|
Loading…
Reference in a new issue