Skip to content

Commit d9ef39c

Browse files
committed
shm api update from FreeBSD 13
1 parent e470e3b commit d9ef39c

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

libc-test/build.rs

+12
Original file line numberDiff line numberDiff line change
@@ -2164,6 +2164,15 @@ fn test_freebsd(target: &str) {
21642164

21652165
// Added in FreeBSD 14.
21662166
"F_KINFO" => true, // FIXME: depends how frequent freebsd 14 is updated on CI, this addition went this week only.
2167+
"SHM_RENAME_NOREPLACE"
2168+
| "SHM_RENAME_EXCHANGE"
2169+
| "MFD_CLOEXEC"
2170+
| "MFD_ALLOW_SEALING"
2171+
| "MFD_HUGETLB"
2172+
if Some(13) == freebsd_ver =>
2173+
{
2174+
true
2175+
}
21672176

21682177
_ => false,
21692178
}
@@ -2205,6 +2214,9 @@ fn test_freebsd(target: &str) {
22052214
// `sockcred2` is not available in FreeBSD 12.
22062215
"sockcred2" if Some(13) > freebsd_ver => true,
22072216

2217+
// Those are not available in FreeBSD 12.
2218+
"memfd_create" | "shm_rename" if Some(13) > freebsd_ver => true,
2219+
22082220
_ => false,
22092221
}
22102222
});

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

+14
Original file line numberDiff line numberDiff line change
@@ -3615,6 +3615,13 @@ pub const DST_CAN: ::c_int = 6;
36153615
pub const CPUCLOCK_WHICH_PID: ::c_int = 0;
36163616
pub const CPUCLOCK_WHICH_TID: ::c_int = 1;
36173617

3618+
pub const MFD_CLOEXEC: ::c_uint = 0x00000001;
3619+
pub const MFD_ALLOW_SEALING: ::c_uint = 0x00000002;
3620+
pub const MFD_HUGETLB: ::c_uint = 0x00000004;
3621+
3622+
pub const SHM_RENAME_NOREPLACE: ::c_int = 1 << 0;
3623+
pub const SHM_RENAME_EXCHANGE: ::c_int = 1 << 1;
3624+
36183625
const_fn! {
36193626
{const} fn _ALIGN(p: usize) -> usize {
36203627
(p + _ALIGNBYTES) & !_ALIGNBYTES
@@ -4155,6 +4162,13 @@ extern "C" {
41554162

41564163
pub fn adjtime(arg1: *const ::timeval, arg2: *mut ::timeval) -> ::c_int;
41574164
pub fn clock_getcpuclockid2(arg1: ::id_t, arg2: ::c_int, arg3: *mut clockid_t) -> ::c_int;
4165+
4166+
pub fn shm_rename(
4167+
path_from: *const ::c_char,
4168+
path_to: *const ::c_char,
4169+
flags: ::c_int,
4170+
) -> ::c_int;
4171+
pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int;
41584172
}
41594173

41604174
#[link(name = "kvm")]

0 commit comments

Comments
 (0)