Skip to content

Commit 54197ef

Browse files
Linux: add getitimer()/setitimer()
1 parent e19650d commit 54197ef

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

libc-test/build.rs

+3
Original file line numberDiff line numberDiff line change
@@ -3558,6 +3558,9 @@ fn test_linux(target: &str) {
35583558
// https://github.com/rust-lang/libc/issues/1359
35593559
"sighandler_t" => true,
35603560

3561+
// musl doesn't define these; instead, it uses a raw int for getitimer/setitimer
3562+
"__itimer_which_t" if musl => true,
3563+
35613564
// These cannot be tested when "resolv.h" is included and are tested
35623565
// in the `linux_elf.rs` file.
35633566
"Elf64_Phdr" | "Elf32_Phdr" => true,

libc-test/semver/linux.txt

+3
Original file line numberDiff line numberDiff line change
@@ -3475,6 +3475,7 @@ __c_anonymous_sockaddr_can_j1939
34753475
__c_anonymous_sockaddr_can_tp
34763476
__errno_location
34773477
__exit_status
3478+
__itimer_which_t
34783479
__s16
34793480
__s32
34803481
__u16
@@ -3591,6 +3592,7 @@ getgrnam_r
35913592
getgrouplist
35923593
gethostid
35933594
getifaddrs
3595+
getitimer
35943596
getline
35953597
getmntent
35963598
getnameinfo
@@ -3892,6 +3894,7 @@ setfsuid
38923894
setgrent
38933895
setgroups
38943896
sethostname
3897+
setitimer
38953898
setmntent
38963899
setns
38973900
setpriority

src/unix/linux_like/linux/mod.rs

+24
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ missing! {
7373
pub enum fpos64_t {} // FIXME: fill this out with a struct
7474
}
7575

76+
pub type __itimer_which_t = ::c_int;
77+
7678
e! {
7779
pub enum tpacket_versions {
7880
TPACKET_V1,
@@ -6129,6 +6131,28 @@ extern "C" {
61296131
pub fn ioctl(fd: ::c_int, request: ::Ioctl, ...) -> ::c_int;
61306132
}
61316133

6134+
cfg_if! {
6135+
if #[cfg(target_env = "musl")] {
6136+
extern "C" {
6137+
pub fn getitimer(which: ::c_int, value: *mut ::itimerval) -> ::c_int;
6138+
pub fn setitimer(
6139+
which: ::c_int,
6140+
new: *const ::itimerval,
6141+
old: *mut ::itimerval,
6142+
) -> ::c_int;
6143+
}
6144+
} else {
6145+
extern "C" {
6146+
pub fn getitimer(which: ::__itimer_which_t, value: *mut ::itimerval) -> ::c_int;
6147+
pub fn setitimer(
6148+
which: ::__itimer_which_t,
6149+
new: *const ::itimerval,
6150+
old: *mut ::itimerval,
6151+
) -> ::c_int;
6152+
}
6153+
}
6154+
}
6155+
61326156
// LFS64 extensions
61336157
//
61346158
// * musl has 64-bit versions only so aliases the LFS64 symbols to the standard ones

0 commit comments

Comments
 (0)