Skip to content

Commit 3059f60

Browse files
CoAlloc: sys ... thread dtor: minor
1 parent 9d808d1 commit 3059f60

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

library/std/src/sys/unix/thread_local_dtor.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
#![cfg(target_thread_local)]
22
#![unstable(feature = "thread_local_internals", issue = "none")]
3-
#![feature(global_co_alloc_plvec)]
43

54
//! Provides thread-local destructors without an associated "key", which
65
//! can be more efficient.
76
8-
use core::alloc::PlVec;
9-
107
// Since what appears to be glibc 2.18 this symbol has been shipped which
118
// GCC and clang both use to invoke destructors in thread_local globals, so
129
// let's do the same!
@@ -74,6 +71,15 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
7471
REGISTERED.set(true);
7572
}
7673

74+
type List = alloc::vec::PlVec<(*mut u8, unsafe extern "C" fn(*mut u8))>;
75+
76+
#[thread_local]
77+
static DTORS: Cell<*mut List> = Cell::new(ptr::null_mut());
78+
if DTORS.get().is_null() {
79+
let v: Box<List> = box Vec::new();
80+
DTORS.set(Box::into_raw(v));
81+
}
82+
7783
extern "C" {
7884
fn _tlv_atexit(dtor: unsafe extern "C" fn(*mut u8), arg: *mut u8);
7985
}

library/std/src/sys_common/thread_local_dtor.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
1313
#![unstable(feature = "thread_local_internals", issue = "none")]
1414
#![allow(dead_code)]
15-
#![feature(global_co_alloc_plvec)]
1615

1716
use crate::ptr;
1817
use crate::sys_common::thread_local_key::StaticKey;

0 commit comments

Comments
 (0)