Skip to content

Commit

Permalink
tpacket
Browse files Browse the repository at this point in the history
  • Loading branch information
nathaniel-bennett committed Aug 17, 2024
1 parent e19650d commit 7d33aff
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3558,6 +3558,9 @@ fn test_linux(target: &str) {
// https://github.com/rust-lang/libc/issues/1359
"sighandler_t" => true,

// musl doesn't define these; instead, it uses a raw int for getitimer/setitimer
"__itimer_which_t" if musl => true,

// These cannot be tested when "resolv.h" is included and are tested
// in the `linux_elf.rs` file.
"Elf64_Phdr" | "Elf32_Phdr" => true,
Expand Down
3 changes: 3 additions & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3475,6 +3475,7 @@ __c_anonymous_sockaddr_can_j1939
__c_anonymous_sockaddr_can_tp
__errno_location
__exit_status
__itimer_which_t
__s16
__s32
__u16
Expand Down Expand Up @@ -3591,6 +3592,7 @@ getgrnam_r
getgrouplist
gethostid
getifaddrs
getitimer
getline
getmntent
getnameinfo
Expand Down Expand Up @@ -3892,6 +3894,7 @@ setfsuid
setgrent
setgroups
sethostname
setitimer
setmntent
setns
setpriority
Expand Down
37 changes: 37 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ missing! {
pub enum fpos64_t {} // FIXME: fill this out with a struct
}

cfg_if! {
if #[cfg(target_env = "musl")] {
pub type __itimer_which_t = ::c_int;
} else {
e! {
#[repr(i32)]
pub enum __itimer_which_t {
ITIMER_REAL = 0,
ITIMER_VIRTUAL = 1,
ITIMER_PROF = 2,
}
}
}
}

e! {
pub enum tpacket_versions {
TPACKET_V1,
Expand Down Expand Up @@ -6129,6 +6144,28 @@ extern "C" {
pub fn ioctl(fd: ::c_int, request: ::Ioctl, ...) -> ::c_int;
}

cfg_if! {
if #[cfg(target_env = "musl")] {
extern "C" {
pub fn getitimer(which: ::c_int, value: *mut ::itimerval) -> ::c_int;
pub fn setitimer(
which: ::c_int,
new: *const ::itimerval,
old: *mut ::itimerval,
) -> ::c_int;
}
} else {
extern "C" {
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
//
// * musl has 64-bit versions only so aliases the LFS64 symbols to the standard ones
Expand Down

0 comments on commit 7d33aff

Please sign in to comment.