Skip to content

Commit 2c94600

Browse files
committed
Auto merge of #2253 - devnexen:timer_api_linux, r=JohnTitor
linux add timer api
2 parents 3c2d4c6 + e2c2b34 commit 2c94600

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

libc-test/semver/linux.txt

+5
Original file line numberDiff line numberDiff line change
@@ -3043,6 +3043,11 @@ telldir
30433043
timerfd_create
30443044
timerfd_gettime
30453045
timerfd_settime
3046+
timer_create
3047+
timer_delete
3048+
timer_getoverrun
3049+
timer_gettime
3050+
timer_settime
30463051
tmpfile64
30473052
truncate
30483053
truncate64

src/unix/linux_like/linux/mod.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -3361,7 +3361,7 @@ extern "C" {
33613361
pub fn lremovexattr(path: *const c_char, name: *const c_char) -> ::c_int;
33623362
pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int;
33633363
pub fn signalfd(fd: ::c_int, mask: *const ::sigset_t, flags: ::c_int) -> ::c_int;
3364-
pub fn timerfd_create(clockid: ::c_int, flags: ::c_int) -> ::c_int;
3364+
pub fn timerfd_create(clockid: ::clockid_t, flags: ::c_int) -> ::c_int;
33653365
pub fn timerfd_gettime(fd: ::c_int, curr_value: *mut itimerspec) -> ::c_int;
33663366
pub fn timerfd_settime(
33673367
fd: ::c_int,
@@ -3824,6 +3824,24 @@ extern "C" {
38243824
pub fn gettid() -> ::pid_t;
38253825
}
38263826

3827+
#[link(name = "rt")]
3828+
extern "C" {
3829+
pub fn timer_create(
3830+
clockid: ::clockid_t,
3831+
sevp: *mut ::sigevent,
3832+
timerid: *mut ::timer_t,
3833+
) -> ::c_int;
3834+
pub fn timer_delete(timerid: ::timer_t) -> ::c_int;
3835+
pub fn timer_getoverrun(timerid: ::timer_t) -> ::c_int;
3836+
pub fn timer_gettime(timerid: ::timer_t, curr_value: *mut ::itimerspec) -> ::c_int;
3837+
pub fn timer_settime(
3838+
timerid: ::timer_t,
3839+
flags: ::c_int,
3840+
new_value: *const ::itimerspec,
3841+
old_value: *mut ::itimerspec,
3842+
) -> ::c_int;
3843+
}
3844+
38273845
cfg_if! {
38283846
if #[cfg(target_env = "uclibc")] {
38293847
mod uclibc;

src/unix/linux_like/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ pub type sa_family_t = u16;
22
pub type speed_t = ::c_uint;
33
pub type tcflag_t = ::c_uint;
44
pub type clockid_t = ::c_int;
5+
pub type timer_t = *mut ::c_void;
56
pub type key_t = ::c_int;
67
pub type id_t = ::c_uint;
78

0 commit comments

Comments
 (0)