use super::TRACKER;
pub fn track_raw_ptr<T: ?Sized>(
#[cfg_attr(not(feature = "track"), allow(unused_variables))] var_name: &str,
#[cfg_attr(not(feature = "track"), allow(unused_variables))] var_id: usize,
#[cfg_attr(not(feature = "track"), allow(unused_variables))] ptr_type: &str,
#[cfg_attr(not(feature = "track"), allow(unused_variables))] location: &str,
ptr: *const T,
) -> *const T {
#[cfg(feature = "track")]
{
let mut tracker = TRACKER.lock();
tracker.record_raw_ptr_created(
var_name,
var_id,
ptr_type,
ptr as *const () as usize,
location,
);
}
ptr
}
#[inline(always)]
pub fn track_raw_ptr_mut<T: ?Sized>(
#[cfg_attr(not(feature = "track"), allow(unused_variables))] var_name: &str,
#[cfg_attr(not(feature = "track"), allow(unused_variables))] var_id: usize,
#[cfg_attr(not(feature = "track"), allow(unused_variables))] ptr_type: &str,
#[cfg_attr(not(feature = "track"), allow(unused_variables))] location: &str,
ptr: *mut T,
) -> *mut T {
#[cfg(feature = "track")]
{
let mut tracker = TRACKER.lock();
tracker.record_raw_ptr_created(
var_name,
var_id,
ptr_type,
ptr as *const () as usize,
location,
);
}
ptr
}
#[inline(always)]
pub fn track_raw_ptr_deref(
#[cfg_attr(not(feature = "track"), allow(unused_variables))] ptr_id: usize,
#[cfg_attr(not(feature = "track"), allow(unused_variables))] location: &str,
#[cfg_attr(not(feature = "track"), allow(unused_variables))] is_write: bool,
) {
#[cfg(feature = "track")]
{
let mut tracker = TRACKER.lock();
tracker.record_raw_ptr_deref(ptr_id, location, is_write);
}
}
#[inline(always)]
pub fn track_unsafe_block_enter(
#[cfg_attr(not(feature = "track"), allow(unused_variables))] block_id: usize,
#[cfg_attr(not(feature = "track"), allow(unused_variables))] location: &str,
) {
#[cfg(feature = "track")]
{
let mut tracker = TRACKER.lock();
tracker.record_unsafe_block_enter(block_id, location);
}
}
#[inline(always)]
pub fn track_unsafe_block_exit(
#[cfg_attr(not(feature = "track"), allow(unused_variables))] block_id: usize,
#[cfg_attr(not(feature = "track"), allow(unused_variables))] location: &str,
) {
#[cfg(feature = "track")]
{
let mut tracker = TRACKER.lock();
tracker.record_unsafe_block_exit(block_id, location);
}
}
#[inline(always)]
pub fn track_unsafe_fn_call(
#[cfg_attr(not(feature = "track"), allow(unused_variables))] fn_name: &str,
#[cfg_attr(not(feature = "track"), allow(unused_variables))] location: &str,
) {
#[cfg(feature = "track")]
{
let mut tracker = TRACKER.lock();
tracker.record_unsafe_fn_call(fn_name, location);
}
}
#[inline(always)]
pub fn track_ffi_call(
#[cfg_attr(not(feature = "track"), allow(unused_variables))] fn_name: &str,
#[cfg_attr(not(feature = "track"), allow(unused_variables))] location: &str,
) {
#[cfg(feature = "track")]
{
let mut tracker = TRACKER.lock();
tracker.record_ffi_call(fn_name, location);
}
}
#[inline(always)]
pub fn track_transmute(
#[cfg_attr(not(feature = "track"), allow(unused_variables))] from_type: &str,
#[cfg_attr(not(feature = "track"), allow(unused_variables))] to_type: &str,
#[cfg_attr(not(feature = "track"), allow(unused_variables))] location: &str,
) {
#[cfg(feature = "track")]
{
let mut tracker = TRACKER.lock();
tracker.record_transmute(from_type, to_type, location);
}
}
#[inline(always)]
pub fn track_union_field_access(
#[cfg_attr(not(feature = "track"), allow(unused_variables))] union_name: &str,
#[cfg_attr(not(feature = "track"), allow(unused_variables))] field_name: &str,
#[cfg_attr(not(feature = "track"), allow(unused_variables))] location: &str,
) {
#[cfg(feature = "track")]
{
let mut tracker = TRACKER.lock();
tracker.record_union_field_access(union_name, field_name, location);
}
}