Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD: move all new ABI to base module, add more O_ flags #3114

Merged
merged 3 commits into from
Feb 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 29 additions & 16 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -2461,8 +2461,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 @@ -5034,6 +5040,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 @@ -5050,6 +5062,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