Skip to content

Commit

Permalink
Linux: add getitimer()/setitimer()
Browse files Browse the repository at this point in the history
  • Loading branch information
nathaniel-bennett committed Aug 17, 2024
1 parent e19650d commit d5924b1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3475,6 +3475,8 @@ __c_anonymous_sockaddr_can_j1939
__c_anonymous_sockaddr_can_tp
__errno_location
__exit_status
__itimer_which
__itimer_which_t
__s16
__s32
__u16
Expand Down Expand Up @@ -3591,6 +3593,7 @@ getgrnam_r
getgrouplist
gethostid
getifaddrs
getitimer
getline
getmntent
getnameinfo
Expand Down Expand Up @@ -3892,6 +3895,7 @@ setfsuid
setgrent
setgroups
sethostname
setitimer
setmntent
setns
setpriority
Expand Down
26 changes: 26 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,31 @@ missing! {
pub enum fpos64_t {} // FIXME: fill this out with a struct
}

cfg_if! {
if #[cfg(target_env = "gnu")] {
pub type __itimer_which_t = ::__itimer_which;
}
}

cfg_if! {
if #[cfg(not(target_env = "gnu"))] {
pub type __itimer_which_t = ::c_int;
}
}

e! {
pub enum tpacket_versions {
TPACKET_V1,
TPACKET_V2,
TPACKET_V3,
}

#[repr(i32)]
pub enum __itimer_which {
ITIMER_REAL = 0,
ITIMER_VIRTUAL = 1,
ITIMER_PROF = 2,
}
}

s! {
Expand Down Expand Up @@ -6127,6 +6146,13 @@ extern "C" {
pub fn klogctl(syslog_type: ::c_int, bufp: *mut ::c_char, len: ::c_int) -> ::c_int;

pub fn ioctl(fd: ::c_int, request: ::Ioctl, ...) -> ::c_int;

pub fn getitimer(which: ::__itimer_which_t, value: *mut ::itimerval) -> ::c_int;
pub fn setitimer(
which: ::__itimer_which_t,
new: *const ::itimerval,
old: *mut ::itimerval,
) -> ::c_int;
}

// LFS64 extensions
Expand Down

0 comments on commit d5924b1

Please sign in to comment.