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 29, 2023
2 parents 4dbe73d + 930f9ae commit eca81c4
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
Original file line number Diff line number Diff line change
Expand Up @@ -2346,6 +2346,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 @@ -2444,6 +2447,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 @@ -4695,6 +4695,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 @@ -5408,6 +5413,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 eca81c4

Please sign in to comment.