Skip to content

linux add timer api #2253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3043,6 +3043,11 @@ telldir
timerfd_create
timerfd_gettime
timerfd_settime
timer_create
timer_delete
timer_getoverrun
timer_gettime
timer_settime
tmpfile64
truncate
truncate64
Expand Down
20 changes: 19 additions & 1 deletion src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3361,7 +3361,7 @@ extern "C" {
pub fn lremovexattr(path: *const c_char, name: *const c_char) -> ::c_int;
pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int;
pub fn signalfd(fd: ::c_int, mask: *const ::sigset_t, flags: ::c_int) -> ::c_int;
pub fn timerfd_create(clockid: ::c_int, flags: ::c_int) -> ::c_int;
pub fn timerfd_create(clockid: ::clockid_t, flags: ::c_int) -> ::c_int;
pub fn timerfd_gettime(fd: ::c_int, curr_value: *mut itimerspec) -> ::c_int;
pub fn timerfd_settime(
fd: ::c_int,
Expand Down Expand Up @@ -3824,6 +3824,24 @@ extern "C" {
pub fn gettid() -> ::pid_t;
}

#[link(name = "rt")]
extern "C" {
pub fn timer_create(
clockid: ::clockid_t,
sevp: *mut ::sigevent,
timerid: *mut ::timer_t,
) -> ::c_int;
pub fn timer_delete(timerid: ::timer_t) -> ::c_int;
pub fn timer_getoverrun(timerid: ::timer_t) -> ::c_int;
pub fn timer_gettime(timerid: ::timer_t, curr_value: *mut ::itimerspec) -> ::c_int;
pub fn timer_settime(
timerid: ::timer_t,
flags: ::c_int,
new_value: *const ::itimerspec,
old_value: *mut ::itimerspec,
) -> ::c_int;
}

cfg_if! {
if #[cfg(target_env = "uclibc")] {
mod uclibc;
Expand Down
1 change: 1 addition & 0 deletions src/unix/linux_like/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub type sa_family_t = u16;
pub type speed_t = ::c_uint;
pub type tcflag_t = ::c_uint;
pub type clockid_t = ::c_int;
pub type timer_t = *mut ::c_void;
pub type key_t = ::c_int;
pub type id_t = ::c_uint;

Expand Down