From 03a891011f70a7f2a67b40c8197ae8d83bfd4e38 Mon Sep 17 00:00:00 2001 From: Simone Margaritelli Date: Fri, 2 Jul 2021 14:44:58 +0200 Subject: [PATCH] fix: replaced custom type defintions with proper libc types --- aya/src/maps/mod.rs | 9 ++------- aya/src/maps/perf/perf_buffer.rs | 7 +------ aya/src/sys/mod.rs | 7 +------ 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/aya/src/maps/mod.rs b/aya/src/maps/mod.rs index d1afec77..b5012a61 100644 --- a/aya/src/maps/mod.rs +++ b/aya/src/maps/mod.rs @@ -65,11 +65,6 @@ pub use sock::{SockHash, SockMap}; pub use stack::Stack; pub use stack_trace::StackTraceMap; -#[cfg(target_pointer_width = "32")] -type CodeType = i32; -#[cfg(target_pointer_width = "64")] -type CodeType = i64; - #[derive(Error, Debug)] pub enum MapError { #[error("map `{name}` not found ")] @@ -90,7 +85,7 @@ pub enum MapError { #[error("failed to create map `{name}`: {code}")] CreateError { name: String, - code: CodeType, + code: libc::c_long, io_error: io::Error, }, @@ -115,7 +110,7 @@ pub enum MapError { #[error("the `{call}` syscall failed with code {code} io_error {io_error}")] SyscallError { call: String, - code: CodeType, + code: libc::c_long, io_error: io::Error, }, diff --git a/aya/src/maps/perf/perf_buffer.rs b/aya/src/maps/perf/perf_buffer.rs index 00771609..bdab9325 100644 --- a/aya/src/maps/perf/perf_buffer.rs +++ b/aya/src/maps/perf/perf_buffer.rs @@ -273,11 +273,6 @@ impl Drop for PerfBuffer { } } -#[cfg(target_pointer_width = "32")] -type OffsetType = i32; -#[cfg(target_pointer_width = "64")] -type OffsetType = i64; - #[cfg_attr(test, allow(unused_variables))] unsafe fn mmap( addr: *mut c_void, @@ -285,7 +280,7 @@ unsafe fn mmap( prot: c_int, flags: c_int, fd: i32, - offset: OffsetType, + offset: libc::off_t, ) -> *mut c_void { #[cfg(not(test))] return libc::mmap(addr, len, prot, flags, fd, offset); diff --git a/aya/src/sys/mod.rs b/aya/src/sys/mod.rs index e788ff69..deee918f 100644 --- a/aya/src/sys/mod.rs +++ b/aya/src/sys/mod.rs @@ -49,11 +49,6 @@ fn syscall(call: Syscall) -> SysResult { return TEST_SYSCALL.with(|test_impl| unsafe { test_impl.borrow()(call) }); } -#[cfg(target_pointer_width = "32")] -type RetType = i32; -#[cfg(target_pointer_width = "64")] -type RetType = i64; - #[cfg(not(test))] unsafe fn syscall_impl(call: Syscall) -> SysResult { use libc::{SYS_bpf, SYS_perf_event_open}; @@ -69,7 +64,7 @@ unsafe fn syscall_impl(call: Syscall) -> SysResult { flags, } => libc::syscall(SYS_perf_event_open, &attr, pid, cpu, group, flags), PerfEventIoctl { fd, request, arg } => { - libc::ioctl(fd, request.try_into().unwrap(), arg) as RetType + libc::ioctl(fd, request.try_into().unwrap(), arg) as libc::c_long } };