Skip to content

Commit

Permalink
aya: import types from std::ffi rather than libc
Browse files Browse the repository at this point in the history
  • Loading branch information
tamird committed Oct 11, 2023
1 parent ef27bce commit 5cdd1ba
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions aya/src/maps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
//! implement the [Pod] trait.
use std::{
borrow::BorrowMut,
ffi::CString,
ffi::{c_long, CString},
fmt, io,
marker::PhantomData,
mem,
Expand Down Expand Up @@ -122,7 +122,7 @@ pub enum MapError {
/// Map name
name: String,
/// Error code
code: libc::c_long,
code: c_long,
#[source]
/// Original io::Error
io_error: io::Error,
Expand Down
4 changes: 2 additions & 2 deletions aya/src/maps/perf/perf_buffer.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::{
ffi::c_void,
ffi::{c_int, c_void},
io, mem,
os::fd::{AsFd, AsRawFd, BorrowedFd, OwnedFd, RawFd},
ptr, slice,
sync::atomic::{self, AtomicPtr, Ordering},
};

use bytes::BytesMut;
use libc::{c_int, munmap, MAP_FAILED, MAP_SHARED, PROT_READ, PROT_WRITE};
use libc::{munmap, MAP_FAILED, MAP_SHARED, PROT_READ, PROT_WRITE};
use thiserror::Error;

use crate::{
Expand Down
4 changes: 2 additions & 2 deletions aya/src/sys/bpf.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::{
cmp,
ffi::{CStr, CString},
ffi::{c_char, c_long, CStr, CString},
io, iter,
mem::{self, MaybeUninit},
os::fd::{AsFd as _, AsRawFd as _, BorrowedFd, FromRawFd as _, OwnedFd, RawFd},
slice,
};

use assert_matches::assert_matches;
use libc::{c_char, c_long, ENOENT, ENOSPC};
use libc::{ENOENT, ENOSPC};
use obj::{
btf::{BtfEnum64, Enum64},
maps::{bpf_map_def, LegacyMap},
Expand Down
8 changes: 5 additions & 3 deletions aya/src/sys/fake.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::{cell::RefCell, ffi::c_long, io, ptr};

use libc::c_void;
use std::{
cell::RefCell,
ffi::{c_long, c_void},
io, ptr,
};

use super::{SysResult, Syscall};

Expand Down
3 changes: 2 additions & 1 deletion aya/src/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ mod perf_event;
mod fake;

use std::{
ffi::{c_int, c_long},
io, mem,
os::fd::{AsRawFd as _, BorrowedFd},
};

pub(crate) use bpf::*;
#[cfg(test)]
pub(crate) use fake::*;
use libc::{c_int, c_long, pid_t, SYS_bpf, SYS_perf_event_open};
use libc::{pid_t, SYS_bpf, SYS_perf_event_open};
#[doc(hidden)]
pub use netlink::netlink_set_link_up;
pub(crate) use netlink::*;
Expand Down
4 changes: 2 additions & 2 deletions aya/src/sys/perf_event.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::{
ffi::{c_long, CString, OsStr},
ffi::{c_int, c_long, CString, OsStr},
io, mem,
os::fd::{BorrowedFd, FromRawFd as _, OwnedFd},
};

use libc::{c_int, pid_t};
use libc::pid_t;

use super::{syscall, SysResult, Syscall};
use crate::generated::{
Expand Down
2 changes: 1 addition & 1 deletion xtask/public-api/aya.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ impl<T> core::convert::From<T> for aya::maps::Map
pub fn aya::maps::Map::from(t: T) -> T
pub enum aya::maps::MapError
pub aya::maps::MapError::CreateError
pub aya::maps::MapError::CreateError::code: libc::unix::linux_like::linux::gnu::b64::x86_64::not_x32::c_long
pub aya::maps::MapError::CreateError::code: core::ffi::c_long
pub aya::maps::MapError::CreateError::io_error: std::io::error::Error
pub aya::maps::MapError::CreateError::name: alloc::string::String
pub aya::maps::MapError::ElementNotFound
Expand Down

0 comments on commit 5cdd1ba

Please sign in to comment.