Skip to content

Commit

Permalink
Auto merge of #2631 - devnexen:fbsd13_upd_shm, r=Amanieu
Browse files Browse the repository at this point in the history
shm api update from FreeBSD 13
  • Loading branch information
bors committed Jan 17, 2022
2 parents f0ba214 + 0a57541 commit df679e8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2167,6 +2167,15 @@ fn test_freebsd(target: &str) {

// Added in FreeBSD 14.
"F_KINFO" => true, // FIXME: depends how frequent freebsd 14 is updated on CI, this addition went this week only.
"SHM_RENAME_NOREPLACE"
| "SHM_RENAME_EXCHANGE"
| "MFD_CLOEXEC"
| "MFD_ALLOW_SEALING"
| "MFD_HUGETLB"
if Some(13) > freebsd_ver =>
{
true
}

_ => false,
}
Expand Down Expand Up @@ -2248,6 +2257,9 @@ fn test_freebsd(target: &str) {
// This is not available in FreeBSD 12.
"SOCKCRED2SIZE" if Some(13) > freebsd_ver => true,

// Those are not available in FreeBSD 12.
"memfd_create" | "shm_rename" if Some(13) > freebsd_ver => true,

_ => false,
}
});
Expand Down
14 changes: 14 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3615,6 +3615,13 @@ pub const DST_CAN: ::c_int = 6;
pub const CPUCLOCK_WHICH_PID: ::c_int = 0;
pub const CPUCLOCK_WHICH_TID: ::c_int = 1;

pub const MFD_CLOEXEC: ::c_uint = 0x00000001;
pub const MFD_ALLOW_SEALING: ::c_uint = 0x00000002;
pub const MFD_HUGETLB: ::c_uint = 0x00000004;

pub const SHM_RENAME_NOREPLACE: ::c_int = 1 << 0;
pub const SHM_RENAME_EXCHANGE: ::c_int = 1 << 1;

const_fn! {
{const} fn _ALIGN(p: usize) -> usize {
(p + _ALIGNBYTES) & !_ALIGNBYTES
Expand Down Expand Up @@ -4155,6 +4162,13 @@ extern "C" {

pub fn adjtime(arg1: *const ::timeval, arg2: *mut ::timeval) -> ::c_int;
pub fn clock_getcpuclockid2(arg1: ::id_t, arg2: ::c_int, arg3: *mut clockid_t) -> ::c_int;

pub fn shm_rename(
path_from: *const ::c_char,
path_to: *const ::c_char,
flags: ::c_int,
) -> ::c_int;
pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int;
}

#[link(name = "kvm")]
Expand Down

0 comments on commit df679e8

Please sign in to comment.