Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wenyuzhao committed Jul 1, 2024
1 parent 7820a00 commit dd62db3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mallockit/src/mutator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ mod macos_tls {
}
}

static mut TLS_KEY: libc::pthread_key_t = u32::MAX;
static mut TLS_KEY: libc::pthread_key_t = libc::pthread_key_t::MAX;

#[thread_local]
static X: usize = 0;
Expand All @@ -265,6 +265,6 @@ pub fn init_pthread_specific() {

pub(crate) fn init_pthread_key() {
unsafe {
libc::pthread_key_create(addr_of_mut!(TLS_KEY), Some(dtor));
libc::pthread_key_create(std::ptr::addr_of_mut!(TLS_KEY), Some(dtor));
}
}
3 changes: 3 additions & 0 deletions mallockit/src/util/lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ pub struct Lazy<T, TL: ThreadLocality = Shared, F = fn() -> T> {
}

impl<T, F: FnOnce() -> T> Lazy<T, Local, F> {
/// # Safety
///
/// This can only be called by pthread destructors, to clear the thread-local storage.
pub unsafe fn reset(&mut self, new: F) {
// Drop old value
if self.state.load(Ordering::SeqCst) == INITIALIZED {
Expand Down

0 comments on commit dd62db3

Please sign in to comment.