From d062f211d59e942e8ba84681316c87d7162a74b5 Mon Sep 17 00:00:00 2001 From: Josh Megnauth Date: Thu, 15 Oct 2026 12:06:19 -0400 Subject: [PATCH] freebsd: Fix cfg gates for FreeBSD 12 FreeBSD 12 is now the minimum supported version by libc. The current gates are too conservative since they gate away the `nanosleep` functions which are available for FreeBSD 12+. See: * https://doc.rust-lang.org/nightly/rustc/platform-support/freebsd.html --- src/backend/libc/thread/syscalls.rs | 4 +--- src/fs/at.rs | 6 ++++++ src/thread/clock.rs | 9 ++++++--- tests/thread/clocks.rs | 10 +++++----- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/backend/libc/thread/syscalls.rs b/src/backend/libc/thread/syscalls.rs index 81f60219a..80a829c6a 100644 --- a/src/backend/libc/thread/syscalls.rs +++ b/src/backend/libc/thread/syscalls.rs @@ -9,7 +9,7 @@ use crate::io; use crate::pid::Pid; #[cfg(not(any( apple, - freebsdlike, + target_os = "dragonfly", target_os = "emscripten", target_os = "espidf", target_os = "haiku", @@ -51,7 +51,6 @@ weak!(fn __nanosleep64(*const LibcTimespec, *mut LibcTimespec) -> c::c_int); target_os = "dragonfly", target_os = "emscripten", target_os = "espidf", - target_os = "freebsd", // FreeBSD 12 has clock_nanosleep, but libc targets FreeBSD 11. target_os = "haiku", target_os = "horizon", target_os = "openbsd", @@ -162,7 +161,6 @@ fn clock_nanosleep_relative_old( target_os = "dragonfly", target_os = "emscripten", target_os = "espidf", - target_os = "freebsd", // FreeBSD 12 has clock_nanosleep, but libc targets FreeBSD 11. target_os = "haiku", target_os = "horizon", target_os = "openbsd", diff --git a/src/fs/at.rs b/src/fs/at.rs index f74bd4351..b670a5a1c 100644 --- a/src/fs/at.rs +++ b/src/fs/at.rs @@ -466,9 +466,11 @@ pub fn fclonefileat( /// # References /// - [POSIX] /// - [Linux] +/// - [FreeBSD] /// /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/mknodat.html /// [Linux]: https://man7.org/linux/man-pages/man2/mknodat.2.html +/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=mknodat&sektion=2 #[cfg(not(any( apple, target_os = "espidf", @@ -494,8 +496,12 @@ pub fn mknodat( /// /// # References /// - [POSIX] +/// - [Linux] +/// - [FreeBSD] /// /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/mkfifoat.html +/// [Linux]: https://www.man7.org/linux/man-pages/man3/mkfifo.3.html +/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=mkfifoat&sektion=2 #[cfg(not(any( apple, target_os = "espidf", diff --git a/src/thread/clock.rs b/src/thread/clock.rs index d6be40e87..654c5d664 100644 --- a/src/thread/clock.rs +++ b/src/thread/clock.rs @@ -7,7 +7,6 @@ pub use crate::timespec::{Nsecs, Secs, Timespec}; apple, target_os = "dragonfly", target_os = "espidf", - target_os = "freebsd", // FreeBSD 12 has clock_nanosleep, but libc targets FreeBSD 11. target_os = "openbsd", target_os = "redox", target_os = "vita", @@ -24,15 +23,16 @@ pub use crate::clockid::ClockId; /// # References /// - [POSIX] /// - [Linux] +/// - [FreeBSD] /// /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/clock_nanosleep.html /// [Linux]: https://man7.org/linux/man-pages/man2/clock_nanosleep.2.html +/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=nanosleep&sektion=2 #[cfg(not(any( apple, target_os = "dragonfly", target_os = "emscripten", target_os = "espidf", - target_os = "freebsd", // FreeBSD 12 has clock_nanosleep, but libc targets FreeBSD 11. target_os = "haiku", target_os = "horizon", target_os = "openbsd", @@ -54,15 +54,16 @@ pub fn clock_nanosleep_relative(id: ClockId, request: &Timespec) -> NanosleepRel /// # References /// - [POSIX] /// - [Linux] +/// - [FreeBSD] /// /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/clock_nanosleep.html /// [Linux]: https://man7.org/linux/man-pages/man2/clock_nanosleep.2.html +/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=nanosleep&sektion=2 #[cfg(not(any( apple, target_os = "dragonfly", target_os = "emscripten", target_os = "espidf", - target_os = "freebsd", // FreeBSD 12 has clock_nanosleep, but libc targets FreeBSD 11. target_os = "haiku", target_os = "horizon", target_os = "openbsd", @@ -82,9 +83,11 @@ pub fn clock_nanosleep_absolute(id: ClockId, request: &Timespec) -> io::Result<( /// # References /// - [POSIX] /// - [Linux] +/// - [FreeBSD] /// /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/nanosleep.html /// [Linux]: https://man7.org/linux/man-pages/man2/nanosleep.2.html +/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=nanosleep&sektion=2 #[inline] pub fn nanosleep(request: &Timespec) -> NanosleepRelativeResult { backend::thread::syscalls::nanosleep(request) diff --git a/tests/thread/clocks.rs b/tests/thread/clocks.rs index 915f3e35e..296e2394e 100644 --- a/tests/thread/clocks.rs +++ b/tests/thread/clocks.rs @@ -1,6 +1,6 @@ #[cfg(not(any( apple, - freebsdlike, + target_os = "dragonfly", target_os = "emscripten", target_os = "haiku", target_os = "openbsd", @@ -49,7 +49,7 @@ fn test_invalid_nanosleep() { #[cfg(not(any( apple, - freebsdlike, + target_os = "dragonfly", target_os = "emscripten", target_os = "haiku", target_os = "openbsd", @@ -103,7 +103,7 @@ fn test_invalid_nanosleep_absolute() { #[cfg(not(any( apple, - freebsdlike, + target_os = "dragonfly", target_os = "emscripten", target_os = "haiku", target_os = "openbsd", @@ -168,7 +168,7 @@ fn test_zero_nanosleep() { #[cfg(not(any( apple, - freebsdlike, + target_os = "dragonfly", target_os = "emscripten", target_os = "haiku", target_os = "openbsd", @@ -191,7 +191,7 @@ fn test_zero_nanosleep_absolute() { #[cfg(not(any( apple, - freebsdlike, + target_os = "dragonfly", target_os = "emscripten", target_os = "haiku", target_os = "openbsd",