|
| 1 | +// Copyright (c) 2019 Wind River Systems, Inc. |
| 2 | + |
1 | 3 | #![cfg(target_thread_local)] |
2 | 4 | #![unstable(feature = "thread_local_internals", issue = "0")] |
3 | 5 |
|
4 | | -// Since what appears to be glibc 2.18 this symbol has been shipped which |
5 | | -// GCC and clang both use to invoke destructors in thread_local globals, so |
6 | | -// let's do the same! |
7 | | -// |
8 | | -// Note, however, that we run on lots older linuxes, as well as cross |
9 | | -// compiling from a newer linux to an older linux, so we also have a |
10 | | -// fallback implementation to use as well. |
11 | | -// |
12 | | -// Due to rust-lang/rust#18804, make sure this is not generic! |
13 | 6 | pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) { |
14 | | - use crate::mem; |
15 | 7 | use crate::sys_common::thread_local::register_dtor_fallback; |
16 | | - |
17 | | - extern { |
18 | | - #[linkage = "extern_weak"] |
19 | | - static __dso_handle: *mut u8; |
20 | | - #[linkage = "extern_weak"] |
21 | | - static __cxa_thread_atexit_impl: *const libc::c_void; |
22 | | - } |
23 | | - if !__cxa_thread_atexit_impl.is_null() { |
24 | | - type F = unsafe extern fn(dtor: unsafe extern fn(*mut u8), |
25 | | - arg: *mut u8, |
26 | | - dso_handle: *mut u8) -> libc::c_int; |
27 | | - mem::transmute::<*const libc::c_void, F>(__cxa_thread_atexit_impl) |
28 | | - (dtor, t, &__dso_handle as *const _ as *mut _); |
29 | | - return |
30 | | - } |
31 | 8 | register_dtor_fallback(t, dtor); |
32 | 9 | } |
33 | 10 |
|
|
0 commit comments