-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
The new driver is making use of a cpp frontend in xcodeml-tools and this does not compile under macOS because it uses posix_fallocate
function.
xcodeml-tools/F-FrontEnd-cpp/src/io_cache.cpp:145:17: error: 'posix_fallocate' was not declared in this scope
if (posix_fallocate(fd, 0, size) != 0)
quick workaround is to add a simple implementation to be able to compile
static int posix_fallocate(int fd, off_t offset, off_t len)
{
off_t c_test;
int ret;
if (!__builtin_saddll_overflow(offset, len, &c_test)) {
fstore_t store = {F_ALLOCATECONTIG, F_PEOFPOSMODE, 0, offset + len};
// Try to get a continuous chunk of disk space
fcntl(fd, F_PREALLOCATE, &store);
if (ret < 0) {
// OK, perhaps we are too fragmented, allocate non-continuous
store.fst_flags = F_ALLOCATEALL;
ret = fcntl(fd, F_PREALLOCATE, &store);
if (ret < 0) {
return ret;
}
}
ret = ftruncate(fd, offset + len);
} else {
// offset+len would overflow.
ret = -1;
}
return ret;
}