Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timerfd api for freebsd 14. #3341

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2343,6 +2343,9 @@ fn test_freebsd(target: &str) {
// Added in FreeBSD 13.2
"AT_USRSTACKBASE" | "AT_USRSTACKLIM" if Some(13) > freebsd_ver => true,

// Added in FreeBSD 14
"TFD_CLOEXEC" | "TFD_NONBLOCK" if Some(14) > freebsd_ver => true,

_ => false,
}
});
Expand Down Expand Up @@ -2441,6 +2444,11 @@ fn test_freebsd(target: &str) {
true
}

// Those are introduced in FreeBSD 14.
"timerfd_create" | "timerfd_gettime" | "timerfd_settime" if Some(14) > 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 @@ -4693,6 +4693,11 @@ pub const RB_POWERCYCLE: ::c_int = 0x400000;
pub const RB_PROBE: ::c_int = 0x10000000;
pub const RB_MULTIPLE: ::c_int = 0x20000000;

// sys/timerfd.h

pub const TFD_NONBLOCK: ::c_int = ::O_NONBLOCK;
pub const TFD_CLOEXEC: ::c_int = O_CLOEXEC;

cfg_if! {
if #[cfg(libc_const_extern_fn)] {
pub const fn MAP_ALIGNED(a: ::c_int) -> ::c_int {
Expand Down Expand Up @@ -5406,6 +5411,15 @@ extern "C" {
infotype: *mut ::c_uint,
flags: *mut ::c_int,
) -> ::ssize_t;

pub fn timerfd_create(clockid: ::c_int, flags: ::c_int) -> ::c_int;
pub fn timerfd_gettime(fd: ::c_int, curr_value: *mut itimerspec) -> ::c_int;
pub fn timerfd_settime(
fd: ::c_int,
flags: ::c_int,
new_value: *const itimerspec,
old_value: *mut itimerspec,
) -> ::c_int;
}

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