Commit 5a3e2f07 authored by Sven Liefgen's avatar Sven Liefgen
Browse files

Move unsafe into macro

parent 2b11e197
use std::time::Instant;
#[cfg(feature = "xlap")]
use std::{
convert::AsRef,
io::prelude::*,
sync::atomic::{AtomicPtr, Ordering},
};
use std::time::Instant;
#[cfg(feature = "xlap")]
use strum::{AsRefStr, EnumCount, EnumIter, IntoEnumIterator};
......@@ -15,7 +15,10 @@ use core::arch::x86::_rdtsc as current_cycle;
#[cfg(all(target_arch = "x86_64", feature = "xlap"))]
use core::arch::x86_64::_rdtsc as current_cycle;
// On all other architectures there is no cycle counting, so just set it to zero
#[cfg(all(not(any(target_arch = "x86", target_arch = "x86_64")), feature = "xlap"))]
#[cfg(all(
not(any(target_arch = "x86", target_arch = "x86_64")),
feature = "xlap"
))]
#[inline(always)]
pub unsafe fn current_cycle() -> u64 {
0
......@@ -70,7 +73,9 @@ static mut ZERO: Option<Instant> = None;
macro_rules! set_timestamp {
( $kind:expr, $row: expr, $id:expr, $stamp:expr ) => {
#[cfg(feature = "xlap")]
$crate::set_timestamp($kind, $row, $id, $stamp);
unsafe {
$crate::set_timestamp($kind, $row, $id, $stamp);
}
};
}
......@@ -86,7 +91,9 @@ pub unsafe fn set_timestamp(kind: Kind, row: usize, id: TimestampId, (t, c): (In
macro_rules! set_timestamp_clock {
( $kind:expr, $row:expr, $id:expr, $value:expr ) => {
#[cfg(feature = "xlap")]
$crate::set_timestamp_clock($kind, $row, $id, $value);
unsafe {
$crate::set_timestamp_clock($kind, $row, $id, $value);
}
};
}
......@@ -102,7 +109,9 @@ pub unsafe fn set_timestamp_clock(kind: Kind, row: usize, id: TimestampId, value
macro_rules! set_timestamp_cycle {
( $kind:expr, $row:expr, $id:expr, $value:expr ) => {
#[cfg(feature = "xlap")]
$crate::set_timestamp_cycle($kind, $row, $id, $value);
unsafe {
$crate::set_timestamp_cycle($kind, $row, $id, $value);
}
};
}
......@@ -118,7 +127,9 @@ pub unsafe fn set_timestamp_cycle(kind: Kind, row: usize, id: TimestampId, value
macro_rules! timestamp_clock {
( $kind:expr, $row:expr, $id:expr ) => {
#[cfg(feature = "xlap")]
$crate::timestamp_clock($kind, $row, $id);
unsafe {
$crate::timestamp_clock($kind, $row, $id);
}
};
}
......@@ -134,7 +145,9 @@ pub unsafe fn timestamp_clock(kind: Kind, row: usize, id: TimestampId) {
macro_rules! timestamp_cycle {
( $kind:expr, $row:expr, $id:expr ) => {
#[cfg(feature = "xlap")]
$crate::timestamp_cycle($kind, $row, $id);
unsafe {
$crate::timestamp_cycle($kind, $row, $id);
}
};
}
......@@ -185,7 +198,9 @@ pub fn get_timestamp_cycle() -> u64 {
macro_rules! init {
() => {
#[cfg(feature = "xlap")]
$crate::init();
unsafe {
$crate::init();
}
};
}
......@@ -211,9 +226,9 @@ macro_rules! kind {
#[cfg(feature = "xlap")]
{ $kind }
#[cfg(not(feature = "xlap"))]
{ $crate::Kind::NoKind }
$crate::Kind::NoKind
}
}
};
}
#[cfg(feature = "xlap")]
......@@ -234,7 +249,9 @@ pub unsafe fn init() {
macro_rules! dump_all {
( $file:expr ) => {
#[cfg(feature = "xlap")]
$crate::TimestampTable::dump_all($file)
unsafe {
$crate::TimestampTable::dump_all($file)
}
};
}
......@@ -243,7 +260,9 @@ macro_rules! dump_all {
macro_rules! dump {
( $file:expr, $tables:expr ) => {
#[cfg(feature = "xlap")]
$crate::TimestampTable::dump($file, $tables)
unsafe {
$crate::TimestampTable::dump($file, $tables)
}
};
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment