Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
wenyuzhao committed May 23, 2024
1 parent ad9897b commit 429d239
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions mallockit/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn plan(_attr: TokenStream, item: TokenStream) -> TokenStream {
mod __mallockit_plan {
type Plan = super::#name;

pub(super) static PLAN: ::mallockit::util::Lazy<Plan> = ::mallockit::util::Lazy::new(|| <Plan as ::mallockit::Plan>::new());
static PLAN: ::mallockit::util::Lazy<Plan> = ::mallockit::util::Lazy::new(|| <Plan as ::mallockit::Plan>::new());

#[cfg(any(feature = "malloc", feature = "mallockit/malloc"))]
#[::mallockit::ctor]
Expand All @@ -21,7 +21,7 @@ pub fn plan(_attr: TokenStream, item: TokenStream) -> TokenStream {

#[cfg(target_os = "macos")]
#[no_mangle]
pub extern "C" fn mallockit_initialize_macos_tls() -> *mut u8 {
extern "C" fn mallockit_initialize_macos_tls() -> *mut u8 {
<Plan as ::mallockit::Plan>::Mutator::current() as *mut ::mallockit::Mutator as _
}

Expand Down Expand Up @@ -60,17 +60,17 @@ pub fn mutator(_attr: TokenStream, item: TokenStream) -> TokenStream {
#[cfg(not(target_os = "macos"))]
mod __mallockit_mutator {
#[thread_local]
pub(super) static mut MUTATOR: ::mallockit::util::Lazy<super::#name, ::mallockit::util::Local> = ::mallockit::util::Lazy::new(|| <super::#name as ::mallockit::Mutator>::new());
}
static mut MUTATOR: ::mallockit::util::Lazy<super::#name, ::mallockit::util::Local> = ::mallockit::util::Lazy::new(|| <super::#name as ::mallockit::Mutator>::new());

impl ::mallockit::mutator::TLS for #name {
fn new() -> Self {
<Self as ::mallockit::Mutator>::new()
}
impl ::mallockit::mutator::TLS for super::#name {
fn new() -> Self {
<Self as ::mallockit::Mutator>::new()
}

#[cfg(not(target_os = "macos"))]
fn current() -> &'static mut Self {
unsafe { &mut *__mallockit_mutator::MUTATOR }
#[cfg(not(target_os = "macos"))]
fn current() -> &'static mut Self {
unsafe { &mut *MUTATOR }
}
}
}
};
Expand Down

0 comments on commit 429d239

Please sign in to comment.