Skip to content

Commit

Permalink
Fix macos error
Browse files Browse the repository at this point in the history
  • Loading branch information
wenyuzhao committed May 23, 2024
1 parent f869b9e commit 9efa3c9
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions mallockit/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ pub fn plan(_attr: TokenStream, item: TokenStream) -> TokenStream {
#[cfg(target_os = "macos")]
#[no_mangle]
extern "C" fn mallockit_initialize_macos_tls() -> *mut u8 {
<Plan as ::mallockit::Plan>::Mutator::current() as *mut ::mallockit::Mutator as _
use ::mallockit::mutator::TLS;
<Plan as ::mallockit::Plan>::Mutator::current() as *mut <Plan as ::mallockit::Plan>::Mutator as _
}

impl ::mallockit::plan::Singleton for super::#name {
Expand Down Expand Up @@ -57,22 +58,19 @@ pub fn mutator(_attr: TokenStream, item: TokenStream) -> TokenStream {
#[repr(align(256))]
#input

#[cfg(not(target_os = "macos"))]
mod __mallockit_mutator {
#[thread_local]
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 super::#name {
fn new() -> Self {
<Self as ::mallockit::Mutator>::new()
}
impl ::mallockit::mutator::TLS for #name {
fn new() -> Self {
<Self as ::mallockit::Mutator>::new()
}

#[cfg(not(target_os = "macos"))]
fn current() -> &'static mut Self {
unsafe { &mut *MUTATOR }
}
#[cfg(not(target_os = "macos"))]
fn current() -> &'static mut Self {
#[thread_local]
static mut MUTATOR: ::mallockit::util::Lazy<#name, ::mallockit::util::Local> = ::mallockit::util::Lazy::new(|| <#name as ::mallockit::Mutator>::new());
unsafe { &mut * MUTATOR }
}
}

};
result.into()
}
Expand Down

0 comments on commit 9efa3c9

Please sign in to comment.