Skip to content

Commit eca81c4

Browse files
committed
Auto merge of #3341 - devnexen:fbsd_14_timerfd, r=JohnTitor
timerfd api for freebsd 14. close #3339
2 parents 4dbe73d + 930f9ae commit eca81c4

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

libc-test/build.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2346,6 +2346,9 @@ fn test_freebsd(target: &str) {
23462346
// Added in FreeBSD 13.2
23472347
"AT_USRSTACKBASE" | "AT_USRSTACKLIM" if Some(13) > freebsd_ver => true,
23482348

2349+
// Added in FreeBSD 14
2350+
"TFD_CLOEXEC" | "TFD_NONBLOCK" if Some(14) > freebsd_ver => true,
2351+
23492352
_ => false,
23502353
}
23512354
});
@@ -2444,6 +2447,11 @@ fn test_freebsd(target: &str) {
24442447
true
24452448
}
24462449

2450+
// Those are introduced in FreeBSD 14.
2451+
"timerfd_create" | "timerfd_gettime" | "timerfd_settime" if Some(14) > freebsd_ver => {
2452+
true
2453+
}
2454+
24472455
_ => false,
24482456
}
24492457
});

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4695,6 +4695,11 @@ pub const RB_POWERCYCLE: ::c_int = 0x400000;
46954695
pub const RB_PROBE: ::c_int = 0x10000000;
46964696
pub const RB_MULTIPLE: ::c_int = 0x20000000;
46974697

4698+
// sys/timerfd.h
4699+
4700+
pub const TFD_NONBLOCK: ::c_int = ::O_NONBLOCK;
4701+
pub const TFD_CLOEXEC: ::c_int = O_CLOEXEC;
4702+
46984703
cfg_if! {
46994704
if #[cfg(libc_const_extern_fn)] {
47004705
pub const fn MAP_ALIGNED(a: ::c_int) -> ::c_int {
@@ -5408,6 +5413,15 @@ extern "C" {
54085413
infotype: *mut ::c_uint,
54095414
flags: *mut ::c_int,
54105415
) -> ::ssize_t;
5416+
5417+
pub fn timerfd_create(clockid: ::c_int, flags: ::c_int) -> ::c_int;
5418+
pub fn timerfd_gettime(fd: ::c_int, curr_value: *mut itimerspec) -> ::c_int;
5419+
pub fn timerfd_settime(
5420+
fd: ::c_int,
5421+
flags: ::c_int,
5422+
new_value: *const itimerspec,
5423+
old_value: *mut itimerspec,
5424+
) -> ::c_int;
54115425
}
54125426

54135427
#[link(name = "memstat")]

0 commit comments

Comments
 (0)