Skip to content

Commit

Permalink
FreeBSD: move newly introduced functions in all versions back to root
Browse files Browse the repository at this point in the history
According to rust-lang#3023, new ABI did not need to be hidden away
under cfg(freebsdXX) flags, only changed ABI!
  • Loading branch information
valpackett authored and tatref committed Mar 20, 2023
1 parent 523ea31 commit 13273fe
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 51 deletions.
12 changes: 11 additions & 1 deletion libc-test/build.rs
Expand Up @@ -2325,6 +2325,14 @@ fn test_freebsd(target: &str) {
// https://github.com/gnzlbg/ctest/issues/68
"lio_listio" => true,

// Those introduced in FreeBSD 12.
"clock_nanosleep" | "getrandom" | "elf_aux_info" | "setproctitle_fast"
| "timingsafe_bcmp" | "timingsafe_memcmp"
if Some(12) > freebsd_ver =>
{
true
}

// Those are introduced in FreeBSD 14.
"sched_getaffinity" | "sched_setaffinity" | "sched_getcpu"
if Some(14) > freebsd_ver =>
Expand All @@ -2336,7 +2344,9 @@ fn test_freebsd(target: &str) {
"SOCKCRED2SIZE" if Some(13) > freebsd_ver => true,

// Those are not available in FreeBSD 12.
"memfd_create" | "shm_create_largepage" | "shm_rename" if Some(13) > freebsd_ver => {
"memfd_create" | "shm_create_largepage" | "shm_rename" | "getentropy" | "eventfd"
if Some(13) > freebsd_ver =>
{
true
}

Expand Down
4 changes: 2 additions & 2 deletions src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs
Expand Up @@ -462,8 +462,8 @@ extern "C" {
msgflg: ::c_int,
) -> ::c_int;

pub fn fdatasync(fd: ::c_int) -> ::c_int;

// Type of `path` argument changed from `const void*` to `void*`
// in FreeBSD 12
pub fn dirname(path: *const ::c_char) -> *mut ::c_char;
pub fn basename(path: *const ::c_char) -> *mut ::c_char;
}
Expand Down
14 changes: 0 additions & 14 deletions src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs
Expand Up @@ -473,20 +473,6 @@ extern "C" {
msgtyp: ::c_long,
msgflg: ::c_int,
) -> ::ssize_t;
pub fn clock_nanosleep(
clk_id: ::clockid_t,
flags: ::c_int,
rqtp: *const ::timespec,
rmtp: *mut ::timespec,
) -> ::c_int;

pub fn fdatasync(fd: ::c_int) -> ::c_int;

pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
pub fn elf_aux_info(aux: ::c_int, buf: *mut ::c_void, buflen: ::c_int) -> ::c_int;
pub fn setproctitle_fast(fmt: *const ::c_char, ...);
pub fn timingsafe_bcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
pub fn timingsafe_memcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;

pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
Expand Down
17 changes: 0 additions & 17 deletions src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs
Expand Up @@ -492,23 +492,6 @@ extern "C" {
msgtyp: ::c_long,
msgflg: ::c_int,
) -> ::ssize_t;
pub fn clock_nanosleep(
clk_id: ::clockid_t,
flags: ::c_int,
rqtp: *const ::timespec,
rmtp: *mut ::timespec,
) -> ::c_int;

pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;

pub fn fdatasync(fd: ::c_int) -> ::c_int;

pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
pub fn elf_aux_info(aux: ::c_int, buf: *mut ::c_void, buflen: ::c_int) -> ::c_int;
pub fn setproctitle_fast(fmt: *const ::c_char, ...);
pub fn timingsafe_bcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
pub fn timingsafe_memcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;

pub fn cpuset_getdomain(
level: ::cpulevel_t,
Expand Down
17 changes: 0 additions & 17 deletions src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs
Expand Up @@ -492,23 +492,6 @@ extern "C" {
msgtyp: ::c_long,
msgflg: ::c_int,
) -> ::ssize_t;
pub fn clock_nanosleep(
clk_id: ::clockid_t,
flags: ::c_int,
rqtp: *const ::timespec,
rmtp: *mut ::timespec,
) -> ::c_int;

pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;

pub fn fdatasync(fd: ::c_int) -> ::c_int;

pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
pub fn elf_aux_info(aux: ::c_int, buf: *mut ::c_void, buflen: ::c_int) -> ::c_int;
pub fn setproctitle_fast(fmt: *const ::c_char, ...);
pub fn timingsafe_bcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
pub fn timingsafe_memcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;

pub fn cpuset_getdomain(
level: ::cpulevel_t,
Expand Down
17 changes: 17 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Expand Up @@ -5102,6 +5102,12 @@ extern "C" {
pub fn getpagesizes(pagesize: *mut ::size_t, nelem: ::c_int) -> ::c_int;

pub fn clock_getcpuclockid2(arg1: ::id_t, arg2: ::c_int, arg3: *mut clockid_t) -> ::c_int;
pub fn clock_nanosleep(
clk_id: ::clockid_t,
flags: ::c_int,
rqtp: *const ::timespec,
rmtp: *mut ::timespec,
) -> ::c_int;

pub fn shm_create_largepage(
path: *const ::c_char,
Expand All @@ -5118,6 +5124,17 @@ extern "C" {
pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int;
pub fn setaudit(auditinfo: *const auditinfo_t) -> ::c_int;

pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;

pub fn fdatasync(fd: ::c_int) -> ::c_int;

pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
pub fn elf_aux_info(aux: ::c_int, buf: *mut ::c_void, buflen: ::c_int) -> ::c_int;
pub fn setproctitle_fast(fmt: *const ::c_char, ...);
pub fn timingsafe_bcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
pub fn timingsafe_memcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;

pub fn _umtx_op(
obj: *mut ::c_void,
op: ::c_int,
Expand Down

0 comments on commit 13273fe

Please sign in to comment.