Skip to content

Commit 35ad929

Browse files
committed
Auto merge of #3114 - valpackett:fbsd, r=JohnTitor
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.
2 parents 781e0c3 + ea09f0d commit 35ad929

File tree

7 files changed

+60
-66
lines changed

7 files changed

+60
-66
lines changed

libc-test/build.rs

+29-16
Original file line numberDiff line numberDiff line change
@@ -2074,6 +2074,12 @@ fn test_freebsd(target: &str) {
20742074
// These constants were introduced in FreeBSD 13:
20752075
"EFD_CLOEXEC" | "EFD_NONBLOCK" | "EFD_SEMAPHORE" if Some(13) > freebsd_ver => true,
20762076

2077+
// This constant was introduced in FreeBSD 12:
2078+
"O_RESOLVE_BENEATH" if Some(12) > freebsd_ver => true,
2079+
2080+
// These constants were introduced in FreeBSD 13:
2081+
"O_DSYNC" | "O_PATH" | "O_EMPTY_PATH" if Some(13) > freebsd_ver => true,
2082+
20772083
// FIXME: These are deprecated - remove in a couple of releases.
20782084
// These constants were removed in FreeBSD 11 (svn r273250) but will
20792085
// still be accepted and ignored at runtime.
@@ -2305,9 +2311,6 @@ fn test_freebsd(target: &str) {
23052311
// FIXME: https://github.com/rust-lang/libc/issues/1272
23062312
"execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true,
23072313

2308-
// `fspacectl` was introduced in FreeBSD 14
2309-
"fspacectl" if Some(14) > freebsd_ver => true,
2310-
23112314
// The `uname` function in the `utsname.h` FreeBSD header is a C
23122315
// inline function (has no symbol) that calls the `__xuname` symbol.
23132316
// Therefore the function pointer comparison does not make sense for it.
@@ -2319,26 +2322,36 @@ fn test_freebsd(target: &str) {
23192322
// https://github.com/gnzlbg/ctest/issues/68
23202323
"lio_listio" => true,
23212324

2322-
// Those are introduced in FreeBSD 14.
2323-
"sched_getaffinity" | "sched_setaffinity" | "sched_getcpu"
2324-
if Some(14) > freebsd_ver =>
2325+
// Those are introduced in FreeBSD 12.
2326+
"clock_nanosleep" | "getrandom" | "elf_aux_info" | "setproctitle_fast"
2327+
| "timingsafe_bcmp" | "timingsafe_memcmp"
2328+
if Some(12) > freebsd_ver =>
23252329
{
23262330
true
23272331
}
23282332

2329-
// This is not available in FreeBSD 12.
2330-
"SOCKCRED2SIZE" if Some(13) > freebsd_ver => true,
2331-
2332-
// Those are not available in FreeBSD 12.
2333-
"memfd_create" | "shm_create_largepage" | "shm_rename" if Some(13) > freebsd_ver => {
2333+
// Those are introduced in FreeBSD 13.
2334+
"memfd_create"
2335+
| "shm_create_largepage"
2336+
| "shm_rename"
2337+
| "getentropy"
2338+
| "eventfd"
2339+
| "SOCKCRED2SIZE"
2340+
| "getlocalbase"
2341+
| "aio_readv"
2342+
| "aio_writev"
2343+
| "copy_file_range"
2344+
if Some(13) > freebsd_ver =>
2345+
{
23342346
true
23352347
}
23362348

2337-
// Added in FreeBSD 13.
2338-
"getlocalbase" if Some(13) > freebsd_ver => true,
2339-
"aio_readv" if Some(13) > freebsd_ver => true,
2340-
"aio_writev" if Some(13) > freebsd_ver => true,
2341-
"copy_file_range" if Some(13) > freebsd_ver => true,
2349+
// Those are introduced in FreeBSD 14.
2350+
"sched_getaffinity" | "sched_setaffinity" | "sched_getcpu" | "fspacectl"
2351+
if Some(14) > freebsd_ver =>
2352+
{
2353+
true
2354+
}
23422355

23432356
_ => false,
23442357
}

libc-test/semver/freebsd.txt

+6
Original file line numberDiff line numberDiff line change
@@ -819,14 +819,20 @@ ONOEOT
819819
OXTABS
820820
O_ASYNC
821821
O_DIRECT
822+
O_DSYNC
823+
O_EMPTY_PATH
822824
O_EXEC
823825
O_EXLOCK
824826
O_FSYNC
825827
O_NDELAY
826828
O_NOCTTY
829+
O_PATH
830+
O_RESOLVE_BENEATH
831+
O_SEARCH
827832
O_SHLOCK
828833
O_SYNC
829834
O_TTY_INIT
835+
O_VERIFY
830836
PD_ALLOWED_AT_FORK
831837
PD_CLOEXEC
832838
PD_DAEMON

src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,8 @@ extern "C" {
462462
msgflg: ::c_int,
463463
) -> ::c_int;
464464

465-
pub fn fdatasync(fd: ::c_int) -> ::c_int;
466-
465+
// Type of `path` argument changed from `const void*` to `void*`
466+
// in FreeBSD 12
467467
pub fn dirname(path: *const ::c_char) -> *mut ::c_char;
468468
pub fn basename(path: *const ::c_char) -> *mut ::c_char;
469469
}

src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs

-14
Original file line numberDiff line numberDiff line change
@@ -473,20 +473,6 @@ extern "C" {
473473
msgtyp: ::c_long,
474474
msgflg: ::c_int,
475475
) -> ::ssize_t;
476-
pub fn clock_nanosleep(
477-
clk_id: ::clockid_t,
478-
flags: ::c_int,
479-
rqtp: *const ::timespec,
480-
rmtp: *mut ::timespec,
481-
) -> ::c_int;
482-
483-
pub fn fdatasync(fd: ::c_int) -> ::c_int;
484-
485-
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
486-
pub fn elf_aux_info(aux: ::c_int, buf: *mut ::c_void, buflen: ::c_int) -> ::c_int;
487-
pub fn setproctitle_fast(fmt: *const ::c_char, ...);
488-
pub fn timingsafe_bcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
489-
pub fn timingsafe_memcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
490476

491477
pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
492478
pub fn basename(path: *mut ::c_char) -> *mut ::c_char;

src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs

-17
Original file line numberDiff line numberDiff line change
@@ -492,23 +492,6 @@ extern "C" {
492492
msgtyp: ::c_long,
493493
msgflg: ::c_int,
494494
) -> ::ssize_t;
495-
pub fn clock_nanosleep(
496-
clk_id: ::clockid_t,
497-
flags: ::c_int,
498-
rqtp: *const ::timespec,
499-
rmtp: *mut ::timespec,
500-
) -> ::c_int;
501-
502-
pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
503-
504-
pub fn fdatasync(fd: ::c_int) -> ::c_int;
505-
506-
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
507-
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
508-
pub fn elf_aux_info(aux: ::c_int, buf: *mut ::c_void, buflen: ::c_int) -> ::c_int;
509-
pub fn setproctitle_fast(fmt: *const ::c_char, ...);
510-
pub fn timingsafe_bcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
511-
pub fn timingsafe_memcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
512495

513496
pub fn cpuset_getdomain(
514497
level: ::cpulevel_t,

src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs

-17
Original file line numberDiff line numberDiff line change
@@ -492,23 +492,6 @@ extern "C" {
492492
msgtyp: ::c_long,
493493
msgflg: ::c_int,
494494
) -> ::ssize_t;
495-
pub fn clock_nanosleep(
496-
clk_id: ::clockid_t,
497-
flags: ::c_int,
498-
rqtp: *const ::timespec,
499-
rmtp: *mut ::timespec,
500-
) -> ::c_int;
501-
502-
pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
503-
504-
pub fn fdatasync(fd: ::c_int) -> ::c_int;
505-
506-
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
507-
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
508-
pub fn elf_aux_info(aux: ::c_int, buf: *mut ::c_void, buflen: ::c_int) -> ::c_int;
509-
pub fn setproctitle_fast(fmt: *const ::c_char, ...);
510-
pub fn timingsafe_bcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
511-
pub fn timingsafe_memcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
512495

513496
pub fn cpuset_getdomain(
514497
level: ::cpulevel_t,

src/unix/bsd/freebsdlike/freebsd/mod.rs

+23
Original file line numberDiff line numberDiff line change
@@ -2523,8 +2523,14 @@ pub const SF_USER_READAHEAD: ::c_int = 0x00000008;
25232523
pub const SF_NOCACHE: ::c_int = 0x00000010;
25242524
pub const O_CLOEXEC: ::c_int = 0x00100000;
25252525
pub const O_DIRECTORY: ::c_int = 0x00020000;
2526+
pub const O_DSYNC: ::c_int = 0x01000000;
2527+
pub const O_EMPTY_PATH: ::c_int = 0x02000000;
25262528
pub const O_EXEC: ::c_int = 0x00040000;
2529+
pub const O_PATH: ::c_int = 0x00400000;
2530+
pub const O_RESOLVE_BENEATH: ::c_int = 0x00800000;
2531+
pub const O_SEARCH: ::c_int = O_EXEC;
25272532
pub const O_TTY_INIT: ::c_int = 0x00080000;
2533+
pub const O_VERIFY: ::c_int = 0x00200000;
25282534
pub const F_GETLK: ::c_int = 11;
25292535
pub const F_SETLK: ::c_int = 12;
25302536
pub const F_SETLKW: ::c_int = 13;
@@ -5096,6 +5102,12 @@ extern "C" {
50965102
pub fn getpagesizes(pagesize: *mut ::size_t, nelem: ::c_int) -> ::c_int;
50975103

50985104
pub fn clock_getcpuclockid2(arg1: ::id_t, arg2: ::c_int, arg3: *mut clockid_t) -> ::c_int;
5105+
pub fn clock_nanosleep(
5106+
clk_id: ::clockid_t,
5107+
flags: ::c_int,
5108+
rqtp: *const ::timespec,
5109+
rmtp: *mut ::timespec,
5110+
) -> ::c_int;
50995111

51005112
pub fn shm_create_largepage(
51015113
path: *const ::c_char,
@@ -5112,6 +5124,17 @@ extern "C" {
51125124
pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int;
51135125
pub fn setaudit(auditinfo: *const auditinfo_t) -> ::c_int;
51145126

5127+
pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
5128+
5129+
pub fn fdatasync(fd: ::c_int) -> ::c_int;
5130+
5131+
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
5132+
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
5133+
pub fn elf_aux_info(aux: ::c_int, buf: *mut ::c_void, buflen: ::c_int) -> ::c_int;
5134+
pub fn setproctitle_fast(fmt: *const ::c_char, ...);
5135+
pub fn timingsafe_bcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
5136+
pub fn timingsafe_memcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
5137+
51155138
pub fn _umtx_op(
51165139
obj: *mut ::c_void,
51175140
op: ::c_int,

0 commit comments

Comments
 (0)