Skip to content

Commit 930f9ae

Browse files
committed
timerfd api for freebsd 14.
close #3339
1 parent 8356615 commit 930f9ae

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
@@ -2343,6 +2343,9 @@ fn test_freebsd(target: &str) {
23432343
// Added in FreeBSD 13.2
23442344
"AT_USRSTACKBASE" | "AT_USRSTACKLIM" if Some(13) > freebsd_ver => true,
23452345

2346+
// Added in FreeBSD 14
2347+
"TFD_CLOEXEC" | "TFD_NONBLOCK" if Some(14) > freebsd_ver => true,
2348+
23462349
_ => false,
23472350
}
23482351
});
@@ -2441,6 +2444,11 @@ fn test_freebsd(target: &str) {
24412444
true
24422445
}
24432446

2447+
// Those are introduced in FreeBSD 14.
2448+
"timerfd_create" | "timerfd_gettime" | "timerfd_settime" if Some(14) > freebsd_ver => {
2449+
true
2450+
}
2451+
24442452
_ => false,
24452453
}
24462454
});

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

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

4696+
// sys/timerfd.h
4697+
4698+
pub const TFD_NONBLOCK: ::c_int = ::O_NONBLOCK;
4699+
pub const TFD_CLOEXEC: ::c_int = O_CLOEXEC;
4700+
46964701
cfg_if! {
46974702
if #[cfg(libc_const_extern_fn)] {
46984703
pub const fn MAP_ALIGNED(a: ::c_int) -> ::c_int {
@@ -5406,6 +5411,15 @@ extern "C" {
54065411
infotype: *mut ::c_uint,
54075412
flags: *mut ::c_int,
54085413
) -> ::ssize_t;
5414+
5415+
pub fn timerfd_create(clockid: ::c_int, flags: ::c_int) -> ::c_int;
5416+
pub fn timerfd_gettime(fd: ::c_int, curr_value: *mut itimerspec) -> ::c_int;
5417+
pub fn timerfd_settime(
5418+
fd: ::c_int,
5419+
flags: ::c_int,
5420+
new_value: *const itimerspec,
5421+
old_value: *mut itimerspec,
5422+
) -> ::c_int;
54095423
}
54105424

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

0 commit comments

Comments
 (0)