Skip to content

Commit c44fece

Browse files
authored
Merge pull request #1885 from MeiK2333/master
Add getitimer and setitimer for macOS
2 parents af7749c + 7cc22db commit c44fece

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/unix/bsd/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,10 @@ pub const PRIO_PROCESS: ::c_int = 0;
506506
pub const PRIO_PGRP: ::c_int = 1;
507507
pub const PRIO_USER: ::c_int = 2;
508508

509+
pub const ITIMER_REAL: ::c_int = 0;
510+
pub const ITIMER_VIRTUAL: ::c_int = 1;
511+
pub const ITIMER_PROF: ::c_int = 2;
512+
509513
f! {
510514
pub fn CMSG_FIRSTHDR(mhdr: *const ::msghdr) -> *mut ::cmsghdr {
511515
if (*mhdr).msg_controllen as usize >= ::mem::size_of::<::cmsghdr>() {
@@ -849,6 +853,23 @@ extern "C" {
849853
options: ::c_int,
850854
rusage: *mut ::rusage,
851855
) -> ::pid_t;
856+
#[cfg_attr(
857+
all(target_os = "macos", target_arch = "x86"),
858+
link_name = "getitimer$UNIX2003"
859+
)]
860+
pub fn getitimer(
861+
which: ::c_int,
862+
curr_value: *mut ::itimerval
863+
) -> ::c_int;
864+
#[cfg_attr(
865+
all(target_os = "macos", target_arch = "x86"),
866+
link_name = "setitimer$UNIX2003"
867+
)]
868+
pub fn setitimer(
869+
which: ::c_int,
870+
new_value: *const ::itimerval,
871+
old_value: *mut ::itimerval,
872+
) -> ::c_int;
852873

853874
pub fn regcomp(
854875
preg: *mut regex_t,

0 commit comments

Comments
 (0)