Skip to content

Commit ffcf50a

Browse files
committed
Auto merge of #2416 - devnexen:fbsd_timer_api, r=JohnTitor
freebsd add timer api.
2 parents 310b698 + 4caf3ce commit ffcf50a

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

libc-test/semver/freebsd.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,6 +1750,12 @@ sysctl
17501750
sysctlbyname
17511751
sysctlnametomib
17521752
telldir
1753+
timer_create
1754+
timer_delete
1755+
timer_getoverrun
1756+
timer_gettime
1757+
timer_settime
1758+
timer_t
17531759
timex
17541760
truncate
17551761
ttyname_r

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub type lwpid_t = i32;
55
pub type blksize_t = i32;
66
pub type clockid_t = ::c_int;
77
pub type sem_t = _sem;
8+
pub type timer_t = *mut __c_anonymous__timer;
89

910
pub type fsblkcnt_t = u64;
1011
pub type fsfilcnt_t = u64;
@@ -249,6 +250,15 @@ s! {
249250
envv: *mut ::c_void,
250251
core: ::uintptr_t,
251252
}
253+
254+
pub struct itimerspec {
255+
pub it_interval: ::timespec,
256+
pub it_value: ::timespec,
257+
}
258+
259+
pub struct __c_anonymous__timer {
260+
_priv: [::c_int; 3],
261+
}
252262
}
253263

254264
s_no_extra_traits! {
@@ -1953,6 +1963,20 @@ extern "C" {
19531963
pub fn procstat_close(procstat: *mut procstat);
19541964
}
19551965

1966+
#[link(name = "rt")]
1967+
extern "C" {
1968+
pub fn timer_create(clock_id: clockid_t, evp: *mut sigevent, timerid: *mut timer_t) -> ::c_int;
1969+
pub fn timer_delete(timerid: timer_t) -> ::c_int;
1970+
pub fn timer_getoverrun(timerid: timer_t) -> ::c_int;
1971+
pub fn timer_gettime(timerid: timer_t, value: *mut itimerspec) -> ::c_int;
1972+
pub fn timer_settime(
1973+
timerid: timer_t,
1974+
flags: ::c_int,
1975+
value: *const itimerspec,
1976+
ovalue: *mut itimerspec,
1977+
) -> ::c_int;
1978+
}
1979+
19561980
cfg_if! {
19571981
if #[cfg(freebsd13)] {
19581982
mod freebsd13;

0 commit comments

Comments
 (0)