unix: Add sendfile to platforms that support it
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 1c71204..9c3b592 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -145,6 +145,7 @@
         cfg.header("sys/epoll.h");
         cfg.header("sys/eventfd.h");
         cfg.header("sys/prctl.h");
+        cfg.header("sys/sendfile.h");
         cfg.header("sys/vfs.h");
         cfg.header("sys/syscall.h");
         if !musl {
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index 4b2c3e0..3d96ed9 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -250,6 +250,13 @@
         pub l_type: ::c_short,
         pub l_whence: ::c_short,
     }
+
+    pub struct sf_hdtr {
+        pub headers: *mut ::iovec,
+        pub hdr_cnt: ::c_int,
+        pub trailers: *mut ::iovec,
+        pub trl_cnt: ::c_int,
+    }
 }
 
 pub const EXIT_FAILURE: ::c_int = 1;
@@ -914,6 +921,12 @@
                     id: ::c_int,
                     data: *mut ::c_char) -> ::c_int;
     pub fn sethostname(name: *const ::c_char, len: ::c_int) -> ::c_int;
+    pub fn sendfile(fd: ::c_int,
+                    s: ::c_int,
+                    offset: ::off_t,
+                    len: *mut ::off_t,
+                    hdtr: *mut ::sf_hdtr,
+                    flags: ::c_int) -> ::c_int;
 }
 
 cfg_if! {
diff --git a/src/unix/bsd/freebsdlike/freebsd.rs b/src/unix/bsd/freebsdlike/freebsd.rs
index ab2d6fc..d6fa96f 100644
--- a/src/unix/bsd/freebsdlike/freebsd.rs
+++ b/src/unix/bsd/freebsdlike/freebsd.rs
@@ -4,6 +4,9 @@
 pub const PTHREAD_STACK_MIN: ::size_t = 2048;
 pub const KERN_PROC_PATHNAME: ::c_int = 12;
 pub const SIGSTKSZ: ::size_t = 34816;
+pub const SF_NODISKIO: ::c_int = 0x00000001;
+pub const SF_MNOWAIT: ::c_int = 0x00000002;
+pub const SF_SYNC: ::c_int = 0x00000004;
 
 extern {
     pub fn __error() -> *mut ::c_int;
diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs
index d2e3a4e..7469012 100644
--- a/src/unix/bsd/freebsdlike/mod.rs
+++ b/src/unix/bsd/freebsdlike/mod.rs
@@ -139,6 +139,13 @@
         pub l_whence: ::c_short,
         pub l_sysid: ::c_int,
     }
+
+    pub struct sf_hdtr {
+        pub headers: *mut ::iovec,
+        pub hdr_cnt: ::c_int,
+        pub trailers: *mut ::iovec,
+        pub trl_cnt: ::c_int,
+    }
 }
 
 pub const EXIT_FAILURE: ::c_int = 1;
@@ -616,6 +623,13 @@
     pub fn sched_setscheduler(pid: ::pid_t, policy: ::c_int, param: *const sched_param) -> ::c_int;
     pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int;
     pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void;
+    pub fn sendfile(fd: ::c_int,
+                    s: ::c_int,
+                    offset: ::off_t,
+                    nbytes: ::size_t,
+                    hdtr: *mut ::sf_hdtr,
+                    sbytes: *mut ::off_t,
+                    flags: ::c_int) -> ::c_int;
 }
 
 cfg_if! {
diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs
index f213a52..83b4f0b 100644
--- a/src/unix/notbsd/mod.rs
+++ b/src/unix/notbsd/mod.rs
@@ -624,6 +624,10 @@
     pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
     pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void;
     pub fn syscall(num: ::c_long, ...) -> ::c_long;
+    pub fn sendfile(out_fd: ::c_int,
+                    in_fd: ::c_int,
+                    offset: *mut off_t,
+                    count: ::size_t) -> ::ssize_t;
     pub fn splice(fd_in: ::c_int,
                   off_in: *mut ::loff_t,
                   fd_out: ::c_int,
@@ -638,7 +642,6 @@
                     iov: *const ::iovec,
                     nr_segs: ::size_t,
                     flags: ::c_uint) -> ::ssize_t;
-
 }
 
 cfg_if! {