#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use libc::pid_t;
use std::os::raw::{c_int, c_ulong};
pub unsafe fn perf_event_open(
attrs: *mut bindings::perf_event_attr,
pid: pid_t,
cpu: c_int,
group_fd: c_int,
flags: c_ulong,
) -> c_int {
unsafe {
libc::syscall(
bindings::__NR_perf_event_open as libc::c_long,
attrs as *const bindings::perf_event_attr,
pid,
cpu,
group_fd,
flags,
) as c_int
}
}
pub mod bindings {
include!(concat!(env!("OUT_DIR"), "/perf_bindings.rs"));
}
pub mod ioctls {
use crate::perf;
use std::os::raw::{c_int, c_uint};
#[allow(clippy::missing_safety_doc)]
pub unsafe fn enable(fd: c_int, arg: c_uint) -> c_int {
unsafe { libc::ioctl(fd, perf::bindings::ENABLE as libc::Ioctl, arg) }
}
#[allow(clippy::missing_safety_doc)]
pub unsafe fn reset(fd: c_int, arg: c_uint) -> c_int {
unsafe { libc::ioctl(fd, perf::bindings::RESET as libc::Ioctl, arg) }
}
}