perf_map: implement AsRawFd

pull/1/head
Alessandro Decina 4 years ago
parent 5d6fe8bdf4
commit 95a24c6f8b

@ -3,6 +3,7 @@ use std::{
ffi::c_void,
io, mem,
ops::DerefMut,
os::unix::prelude::AsRawFd,
ptr, slice,
sync::{
atomic::{self, AtomicPtr, Ordering},
@ -239,6 +240,12 @@ impl PerfBuffer {
}
}
impl AsRawFd for PerfBuffer {
fn as_raw_fd(&self) -> RawFd {
self.fd
}
}
impl Drop for PerfBuffer {
fn drop(&mut self) {
unsafe {
@ -290,6 +297,12 @@ impl<T: DerefMut<Target = Map>> PerfMapBuffer<T> {
}
}
impl<T: DerefMut<Target = Map>> AsRawFd for PerfMapBuffer<T> {
fn as_raw_fd(&self) -> RawFd {
self.buf.as_raw_fd()
}
}
pub struct PerfMap<T: DerefMut<Target = Map>> {
map: Arc<T>,
page_size: usize,

Loading…
Cancel
Save