Skip to content

Commit

Permalink
Auto merge of #3341 - devnexen:fbsd_14_timerfd, r=JohnTitor
Browse files Browse the repository at this point in the history
timerfd api for freebsd 14.

close #3339
  • Loading branch information
bors committed Sep 10, 2023
2 parents 8356615 + 930f9ae commit 03fb728
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libc-test/build.rs
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
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

0 comments on commit 03fb728

Please sign in to comment.