about summary refs log tree commit diff
path: root/library/std/src/thread/local.rs
AgeCommit message (Collapse)AuthorLines
2022-05-01Fix some links in the standard libraryVadim Petrochenkov-0/+2
2022-04-17Revert "Auto merge of #94373 - erikdesjardins:getitinl, r=Mark-Simulacrum"Erik Desjardins-2/+2
This reverts commit 035a717ee8bf548868fb50b5c7ca562fc4a657a7, reversing changes made to 761e8884858759b21f3374ad610494e68c087a38.
2022-04-12Add missing unsafe marker.Mara Bos-1/+1
This is now necessary because of deny(unsafe_op_in_unsafe_fn).
2022-04-12Add #[deny(unsafe_op_in_unsafe_fn)] to thread_local!(const).Mara Bos-0/+1
This avoids 'unused unsafe' warnings when using this feature inside std.
2022-04-07Use gender neutral termsJames 'zofrex' Sanderson-1/+1
2022-04-02Refer to u8 by absolute path in expansion of thread_localDavid Tolnay-3/+3
2022-04-01Fix `thread_local!` macro to be compatible with `no_implicit_prelude`niluxv-8/+8
Fixes issue #95533
2022-03-29Make the stdlib largely conform to strict provenance.Aria Beingessner-3/+3
Some things like the unwinders and system APIs are not fully conformant, this only covers a lot of low-hanging fruit.
2022-03-05Small fixes in thread local code.Mara Bos-2/+2
2022-03-05Update documentation in thread/local.rs.Mara Bos-6/+26
2022-03-05Add debug asserts in thread local cell set methods.Mara Bos-0/+4
2022-03-05Add tracking issue number for local_key_cell_methods.Mara Bos-9/+9
2022-03-05Rename LocalKey's with_{ref,mut} to with_borrow{,_mut}.Mara Bos-9/+9
2022-03-05Implement RFC 3184 - thread local cell methods.Mara Bos-10/+347
2022-02-25Make TLS __getit #[inline(always)] on non-WindowsErik Desjardins-2/+2
This may improve perf.
2022-01-06Add diagnostic items for macrosAlex Macleod-0/+1
2021-12-14Fix a bunch of typosFrank Steffahn-2/+2
2021-12-05Rollup merge of #91355 - alexcrichton:stabilize-thread-local-const, r=m-ou-seMatthias Krüger-1/+0
std: Stabilize the `thread_local_const_init` feature This commit is intended to follow the stabilization disposition of the FCP that has now finished in #84223. This stabilizes the ability to flag thread local initializers as `const` expressions which enables the macro to generate more efficient code for accessing it, notably removing runtime checks for initialization. More information can also be found in #84223 as well as the tests where the feature usage was removed in this PR. Closes #84223
2021-12-02Document Windows TLS drop behaviourChris Denton-0/+14
2021-11-29std: Stabilize the `thread_local_const_init` featureAlex Crichton-1/+0
This commit is intended to follow the stabilization disposition of the FCP that has now finished in #84223. This stabilizes the ability to flag thread local initializers as `const` expressions which enables the macro to generate more efficient code for accessing it, notably removing runtime checks for initialization. More information can also be found in #84223 as well as the tests where the feature usage was removed in this PR. Closes #84223
2021-11-18Auto merge of #90774 - alexcrichton:tweak-const, r=m-ou-sebors-6/+6
std: Tweak expansion of thread-local const This commit tweaks the expansion of `thread_local!` when combined with a `const { ... }` value to help ensure that the rules which apply to `const { ... }` blocks will be the same as when they're stabilized. Previously with this invocation: thread_local!(static NAME: Type = const { init_expr }); this would generate (on supporting platforms): #[thread_local] static NAME: Type = init_expr; instead the macro now expands to: const INIT_EXPR: Type = init_expr; #[thread_local] static NAME: Type = INIT_EXPR; with the hope that because `init_expr` is defined as a `const` item then it's not accidentally allowing more behavior than if it were put into a `static`. For example on the stabilization issue [this example][ex] now gives the same error both ways. [ex]: https://github.com/rust-lang/rust/issues/84223#issuecomment-953384298
2021-11-10std: Tweak expansion of thread-local constAlex Crichton-6/+6
This commit tweaks the expansion of `thread_local!` when combined with a `const { ... }` value to help ensure that the rules which apply to `const { ... }` blocks will be the same as when they're stabilized. Previously with this invocation: thread_local!(static NAME: Type = const { init_expr }); this would generate (on supporting platforms): #[thread_local] static NAME: Type = init_expr; instead the macro now expands to: const INIT_EXPR: Type = init_expr; #[thread_local] static NAME: Type = INIT_EXPR; with the hope that because `init_expr` is defined as a `const` item then it's not accidentally allowing more behavior than if it were put into a `static`. For example on the stabilization issue [this example][ex] now gives the same error both ways. [ex]: https://github.com/rust-lang/rust/issues/84223#issuecomment-953384298
2021-11-10Review commentsAlex Crichton-1/+1
2021-11-10Use `target_family = "wasm"`Alex Crichton-13/+7
2021-11-10std: Get the standard library compiling for wasm64Alex Crichton-8/+14
This commit goes through and updates various `#[cfg]` as appropriate to get the wasm64-unknown-unknown target behaving similarly to the wasm32-unknown-unknown target. Most of this is just updating various conditions for `target_arch = "wasm32"` to also account for `target_arch = "wasm64"` where appropriate. This commit also lists `wasm64` as an allow-listed architecture to not have the `restricted_std` feature enabled, enabling experimentation with `-Z build-std` externally. The main goal of this commit is to enable playing around with `wasm64-unknown-unknown` externally via `-Z build-std` in a way that's similar to the `wasm32-unknown-unknown` target. These targets are effectively the same and only differ in their pointer size, but wasm64 is much newer and has much less ecosystem/library support so it'll still take time to get wasm64 fully-fledged.
2021-06-24Use `#[non_exhaustive]` where appropriateJacob Pratt-4/+3
Due to the std/alloc split, it is not possible to make `alloc::collections::TryReserveError::AllocError` non-exhaustive without having an unstable, doc-hidden method to construct (which negates the benefits from `#[non_exhaustive]`.
2021-05-20std: Don't inline TLS accessor on MinGWAlex Crichton-13/+13
This is causing [issues] on Cargo's own CI for MinGW and given the original investigation there's no reason that MinGW should work when MSVC doesn't, this this tweaks the MSVC exception to being a Windows exception. [issues]: https://github.com/rust-lang/cargo/runs/2626676503?check_suite_focus=true#step:9:2453
2021-05-18std: Attempt again to inline thread-local-init across cratesAlex Crichton-0/+24
Issue #25088 has been part of `thread_local!` for quite some time now. Historical attempts have been made to add `#[inline]` to `__getit` in #43931, #50252, and #59720, but these attempts ended up not landing at the time due to segfaults on Windows. In the interim though with `const`-initialized thread locals AFAIK this is the only remaining bug which is why you might want to use `#[thread_local]` over `thread_local!`. As a result I figured it was time to resubmit this and see how it fares on CI and if I can help debugging any issues that crop up. Closes #25088
2021-05-02Change 'NULL' to 'null'Brent Kerby-1/+1
2021-04-21Rollup merge of #84013 - CDirkx:fmt, r=m-ou-seMara Bos-4/+4
Replace all `fmt.pad` with `debug_struct` This replaces any occurrence of: - `f.pad("X")` with `f.debug_struct("X").finish()` - `f.pad("X { .. }")` with `f.debug_struct("X").finish_non_exhaustive()` This is in line with existing formatting code such as https://github.com/rust-lang/rust/blob/125505306744a0a5bb01d62337260a95d9ff8d57/library/std/src/sync/mpsc/mod.rs#L1470-L1475
2021-04-21Replace all `fmt.pad` with `debug_struct`Christiaan Dirkx-4/+4
2021-04-18fix aliasing violations in thread_local_const_initRalf Jung-1/+1
2021-04-16std: Add a variant of thread locals with const initAlex Crichton-2/+115
This commit adds a variant of the `thread_local!` macro as a new `thread_local_const_init!` macro which requires that the initialization expression is constant (e.g. could be stuck into a `const` if so desired). This form of thread local allows for a more efficient implementation of `LocalKey::with` both if the value has a destructor and if it doesn't. If the value doesn't have a destructor then `with` should desugar to exactly as-if you use `#[thread_local]` given sufficient inlining. The purpose of this new form of thread locals is to precisely be equivalent to `#[thread_local]` on platforms where possible for values which fit the bill (those without destructors). This should help close the gap in performance between `thread_local!`, which is safe, relative to `#[thread_local]`, which is not easy to use in a portable fashion.
2020-11-07Convert a bunch of intra-doc linksCamelid-1/+1
2020-09-26Auto merge of #74225 - poliorcetics:std-thread-unsafe-op-in-unsafe-fn, ↵bors-36/+107
r=joshtriplett Std/thread: deny unsafe op in unsafe fn Partial fix of #73904. This encloses `unsafe` operations in `unsafe fn` in `libstd/thread`. `@rustbot` modify labels: F-unsafe-block-in-unsafe-fn
2020-09-22Update library functions with stability attributesDylan MacKenzie-0/+2
This may not be strictly minimal, but all unstable functions also need a `rustc_const_unstable` attribute.
2020-09-21Fix missing unsafe block for target arch wasm32Alexis Bourget-3/+10
2020-09-21Fix accordingly to reviewAlexis Bourget-22/+20
2020-09-21Improve some SAFETY comments following suggestionsAlexis Bourget-6/+17
2020-09-21Finished documenting all unsafe op inside unsafe fnAlexis Bourget-5/+17
2020-09-21Deny unsafe op in unsafe fns without the unsafe keyword, first part for ↵Alexis Bourget-28/+71
std/thread
2020-09-03Use inline(never) instead of coldHoward Su-3/+2
inline(never) is better way to avoid optimizer to inline the function instead of cold.
2020-08-31std: move "mod tests/benches" to separate filesLzu Tao-200/+6
Also doing fmt inplace as requested.
2020-08-20Move to intra doc links for std::thread documentationAlexis Bourget-5/+3
2020-07-29Disallow missing unsafe blocks in unsafe fn in panicking.rsAlexis Bourget-1/+5
This adds SAFETY comments where necessary, explaining the preconditions and how they are respected.
2020-07-27mv std libs to library/mark-0/+747