Skip to content

Commit

Permalink
Auto merge of #125525 - joboet:tls_accessor, r=cuviper
Browse files Browse the repository at this point in the history
Make TLS accessors closures that return pointers

The current TLS macros generate a function that returns an `Option<&'static T>`. This is both risky as we lie about lifetimes, and necessitates that those functions are `unsafe`. By returning a `*const T` instead, the accessor function do not have safety requirements any longer and can be made closures without hassle. This PR does exactly that!

For native TLS, the closure approach makes it trivial to select the right accessor function at compile-time, which could result in a slight speed-up (I have the hope that the accessors are now simple enough for the MIR-inliner to kick in).
  • Loading branch information
bors committed Jun 4, 2024
2 parents 1f3fdbe + 7960cd7 commit c2f6d56
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit c2f6d56

Please sign in to comment.