Skip to content

Commit 4caf3ce

Browse files
committed
freebsd add timer api.
1 parent 971fde3 commit 4caf3ce

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
@@ -1748,6 +1748,12 @@ sysctl
17481748
sysctlbyname
17491749
sysctlnametomib
17501750
telldir
1751+
timer_create
1752+
timer_delete
1753+
timer_getoverrun
1754+
timer_gettime
1755+
timer_settime
1756+
timer_t
17511757
timex
17521758
truncate
17531759
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;
@@ -238,6 +239,15 @@ s! {
238239
envv: *mut ::c_void,
239240
core: ::uintptr_t,
240241
}
242+
243+
pub struct itimerspec {
244+
pub it_interval: ::timespec,
245+
pub it_value: ::timespec,
246+
}
247+
248+
pub struct __c_anonymous__timer {
249+
_priv: [::c_int; 3],
250+
}
241251
}
242252

243253
s_no_extra_traits! {
@@ -1938,6 +1948,20 @@ extern "C" {
19381948
pub fn procstat_close(procstat: *mut procstat);
19391949
}
19401950

1951+
#[link(name = "rt")]
1952+
extern "C" {
1953+
pub fn timer_create(clock_id: clockid_t, evp: *mut sigevent, timerid: *mut timer_t) -> ::c_int;
1954+
pub fn timer_delete(timerid: timer_t) -> ::c_int;
1955+
pub fn timer_getoverrun(timerid: timer_t) -> ::c_int;
1956+
pub fn timer_gettime(timerid: timer_t, value: *mut itimerspec) -> ::c_int;
1957+
pub fn timer_settime(
1958+
timerid: timer_t,
1959+
flags: ::c_int,
1960+
value: *const itimerspec,
1961+
ovalue: *mut itimerspec,
1962+
) -> ::c_int;
1963+
}
1964+
19411965
cfg_if! {
19421966
if #[cfg(freebsd13)] {
19431967
mod freebsd13;

0 commit comments

Comments
 (0)