Skip to content

Commit

Permalink
Auto merge of #3114 - valpackett:fbsd, r=JohnTitor
Browse files Browse the repository at this point in the history
FreeBSD: move all new ABI to base module, add more O_ flags

So according to #3023 all of that stuff didn't need to be hidden away in these conditionally built modules and we could've been exposing `eventfd`, `getrandom`, `getentropy`, `setproctitle_fast` etc. to crates.io consumers all this time…
While in the test file, clean up the mess in `skip_fn` :)

Other thing we need to expose is `O_PATH`, `O_RESOLVE_BENEATH` for crates like cap-std/openat. While here, add other open flags.
  • Loading branch information
bors committed Feb 12, 2023
2 parents 781e0c3 + ea09f0d commit 35ad929
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 66 deletions.
45 changes: 29 additions & 16 deletions libc-test/build.rs
Expand Up @@ -2074,6 +2074,12 @@ fn test_freebsd(target: &str) {
// These constants were introduced in FreeBSD 13:
"EFD_CLOEXEC" | "EFD_NONBLOCK" | "EFD_SEMAPHORE" if Some(13) > freebsd_ver => true,

// This constant was introduced in FreeBSD 12:
"O_RESOLVE_BENEATH" if Some(12) > freebsd_ver => true,

// These constants were introduced in FreeBSD 13:
"O_DSYNC" | "O_PATH" | "O_EMPTY_PATH" if Some(13) > freebsd_ver => true,

// FIXME: These are deprecated - remove in a couple of releases.
// These constants were removed in FreeBSD 11 (svn r273250) but will
// still be accepted and ignored at runtime.
Expand Down Expand Up @@ -2305,9 +2311,6 @@ fn test_freebsd(target: &str) {
// FIXME: https://github.com/rust-lang/libc/issues/1272
"execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true,

// `fspacectl` was introduced in FreeBSD 14
"fspacectl" if Some(14) > freebsd_ver => true,

// The `uname` function in the `utsname.h` FreeBSD header is a C
// inline function (has no symbol) that calls the `__xuname` symbol.
// Therefore the function pointer comparison does not make sense for it.
Expand All @@ -2319,26 +2322,36 @@ fn test_freebsd(target: &str) {
// https://github.com/gnzlbg/ctest/issues/68
"lio_listio" => true,

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

// This is not available in FreeBSD 12.
"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 => {
// Those are introduced in FreeBSD 13.
"memfd_create"
| "shm_create_largepage"
| "shm_rename"
| "getentropy"
| "eventfd"
| "SOCKCRED2SIZE"
| "getlocalbase"
| "aio_readv"
| "aio_writev"
| "copy_file_range"
if Some(13) > freebsd_ver =>
{
true
}

// Added in FreeBSD 13.
"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,
// Those are introduced in FreeBSD 14.
"sched_getaffinity" | "sched_setaffinity" | "sched_getcpu" | "fspacectl"
if Some(14) > freebsd_ver =>
{
true
}

_ => false,
}
Expand Down
6 changes: 6 additions & 0 deletions libc-test/semver/freebsd.txt
Expand Up @@ -819,14 +819,20 @@ ONOEOT
OXTABS
O_ASYNC
O_DIRECT
O_DSYNC
O_EMPTY_PATH
O_EXEC
O_EXLOCK
O_FSYNC
O_NDELAY
O_NOCTTY
O_PATH
O_RESOLVE_BENEATH
O_SEARCH
O_SHLOCK
O_SYNC
O_TTY_INIT
O_VERIFY
PD_ALLOWED_AT_FORK
PD_CLOEXEC
PD_DAEMON
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
23 changes: 23 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Expand Up @@ -2523,8 +2523,14 @@ pub const SF_USER_READAHEAD: ::c_int = 0x00000008;
pub const SF_NOCACHE: ::c_int = 0x00000010;
pub const O_CLOEXEC: ::c_int = 0x00100000;
pub const O_DIRECTORY: ::c_int = 0x00020000;
pub const O_DSYNC: ::c_int = 0x01000000;
pub const O_EMPTY_PATH: ::c_int = 0x02000000;
pub const O_EXEC: ::c_int = 0x00040000;
pub const O_PATH: ::c_int = 0x00400000;
pub const O_RESOLVE_BENEATH: ::c_int = 0x00800000;
pub const O_SEARCH: ::c_int = O_EXEC;
pub const O_TTY_INIT: ::c_int = 0x00080000;
pub const O_VERIFY: ::c_int = 0x00200000;
pub const F_GETLK: ::c_int = 11;
pub const F_SETLK: ::c_int = 12;
pub const F_SETLKW: ::c_int = 13;
Expand Down Expand Up @@ -5096,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 @@ -5112,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 35ad929

Please sign in to comment.