[PATCH] Use posix_fallocate instead of ftruncate.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 19 12:29:27 PDT 2016


On 19 July 2016 at 15:11, Rui Ueyama <ruiu at google.com> wrote:
> I'd use fallocate(2) instead of posix_fallocate. fallocate does, contrary to
> posix's one, return an error if an underlying filesystem doesn't support the
> feature. You can just ignore the error.

But why is that an advantage? It the underlying FS don't support
ftruncate we would have to implement an emulation similar to what
posix_fallocate does or risk a sigbus. We would also need more ifdefs
for freebsd for example.

> Since fallocate is Linux-specific, you would have to add HAS_FALLOCATE.

Well, since it is linux only we could use "#if defined(__linux__)"
which is already used in Path.inc.

In any case, a patch that also works on OS X is attached.

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-PATCH-Use-posix_fallocate-instead-of-ftruncate.patch
Type: application/octet-stream
Size: 1257 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160719/371c5542/attachment.obj>


More information about the llvm-commits mailing list