-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Cleanup TLS implementation #102656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup TLS implementation #102656
Conversation
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
(rust-highfive has picked a reviewer for you, use r? to override) |
@@ -6,8 +6,23 @@ pub type Key = libc::pthread_key_t; | |||
|
|||
#[inline] | |||
pub unsafe fn create(dtor: Option<unsafe extern "C" fn(*mut u8)>) -> Key { | |||
let dtor = mem::transmute(dtor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we annotate the type on dtor
explicitly?
I'm not sure if it makes sense to move this into the unix module -- it seems likely to be fairly harmless on SGX, and it would mean that we need to remember to check this on all future impls of the thread local key module for future platforms. I would feel better if the debug assert was a regular assert, but not sure I'm sold on the benefit here yet. |
☔ The latest upstream changes (presumably #102655) made this pull request unmergeable. Please resolve the merge conflicts. |
I'm in the process of adding ELF TLS support to SGX, which would make UNIX the only target using the current implementation. I'll make another PR moving |
The previous implementation checked for keys with value zero on every platform except Windows, even though it is only necessary on UNIX (SGX does not hand out 0-keys and all other platforms panic anyway).