Skip to content

Commit

Permalink
Rollup merge of #1944 - nroi:include-sendfile64, r=JohnTitor
Browse files Browse the repository at this point in the history
Include sendfile64() for Linux

`sendfile` uses the `off_t` type, which is platform dependent. On 64-bit architectures, I can pass an `off64_t` as the third argument to `libc::sendfile`, but on 32-bit architectures, this does not compile. `sendfile64` on the other hand uses a 64-bit wide offset even on 32-bit architectures, so that `off64_t` can be used.

Excerpt from `man 2 sendfile`:

> The original Linux sendfile() system call was not designed to handle large file offsets. Consequently, Linux 2.4 added sendfile64(), with a wider type for the offset argument.

I hope that supporting Linux versions below 2.4 is not a requirement for libc.
  • Loading branch information
JohnTitor committed Oct 20, 2020
2 parents fd266e0 + a8c1d97 commit 419a976
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3230,6 +3230,12 @@ extern "C" {
offset: *mut off_t,
count: ::size_t,
) -> ::ssize_t;
pub fn sendfile64(
out_fd: ::c_int,
in_fd: ::c_int,
offset: *mut off64_t,
count: ::size_t,
) -> ::ssize_t;
pub fn sigsuspend(mask: *const ::sigset_t) -> ::c_int;
pub fn getgrgid_r(
gid: ::gid_t,
Expand Down

0 comments on commit 419a976

Please sign in to comment.