Skip to content

Commit 5f8019f

Browse files
committed
Added timer_create and related calls
Added: * timer_create * timer_getoverrun * timer_gettime * timer_settime * timer_delete
1 parent 999e5e1 commit 5f8019f

File tree

5 files changed

+78
-16
lines changed

5 files changed

+78
-16
lines changed

src/unix/bsd/freebsdlike/mod.rs

+24
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub type speed_t = ::c_uint;
1313
pub type nl_item = ::c_int;
1414
pub type id_t = i64;
1515
pub type vm_size_t = ::uintptr_t;
16+
pub type timer_t = *mut ::c_void;
1617

1718
#[cfg_attr(feature = "extra_traits", derive(Debug))]
1819
pub enum timezone {}
@@ -233,6 +234,11 @@ s! {
233234
pub piod_addr: *mut ::c_void,
234235
pub piod_len: ::size_t,
235236
}
237+
238+
pub struct itimerspec {
239+
pub it_interval: ::timespec,
240+
pub it_value: ::timespec,
241+
}
236242
}
237243

238244
s_no_extra_traits! {
@@ -1566,6 +1572,24 @@ extern "C" {
15661572
abs_timeout: *const ::timespec,
15671573
) -> ::c_int;
15681574
pub fn mq_unlink(name: *const ::c_char) -> ::c_int;
1575+
1576+
pub fn timer_create(
1577+
clockid: ::clock_t,
1578+
sevp: *mut ::sigevent,
1579+
timerid: *mut ::timer_t,
1580+
) -> ::c_int;
1581+
pub fn timer_settime(
1582+
timerid: ::timer_t,
1583+
flags: ::c_int,
1584+
new_value: *const ::itimerspec,
1585+
old_value: *mut ::itimerspec,
1586+
) -> ::c_int;
1587+
pub fn timer_gettime(
1588+
timerid: ::timer_t,
1589+
curr_value: *mut ::itimerspec,
1590+
) -> ::c_int;
1591+
pub fn timer_getoverrun(timerid: ::timer_t) -> ::c_int;
1592+
pub fn timer_delete(timerid: ::timer_t) -> ::c_int;
15691593
}
15701594

15711595
#[link(name = "util")]

src/unix/bsd/netbsdlike/netbsd/mod.rs

+24
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type __pthread_spin_t = __cpu_simple_lock_nv_t;
1010
pub type vm_size_t = ::uintptr_t;
1111
pub type lwpid_t = ::c_uint;
1212
pub type shmatt_t = ::c_uint;
13+
pub type timer_t = *mut ::c_void;
1314

1415
impl siginfo_t {
1516
pub unsafe fn si_value(&self) -> ::sigval {
@@ -341,6 +342,11 @@ s! {
341342
pub time_state: ::c_int,
342343
}
343344

345+
pub struct itimerspec {
346+
pub it_interval: ::timespec,
347+
pub it_value: ::timespec,
348+
}
349+
344350
}
345351

346352
s_no_extra_traits! {
@@ -1759,6 +1765,24 @@ extern "C" {
17591765
nitems: ::c_int,
17601766
sevp: *mut sigevent,
17611767
) -> ::c_int;
1768+
1769+
pub fn timer_create(
1770+
clockid: ::clock_t,
1771+
sevp: *mut ::sigevent,
1772+
timerid: *mut ::timer_t,
1773+
) -> ::c_int;
1774+
pub fn timer_settime(
1775+
timerid: ::timer_t,
1776+
flags: ::c_int,
1777+
new_value: *const ::itimerspec,
1778+
old_value: *mut ::itimerspec,
1779+
) -> ::c_int;
1780+
pub fn timer_gettime(
1781+
timerid: ::timer_t,
1782+
curr_value: *mut ::itimerspec,
1783+
) -> ::c_int;
1784+
pub fn timer_getoverrun(timerid: ::timer_t) -> ::c_int;
1785+
pub fn timer_delete(timerid: ::timer_t) -> ::c_int;
17621786
}
17631787

17641788
extern "C" {

src/unix/linux_like/android/mod.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,6 @@ s! {
148148
_pad: [u8; 28],
149149
}
150150

151-
pub struct itimerspec {
152-
pub it_interval: ::timespec,
153-
pub it_value: ::timespec,
154-
}
155-
156151
pub struct ucred {
157152
pub pid: ::pid_t,
158153
pub uid: ::uid_t,
@@ -2465,13 +2460,13 @@ extern "C" {
24652460
pub fn timerfd_create(clock: ::clockid_t, flags: ::c_int) -> ::c_int;
24662461
pub fn timerfd_gettime(
24672462
fd: ::c_int,
2468-
current_value: *mut itimerspec,
2463+
current_value: *mut ::itimerspec,
24692464
) -> ::c_int;
24702465
pub fn timerfd_settime(
24712466
fd: ::c_int,
24722467
flags: ::c_int,
2473-
new_value: *const itimerspec,
2474-
old_value: *mut itimerspec,
2468+
new_value: *const ::itimerspec,
2469+
old_value: *mut ::itimerspec,
24752470
) -> ::c_int;
24762471
pub fn syscall(num: ::c_long, ...) -> ::c_long;
24772472
pub fn sched_getaffinity(

src/unix/linux_like/linux/mod.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,6 @@ s! {
123123
_pad: [u8; 28],
124124
}
125125

126-
pub struct itimerspec {
127-
pub it_interval: ::timespec,
128-
pub it_value: ::timespec,
129-
}
130-
131126
pub struct fsid_t {
132127
__val: [::c_int; 2],
133128
}
@@ -2951,13 +2946,13 @@ extern "C" {
29512946
pub fn timerfd_create(clockid: ::c_int, flags: ::c_int) -> ::c_int;
29522947
pub fn timerfd_gettime(
29532948
fd: ::c_int,
2954-
curr_value: *mut itimerspec,
2949+
curr_value: *mut ::itimerspec,
29552950
) -> ::c_int;
29562951
pub fn timerfd_settime(
29572952
fd: ::c_int,
29582953
flags: ::c_int,
2959-
new_value: *const itimerspec,
2960-
old_value: *mut itimerspec,
2954+
new_value: *const ::itimerspec,
2955+
old_value: *mut ::itimerspec,
29612956
) -> ::c_int;
29622957
pub fn pwritev(
29632958
fd: ::c_int,

src/unix/linux_like/mod.rs

+24
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pub type tcflag_t = ::c_uint;
44
pub type clockid_t = ::c_int;
55
pub type key_t = ::c_int;
66
pub type id_t = ::c_uint;
7+
pub type timer_t = *mut ::c_void;
78

89
#[cfg_attr(feature = "extra_traits", derive(Debug))]
910
pub enum timezone {}
@@ -201,6 +202,11 @@ s! {
201202
pub msg_hdr: ::msghdr,
202203
pub msg_len: ::c_uint,
203204
}
205+
206+
pub struct itimerspec {
207+
pub it_interval: ::timespec,
208+
pub it_value: ::timespec,
209+
}
204210
}
205211

206212
s_no_extra_traits! {
@@ -1566,6 +1572,24 @@ extern "C" {
15661572
flags: ::c_int,
15671573
) -> ::ssize_t;
15681574
pub fn uname(buf: *mut ::utsname) -> ::c_int;
1575+
1576+
pub fn timer_create(
1577+
clockid: ::clock_t,
1578+
sevp: *mut ::sigevent,
1579+
timerid: *mut ::timer_t,
1580+
) -> ::c_int;
1581+
pub fn timer_settime(
1582+
timerid: ::timer_t,
1583+
flags: ::c_int,
1584+
new_value: *const ::itimerspec,
1585+
old_value: *mut ::itimerspec,
1586+
) -> ::c_int;
1587+
pub fn timer_gettime(
1588+
timerid: ::timer_t,
1589+
curr_value: *mut ::itimerspec,
1590+
) -> ::c_int;
1591+
pub fn timer_getoverrun(timerid: ::timer_t) -> ::c_int;
1592+
pub fn timer_delete(timerid: ::timer_t) -> ::c_int;
15691593
}
15701594

15711595
cfg_if! {

0 commit comments

Comments
 (0)