Skip to content

Commit

Permalink
freebsd kcmp call support.
Browse files Browse the repository at this point in the history
(backport <rust-lang#3746>)
(cherry picked from commit 68ebe1d)
  • Loading branch information
devnexen authored and tgross35 committed Nov 17, 2024
1 parent e582397 commit 155c38c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2596,6 +2596,13 @@ fn test_freebsd(target: &str) {
true
}

// Added in FreeBSD 14.1
"KCMP_FILE" | "KCMP_FILEOBJ" | "KCMP_FILES" | "KCMP_SIGHAND" | "KCMP_VM"
if Some(14) > freebsd_ver =>
{
true
}

// FIXME: Removed in FreeBSD 15:
"LOCAL_CONNWAIT" if freebsd_ver >= Some(15) => true,

Expand Down Expand Up @@ -2716,6 +2723,9 @@ fn test_freebsd(target: &str) {
true
}

// Those are introduced in FreeBSD 14.1.
"kcmp" => 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 @@ -689,6 +689,11 @@ JAIL_SYS_DISABLE
JAIL_SYS_INHERIT
JAIL_SYS_NEW
JAIL_UPDATE
KCMP_FILE
KCMP_FILEOBJ
KCMP_FILES
KCMP_SIGHAND
KCMP_VM
KENV_DUMP
KENV_DUMP_LOADER
KENV_DUMP_STATIC
Expand Down Expand Up @@ -2007,6 +2012,7 @@ jail_get
jail_remove
jail_set
jrand48
kcmp
kevent
key_t
killpg
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 @@ -4902,6 +4902,12 @@ pub const TFD_TIMER_CANCEL_ON_SET: ::c_int = 0x02;

pub const CLOSE_RANGE_CLOEXEC: ::c_uint = 1 << 2;

pub const KCMP_FILE: ::c_int = 100;
pub const KCMP_FILEOBJ: ::c_int = 101;
pub const KCMP_FILES: ::c_int = 102;
pub const KCMP_SIGHAND: ::c_int = 103;
pub const KCMP_VM: ::c_int = 104;

pub const fn MAP_ALIGNED(a: ::c_int) -> ::c_int {
a << 24
}
Expand Down Expand Up @@ -5625,6 +5631,14 @@ extern "C" {
argv: *const *const ::c_char,
envp: *const *const ::c_char,
) -> ::c_int;

pub fn kcmp(
pid1: ::pid_t,
pid2: ::pid_t,
type_: ::c_int,
idx1: ::c_ulong,
idx2: ::c_ulong,
) -> ::c_int;
}

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

0 comments on commit 155c38c

Please sign in to comment.