From dbedd4acd3a1003b9ee59b7dac3de25176ec51c7 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 9 Jun 2024 12:56:27 +0100 Subject: [PATCH] freebsd kcmp call support. (backport ) (cherry picked from commit 68ebe1d187d0b40e7ba2012c5d36162a57528a2e) --- libc-test/build.rs | 10 ++++++++++ libc-test/semver/freebsd.txt | 6 ++++++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 14 ++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 0746d3d607007..f522e39f97a46 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2510,6 +2510,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, @@ -2626,6 +2633,9 @@ fn test_freebsd(target: &str) { true } + // Those are introduced in FreeBSD 14.1. + "kcmp" => true, + _ => false, } }); diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 00b00b7a57b04..7f7343ceb3c64 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -687,6 +687,11 @@ JAIL_SYS_DISABLE JAIL_SYS_INHERIT JAIL_SYS_NEW JAIL_UPDATE +KCMP_FILE +KCMP_FILEOBJ +KCMP_FILES +KCMP_SIGHAND +KCMP_VM KENV_GET KENV_SET KENV_UNSET @@ -1974,6 +1979,7 @@ jail_get jail_remove jail_set jrand48 +kcmp kevent key_t killpg diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index cb39077402f19..f8141eedb84bd 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -4923,6 +4923,12 @@ pub const TFD_CLOEXEC: ::c_int = O_CLOEXEC; pub const TFD_TIMER_ABSTIME: ::c_int = 0x01; pub const TFD_TIMER_CANCEL_ON_SET: ::c_int = 0x02; +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; + cfg_if! { if #[cfg(libc_const_extern_fn)] { pub const fn MAP_ALIGNED(a: ::c_int) -> ::c_int { @@ -5648,6 +5654,14 @@ extern "C" { ) -> ::c_int; pub fn closefrom(lowfd: ::c_int); pub fn close_range(lowfd: ::c_uint, highfd: ::c_uint, flags: ::c_int) -> ::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")]