about summary refs log tree commit diff
path: root/src/libstd/sys/windows/thread_local.rs
AgeCommit message (Collapse)AuthorLines
2020-07-12rename fast_thread_local -> thread_local_dtor; thread_local -> thread_local_keyRalf Jung-236/+0
2019-11-29Format libstd/sys with rustfmtDavid Tolnay-15/+10
This commit applies rustfmt with rust-lang/rust's default settings to files in src/libstd/sys *that are not involved in any currently open PR* to minimize merge conflicts. THe list of files involved in open PRs was determined by querying GitHub's GraphQL API with this script: https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8 With the list of files from the script in outstanding_files, the relevant commands were: $ find src/libstd/sys -name '*.rs' \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ rg libstd/sys outstanding_files | xargs git checkout -- Repeating this process several months apart should get us coverage of most of the rest of the files. To confirm no funny business: $ git checkout $THIS_COMMIT^ $ git show --pretty= --name-only $THIS_COMMIT \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ git diff $THIS_COMMIT # there should be no difference
2019-10-22Apply clippy::needless_return suggestionsMateusz MikuĊ‚a-1/+1
2019-02-28libstd => 2018Taiki Endo-6/+6
2018-12-25Remove licensesMark Rousskov-10/+0
2017-11-24std: Flag Windows TLS dtor symbol as #[used]Alex Crichton-1/+2
Turns out ThinLTO was internalizing this symbol and eliminating it. Worse yet if you compiled with LTO turns out no TLS destructors would run on Windows! The `#[used]` annotation should be a more bulletproof implementation (in the face of LTO) of preserving this symbol all the way through in LLVM and ensuring it makes it all the way to the linker which will take care of it.
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-2/+2
Like #43008 (f668999), but _much more aggressive_.
2017-05-05std: Avoid locks during TLS destruction on WindowsAlex Crichton-99/+66
Gecko recently had a bug reported [1] with a deadlock in the Rust TLS implementation for Windows. TLS destructors are implemented in a sort of ad-hoc fashion on Windows as it doesn't natively support destructors for TLS keys. To work around this the runtime manages a list of TLS destructors and registers a hook to get run whenever a thread exits. When a thread exits it takes a look at the list and runs all destructors. Unfortunately it turns out that there's a lock which is held when our "at thread exit" callback is run. The callback then attempts to acquire a lock protecting the list of TLS destructors. Elsewhere in the codebase while we hold a lock over the TLS destructors we try to acquire the same lock held first before our special callback is run. And as a result, deadlock! This commit sidesteps the issue with a few small refactorings: * Removed support for destroying a TLS key on Windows. We don't actually ever exercise this as a public-facing API, and it's only used during `lazy_init` during racy situations. To handle that we just synchronize `lazy_init` globally on Windows so we never have to call `destroy`. * With no need to support removal the global synchronized `Vec` was tranformed to a lock-free linked list. With the removal of locks this means that iteration no long requires a lock and as such we won't run into the deadlock problem mentioned above. Note that it's still a general problem that you have to be extra super careful in TLS destructors. For example no code which runs a TLS destructor on Windows can call back into the Windows API to do a dynamic library lookup. Unfortunately I don't know of a great way around that, but this at least fixes the immediate problem that Gecko was seeing which is that with "well behaved" destructors the system would still deadlock! [1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1358151
2017-01-02Reword 'stupid' and 'crazy' in docs.Clar Charr-1/+1
2016-08-24Use `#[prelude_import]` in `libstd`.Jeffrey Seyfried-2/+0
2016-02-25Rollup merge of #31842 - dileepbapat:master, r=alexcrichtonManish Goregaokar-3/+2
I have made changes and built it after that. Please advise, https://github.com/rust-lang/rust/issues/31820
2016-02-23#31820 - Utilize `if..let` instead of single `match` branchdileepb-3/+2
2016-02-20Remove dead code from sys::windows::cPaul Dicker-2/+2
2015-11-09std: Migrate to the new libcAlex Crichton-27/+16
* Delete `sys::unix::{c, sync}` as these are now all folded into libc itself * Update all references to use `libc` as a result. * Update all references to the new flat namespace. * Moves all windows bindings into sys::c
2015-09-11std: Internalize almost all of `std::rt`Alex Crichton-2/+2
This commit does some refactoring to make almost all of the `std::rt` private. Specifically, the following items are no longer part of its API: * DEFAULT_ERROR_CODE * backtrace * unwind * args * at_exit * cleanup * heap (this is just alloc::heap) * min_stack * util The module is now tagged as `#[doc(hidden)]` as the only purpose it's serve is an entry point for the `panic!` macro via the `begin_unwind` and `begin_unwind_fmt` reexports.
2015-09-03Use `null()`/`null_mut()` instead of `0 as *const T`/`0 as *mut T`Vadim Petrochenkov-1/+1
2015-09-01std: Run TLS destructors in a statically linked binaryAlex Crichton-9/+29
Running TLS destructors for a MSVC Windows binary requires the linker doesn't elide the `_tls_used` or `__tls_used` symbols (depending on the architecture). This is currently achieved via a `#[link_args]` hack but this only works for dynamically linked binaries because the link arguments aren't propagated to statically linked binaries. This commit alters the strategy to instead emit a volatile load from those symbols so LLVM can't elide it, forcing the reference to the symbol to stay alive as long as the callback function stays alive (which we've made sure of with the `#[linkage]` attribute). Closes #28111
2015-07-20std: Fix compiling the standard library on i686-MSVCAlex Crichton-1/+4
This commit fixes building the standard library with the `i686-pc-windows-msvc` target by correcting an included symbol name to the linker.
2015-07-01msvc: Fix TLS destructorsAlex Crichton-2/+6
Just like the original article our Windows TLS support is based on predicted, this symbol must be linked in on MSVC to pull in the necessary support for TLS variables. This commit fixes a number of unit tests which require that TLS destructors are run.
2015-06-18Fix libstd testsAlex Crichton-2/+1
2015-05-27Use `const fn` to abstract away the contents of UnsafeCell & friends.Eduard Burtescu-2/+2
2015-05-09Squeeze the last bits of `task`s in documentation in favor of `thread`Barosl Lee-1/+1
An automated script was run against the `.rs` and `.md` files, subsituting every occurrence of `task` with `thread`. In the `.rs` files, only the texts in the comment blocks were affected.
2015-03-26Mass rename uint/int to usize/isizeAlex Crichton-5/+5
Now that support has been removed, all lingering use cases are renamed.
2015-03-24Test fixes and rebase conflicts, round 2Alex Crichton-2/+6
2015-03-20Revert "Revert "std: Re-enable at_exit()""Alex Crichton-3/+9
This reverts commit aec67c2ee0f673ea7b0e21c2fe7e0f26a523d823.
2015-02-23Test fixes and rebase conflictsAlex Crichton-1/+0
2015-02-23Fix windows failure (fixup #22538)Manish Goregaokar-1/+2
2015-02-23Use boxed functions instead of transmuteStepan Koltsov-2/+2
... to convert between Box and raw pointers. E. g. use ``` let b: Box<Foo> = Box::from_raw(p); ``` instead of ``` let b: Box<Foo> = mem::transmute(p); ``` Patch also changes closure release code in `src/libstd/sys/unix/thread.rs` when `pthread_create` failed. Raw pointer was transmuted to box of `FnOnce()` instead of `Thunk`. This code was probably never executed, because `pthread_create` rarely fails in practice.
2015-02-04Fix for misspelled comments.Joseph Crail-1/+1
The spelling corrections were made in both documentation comments and regular comments.
2015-02-02rollup merge of #21830: japaric/for-cleanupAlex Crichton-1/+1
Conflicts: src/librustc/metadata/filesearch.rs src/librustc_back/target/mod.rs src/libstd/os.rs src/libstd/sys/windows/os.rs src/libsyntax/ext/tt/macro_parser.rs src/libsyntax/print/pprust.rs src/test/compile-fail/issue-2149.rs
2015-02-02`for x in xs.iter()` -> `for x in &xs`Jorge Aparicio-1/+1
2015-02-01std: Add a new `env` moduleAlex Crichton-0/+1
This is an implementation of [RFC 578][rfc] which adds a new `std::env` module to replace most of the functionality in the current `std::os` module. More details can be found in the RFC itself, but as a summary the following methods have all been deprecated: [rfc]: https://github.com/rust-lang/rfcs/pull/578 * `os::args_as_bytes` => `env::args` * `os::args` => `env::args` * `os::consts` => `env::consts` * `os::dll_filename` => no replacement, use `env::consts` directly * `os::page_size` => `env::page_size` * `os::make_absolute` => use `env::current_dir` + `join` instead * `os::getcwd` => `env::current_dir` * `os::change_dir` => `env::set_current_dir` * `os::homedir` => `env::home_dir` * `os::tmpdir` => `env::temp_dir` * `os::join_paths` => `env::join_paths` * `os::split_paths` => `env::split_paths` * `os::self_exe_name` => `env::current_exe` * `os::self_exe_path` => use `env::current_exe` + `pop` * `os::set_exit_status` => `env::set_exit_status` * `os::get_exit_status` => `env::get_exit_status` * `os::env` => `env::vars` * `os::env_as_bytes` => `env::vars` * `os::getenv` => `env::var` or `env::var_string` * `os::getenv_as_bytes` => `env::var` * `os::setenv` => `env::set_var` * `os::unsetenv` => `env::remove_var` Many function signatures have also been tweaked for various purposes, but the main changes were: * `Vec`-returning APIs now all return iterators instead * All APIs are now centered around `OsString` instead of `Vec<u8>` or `String`. There is currently on convenience API, `env::var_string`, which can be used to get the value of an environment variable as a unicode `String`. All old APIs are `#[deprecated]` in-place and will remain for some time to allow for migrations. The semantics of the APIs have been tweaked slightly with regard to dealing with invalid unicode (panic instead of replacement). The new `std::env` module is all contained within the `env` feature, so crates must add the following to access the new APIs: #![feature(env)] [breaking-change]
2015-01-30Remove all `i` suffixesTobias Bucher-1/+1
2015-01-29`for x in range(a, b)` -> `for x in a..b`Jorge Aparicio-1/+1
sed -i 's/in range(\([^,]*\), *\([^()]*\))/in \1\.\.\2/g' **/*.rs
2015-01-21Test fixes and rebase conflictsAlex Crichton-0/+1
2015-01-19Replace `0 as *const/mut T` with `ptr::null/null_mut()`we-2/+2
2015-01-06Fix misspelled comments.Joseph Crail-1/+1
I cleaned up comments prior to the 1.0 alpha release.
2015-01-02std: Stabilize the prelude moduleAlex Crichton-1/+1
This commit is an implementation of [RFC 503][rfc] which is a stabilization story for the prelude. Most of the RFC was directly applied, removing reexports. Some reexports are kept around, however: * `range` remains until range syntax has landed to reduce churn. * `Path` and `GenericPath` remain until path reform lands. This is done to prevent many imports of `GenericPath` which will soon be removed. * All `io` traits remain until I/O reform lands so imports can be rewritten all at once to `std::io::prelude::*`. This is a breaking change because many prelude reexports have been removed, and the RFC can be consulted for the exact list of removed reexports, as well as to find the locations of where to import them. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0503-prelude-stabilization.md [breaking-change] Closes #20068
2014-12-18std: Lower abstractions for thread_local/at_exitAlex Crichton-20/+42
The current implementations use `std::sync` primitives, but these primitives currently end up relying on `thread_info` and a local `Thread` being available (mainly for checking the panicking flag). To get around this, this commit lowers the abstractions used by the windows thread_local implementation as well as the at_exit_imp module. Both of these modules now use a `sys::Mutex` and a `static mut` and manage the allocation/locking manually.
2014-12-18Revise std::thread API to join by defaultAaron Turon-5/+4
This commit is part of a series that introduces a `std::thread` API to replace `std::task`. In the new API, `spawn` returns a `JoinGuard`, which by default will join the spawned thread when dropped. It can also be used to join explicitly at any time, returning the thread's result. Alternatively, the spawned thread can be explicitly detached (so no join takes place). As part of this change, Rust processes now terminate when the main thread exits, even if other detached threads are still running, moving Rust closer to standard threading models. This new behavior may break code that was relying on the previously implicit join-all. In addition to the above, the new thread API also offers some built-in support for building blocking abstractions in user space; see the module doc for details. Closes #18000 [breaking-change]
2014-12-18libs: merge librustrt into libstdAaron Turon-3/+3
This commit merges the `rustrt` crate into `std`, undoing part of the facade. This merger continues the paring down of the runtime system. Code relying on the public API of `rustrt` will break; some of this API is now available through `std::rt`, but is likely to change and/or be removed very soon. [breaking-change]
2014-12-14Mostly rote conversion of `proc()` to `move||` (and occasionally `Thunk::new`)Niko Matsakis-1/+1
2014-11-23std: Add a new top-level thread_local moduleAlex Crichton-0/+238
This commit removes the `std::local_data` module in favor of a new `std::thread_local` module providing thread local storage. The module provides two variants of TLS: one which owns its contents and one which is based on scoped references. Each implementation has pros and cons listed in the documentation. Both flavors have accessors through a function called `with` which yield a reference to a closure provided. Both flavors also panic if a reference cannot be yielded and provide a function to test whether an access would panic or not. This is an implementation of [RFC 461][rfc] and full details can be found in that RFC. This is a breaking change due to the removal of the `std::local_data` module. All users can migrate to the new thread local system like so: thread_local!(static FOO: Rc<RefCell<Option<T>>> = Rc::new(RefCell::new(None))) The old `local_data` module inherently contained the `Rc<RefCell<Option<T>>>` as an implementation detail which must now be explicitly stated by users. [rfc]: https://github.com/rust-lang/rfcs/pull/461 [breaking-change]