From 5756980eb3c217ec38e05a890a85d744eded96b7 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Tue, 29 Nov 2022 18:54:09 -0700 Subject: [PATCH] Enable copy_file_range on FreeBSD PR #2479 did this, but only in the freebsd13 and freebsd14 modules, which was incorrect. Those modules should only be used for functions that change across FreeBSD versions, and therefore need different ELF symbol versions. Functions that were newly added since FreeBSD 11 can still go in the base freebsd module. It will cause no problems for them to be there, and users will see an error at link time if they try to use such a function in an environment that is too old to support it. --- libc-test/build.rs | 1 + libc-test/semver/freebsd.txt | 1 + src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs | 9 --------- src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs | 9 --------- src/unix/bsd/freebsdlike/freebsd/mod.rs | 9 +++++++++ 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index a0e0380e61a96..30f779249e27c 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2304,6 +2304,7 @@ fn test_freebsd(target: &str) { "getlocalbase" if Some(13) > freebsd_ver => true, "aio_readv" if Some(13) > freebsd_ver => true, "aio_writev" if Some(13) > freebsd_ver => true, + "copy_file_range" if Some(13) > freebsd_ver => true, _ => false, } diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 8f73e027afce0..8d26b58026394 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1517,6 +1517,7 @@ clearerr clock_getcpuclockid clock_getres clock_settime +copy_file_range cmsgcred cmsghdr cpuset diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs index 798431c35e191..72a38dc226851 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -527,15 +527,6 @@ extern "C" { policy: ::c_int, ) -> ::c_int; - pub fn copy_file_range( - infd: ::c_int, - inoffp: *mut ::off_t, - outfd: ::c_int, - outoffp: *mut ::off_t, - len: ::size_t, - flags: ::c_uint, - ) -> ::ssize_t; - pub fn dirname(path: *mut ::c_char) -> *mut ::c_char; pub fn basename(path: *mut ::c_char) -> *mut ::c_char; } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs index 3e0ec40519461..115b47764e69e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -527,15 +527,6 @@ extern "C" { policy: ::c_int, ) -> ::c_int; - pub fn copy_file_range( - infd: ::c_int, - inoffp: *mut ::off_t, - outfd: ::c_int, - outoffp: *mut ::off_t, - len: ::size_t, - flags: ::c_uint, - ) -> ::ssize_t; - pub fn dirname(path: *mut ::c_char) -> *mut ::c_char; pub fn basename(path: *mut ::c_char) -> *mut ::c_char; } diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 4064a3fe4eb1a..ff5233665a08f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -3954,6 +3954,15 @@ extern "C" { pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int; pub fn aio_writev(aiocbp: *mut ::aiocb) -> ::c_int; + pub fn copy_file_range( + infd: ::c_int, + inoffp: *mut ::off_t, + outfd: ::c_int, + outoffp: *mut ::off_t, + len: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; + pub fn devname_r( dev: ::dev_t, mode: ::mode_t,