Skip to content

Added timer_create and related calls #1900

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

Closed
wants to merge 1 commit into from
Closed
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
24 changes: 24 additions & 0 deletions src/unix/bsd/freebsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub type speed_t = ::c_uint;
pub type nl_item = ::c_int;
pub type id_t = i64;
pub type vm_size_t = ::uintptr_t;
pub type timer_t = *mut ::c_void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum timezone {}
Expand Down Expand Up @@ -233,6 +234,11 @@ s! {
pub piod_addr: *mut ::c_void,
pub piod_len: ::size_t,
}

pub struct itimerspec {
pub it_interval: ::timespec,
pub it_value: ::timespec,
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -1566,6 +1572,24 @@ extern "C" {
abs_timeout: *const ::timespec,
) -> ::c_int;
pub fn mq_unlink(name: *const ::c_char) -> ::c_int;

pub fn timer_create(
clockid: ::clockid_t,
sevp: *mut ::sigevent,
timerid: *mut ::timer_t,
) -> ::c_int;
pub fn timer_settime(
timerid: ::timer_t,
flags: ::c_int,
new_value: *const ::itimerspec,
old_value: *mut ::itimerspec,
) -> ::c_int;
pub fn timer_gettime(
timerid: ::timer_t,
curr_value: *mut ::itimerspec,
) -> ::c_int;
pub fn timer_getoverrun(timerid: ::timer_t) -> ::c_int;
pub fn timer_delete(timerid: ::timer_t) -> ::c_int;
}

#[link(name = "util")]
Expand Down
24 changes: 24 additions & 0 deletions src/unix/bsd/netbsdlike/netbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type __pthread_spin_t = __cpu_simple_lock_nv_t;
pub type vm_size_t = ::uintptr_t;
pub type lwpid_t = ::c_uint;
pub type shmatt_t = ::c_uint;
pub type timer_t = *mut ::c_void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, seems it's defined as int, am I missing something?

https://github.com/NetBSD/src/search?q=_BSD_TIMER_T_


impl siginfo_t {
pub unsafe fn si_value(&self) -> ::sigval {
Expand Down Expand Up @@ -341,6 +342,11 @@ s! {
pub time_state: ::c_int,
}

pub struct itimerspec {
pub it_interval: ::timespec,
pub it_value: ::timespec,
}

}

s_no_extra_traits! {
Expand Down Expand Up @@ -1759,6 +1765,24 @@ extern "C" {
nitems: ::c_int,
sevp: *mut sigevent,
) -> ::c_int;

pub fn timer_create(
clockid: ::clockid_t,
sevp: *mut ::sigevent,
timerid: *mut ::timer_t,
) -> ::c_int;
pub fn timer_settime(
timerid: ::timer_t,
flags: ::c_int,
new_value: *const ::itimerspec,
old_value: *mut ::itimerspec,
) -> ::c_int;
pub fn timer_gettime(
timerid: ::timer_t,
curr_value: *mut ::itimerspec,
) -> ::c_int;
pub fn timer_getoverrun(timerid: ::timer_t) -> ::c_int;
pub fn timer_delete(timerid: ::timer_t) -> ::c_int;
}

extern "C" {
Expand Down
11 changes: 3 additions & 8 deletions src/unix/linux_like/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@ s! {
_pad: [u8; 28],
}

pub struct itimerspec {
pub it_interval: ::timespec,
pub it_value: ::timespec,
}

pub struct ucred {
pub pid: ::pid_t,
pub uid: ::uid_t,
Expand Down Expand Up @@ -2465,13 +2460,13 @@ extern "C" {
pub fn timerfd_create(clock: ::clockid_t, flags: ::c_int) -> ::c_int;
pub fn timerfd_gettime(
fd: ::c_int,
current_value: *mut itimerspec,
current_value: *mut ::itimerspec,
) -> ::c_int;
pub fn timerfd_settime(
fd: ::c_int,
flags: ::c_int,
new_value: *const itimerspec,
old_value: *mut itimerspec,
new_value: *const ::itimerspec,
old_value: *mut ::itimerspec,
) -> ::c_int;
pub fn syscall(num: ::c_long, ...) -> ::c_long;
pub fn sched_getaffinity(
Expand Down
11 changes: 3 additions & 8 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ s! {
_pad: [u8; 28],
}

pub struct itimerspec {
pub it_interval: ::timespec,
pub it_value: ::timespec,
}

pub struct fsid_t {
__val: [::c_int; 2],
}
Expand Down Expand Up @@ -2951,13 +2946,13 @@ extern "C" {
pub fn timerfd_create(clockid: ::c_int, flags: ::c_int) -> ::c_int;
pub fn timerfd_gettime(
fd: ::c_int,
curr_value: *mut itimerspec,
curr_value: *mut ::itimerspec,
) -> ::c_int;
pub fn timerfd_settime(
fd: ::c_int,
flags: ::c_int,
new_value: *const itimerspec,
old_value: *mut itimerspec,
new_value: *const ::itimerspec,
old_value: *mut ::itimerspec,
) -> ::c_int;
pub fn pwritev(
fd: ::c_int,
Expand Down
24 changes: 24 additions & 0 deletions src/unix/linux_like/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub type tcflag_t = ::c_uint;
pub type clockid_t = ::c_int;
pub type key_t = ::c_int;
pub type id_t = ::c_uint;
pub type timer_t = *mut ::c_void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems Android and Linux define __kernel_timer_t as int?


#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum timezone {}
Expand Down Expand Up @@ -201,6 +202,11 @@ s! {
pub msg_hdr: ::msghdr,
pub msg_len: ::c_uint,
}

pub struct itimerspec {
pub it_interval: ::timespec,
pub it_value: ::timespec,
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -1566,6 +1572,24 @@ extern "C" {
flags: ::c_int,
) -> ::ssize_t;
pub fn uname(buf: *mut ::utsname) -> ::c_int;

pub fn timer_create(
clockid: ::clockid_t,
sevp: *mut ::sigevent,
timerid: *mut ::timer_t,
) -> ::c_int;
pub fn timer_settime(
timerid: ::timer_t,
flags: ::c_int,
new_value: *const ::itimerspec,
old_value: *mut ::itimerspec,
) -> ::c_int;
pub fn timer_gettime(
timerid: ::timer_t,
curr_value: *mut ::itimerspec,
) -> ::c_int;
pub fn timer_getoverrun(timerid: ::timer_t) -> ::c_int;
pub fn timer_delete(timerid: ::timer_t) -> ::c_int;
}

cfg_if! {
Expand Down