about summary refs log tree commit diff
path: root/library/std/src/sys
AgeCommit message (Collapse)AuthorLines
2024-02-29Rollup merge of #121596 - ChrisDenton:tls, r=joboetGuillaume Gomez-22/+13
Use volatile access instead of `#[used]` for `on_tls_callback` The first commit adds a volatile load of `p_thread_callback` when registering a dtor so that the compiler knows if the callback is used or not. I don't believe the added volatile instruction is otherwise significant in the context. In my testing using the volatile load allowed the compiler to correctly reason about whether `on_tls_callback` is used or not, allowing it to be omitted entirely in some cases. Admittedly it usually is used due to `Thread` but that can be avoided (e.g. in DLLs or with custom entry points that avoid the offending APIs). Ideally this would be something the compiler could help a bit more with so we didn't have to use tricks like `#[used]` or volatile. But alas. I also used this as an opportunity to clean up the `unused` lints which I don't think serve a purpose any more. The second commit removes the volatile load of `_tls_used` with `#cfg[target_thread_local]` because `#[thread_local]` already implies it. And if it ever didn't then `#[thread_local]` would be broken when there aren't any dtors.
2024-02-29Rollup merge of #121765 - hermit-os:errno, r=ChrisDentonGuillaume Gomez-5/+5
add platform-specific function to get the error number for HermitOS Extending `std` to get the last error number for HermitOS. HermitOS is a tier 3 platform and this PR changes only files, wich are related to the tier 3 platform.
2024-02-28add platform-specific function to get the error number for HermitOSStefan Lankes-5/+5
Extending `std` to get the last error number for HermitOS. HermitOS is a tier 3 platform and this PR changes only files, wich are related to the tier 3 platform.
2024-02-28std: move thread local implementation to `sys`joboet-2/+3
2024-02-28Rollup merge of #121691 - ↵Guillaume Gomez-1/+1
janstarke:handle-missing-creation-time-as-unsupported, r=cuviper handle unavailable creation time as `io::ErrorKind::Unsupported`
2024-02-27Implement junction_pointChris Denton-74/+69
2024-02-27Auto merge of #119616 - rylev:wasm32-wasi-preview2, r=petrochenkov,m-ou-sebors-123/+213
Add a new `wasm32-wasi-preview2` target This is the initial implementation of the MCP https://github.com/rust-lang/compiler-team/issues/694 creating a new tier 3 target `wasm32-wasi-preview2`. That MCP has been seconded and will most likely be approved in a little over a week from now. For more information on the need for this target, please read the [MCP](https://github.com/rust-lang/compiler-team/issues/694). There is one aspect of this PR that will become insta-stable once these changes reach a stable compiler: * A new `target_family` named `wasi` is introduced. This target family incorporates all wasi targets including `wasm32-wasi` and its derivative `wasm32-wasi-preview1-threads`. The difference between `target_family = wasi` and `target_os = wasi` will become much clearer when `wasm32-wasi` is renamed to `wasm32-wasi-preview1` and the `target_os` becomes `wasm32-wasi-preview1`. You can read about this target rename in [this MCP](https://github.com/rust-lang/compiler-team/issues/695) which has also been seconded and will hopefully be officially approved soon. Additional technical details include: * Both `std::sys::wasi_preview2` and `std::os::wasi_preview2` have been created and mostly use `#[path]` annotations on their submodules to reach into the existing `wasi` (soon to be `wasi_preview1`) modules. Over time the differences between `wasi_preview1` and `wasi_preview2` will grow and most like all `#[path]` based module aliases will fall away. * Building `wasi-preview2` relies on a [`wasi-sdk`](https://github.com/WebAssembly/wasi-sdk) in the same way that `wasi-preview1` does (one must include a `wasi-root` path in the `Config.toml` pointing to sysroot included in the wasi-sdk). The target should build against [wasi-sdk v21](https://github.com/WebAssembly/wasi-sdk/releases/tag/wasi-sdk-21) without modifications. However, the wasi-sdk itself is growing [preview2 support](https://github.com/WebAssembly/wasi-sdk/pull/370) so this might shift rapidly. We will be following along quickly to make sure that building the target remains possible as the wasi-sdk changes. * This requires a [patch to libc](https://github.com/rylev/rust-libc/tree/wasm32-wasi-preview2) that we'll need to land in conjunction with this change. Until that patch lands the target won't actually build.
2024-02-27handle unavailable creation time as `io::ErrorKind::Unsupported`Jan Starke-1/+1
2024-02-27Auto merge of #119636 - devnexen:linux_tcp_defer_accept, r=m-ou-sebors-0/+12
os::net: expanding TcpStreamExt for Linux with `tcp_deferaccept`. allows for socket to process only when there is data to process, the option sets a number of seconds until the data is ready.
2024-02-27Rename wasm32-wasi-preview2 to wasm32-wasip2Ryan Levick-4/+4
Signed-off-by: Ryan Levick <me@ryanlevick.com>
2024-02-27Add the wasm32-wasi-preview2 targetRyan Levick-123/+213
Signed-off-by: Ryan Levick <me@ryanlevick.com>
2024-02-27Use the OS thread name by default for the current threadChris Denton-2/+75
2024-02-26change std::process to drop supplementary groups based on CAP_SETGIDElliot Roberts-3/+11
2024-02-26Remove _tls_used trickery unless neededChris Denton-5/+2
2024-02-26Use volatile to make `p_thread_callback` usedChris Denton-17/+11
2024-02-26Win10: Use GetSystemTimePreciseAsFileTime directlyChris Denton-0/+6
2024-02-26Auto merge of #121317 - ChrisDenton:win10-sync, r=Mark-Simulacrumbors-106/+154
Always use WaitOnAddress on Win10+ `WaitOnAddress` and `WakeByAddressSingle` are always available since Windows 8 so they can now be used without needing to delay load. I've also moved the Windows 7 thread parking fallbacks into a separate sub-module.
2024-02-25Auto merge of #121591 - matthiaskrgr:rollup-8wfhh3v, r=matthiaskrgrbors-0/+0
Rollup of 9 pull requests Successful merges: - #119590 (Stabilize `cfg_target_abi`) - #120805 (make non-PartialEq-typed consts as patterns a hard error) - #121060 (Add newtypes for bool fields/params/return types) - #121284 (Add test cases for inlining compiler-private items) - #121324 (pattern_analysis: factor out unspecialization) - #121409 (Prevent cycle in implied predicates computation) - #121513 (Fix sgx unit test compilation) - #121570 (Make most bootstrap step types !Copy) - #121586 (Don't use `unwrap()` in `ArrayIntoIter` lint when typeck fails) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-25Rollup merge of #121513 - nshyrei:fix_tests_module, r=cuviperMatthias Krüger-0/+0
Fix sgx unit test compilation Fixes a compilation error: ``` error[E0583]: file not found for module `tests` --> library/std/src/sys/locks/rwlock/sgx.rs:2:1 | 2 | mod tests; | ^^^^^^^^^^ | = help: to create the module `tests`, create file "library/std/src/sys/locks/rwlock/sgx/tests.rs" or "library/std/src/sys/locks/rwlock/sgx/tests/mod.rs" = note: if there is a `mod tests` elsewhere in the crate already, import it with `use crate::...` instead For more information about this error, try `rustc --explain E0583`. error: could not compile `std` (lib test) due to 1 previous error` ``` When running command: ``` `TF_BUILD=True RUST_TEST_THREADS=1 ./x.py test --stage 1 "library/std" tests/assembly tests/run-make --target=x86_64-fortanix-unknown-sgx --no-doc --exclude src/tools/linkchecker --exclude src/tools/rust-demangler --no-fail-fast 2>&1 ``` The fix is done by moving a file to the location suggested by the compiler. The issue was introduced by PR: https://github.com/rust-lang/rust/pull/121177
2024-02-25Windows: Use ProcessPrng for random keysChris Denton-44/+28
2024-02-24library: use `addr_of!`Pavel Grigorenko-37/+37
2024-02-23moved tests fileNikitaShyrei-0/+0
2024-02-23Make timespec capping public to crate::sysFlorian Bartels-2/+2
It is used in: - `library/std/src/sys/locks/condvar/pthread.rs` - `library/std/src/sys/pal/unix/thread_parking/pthread.rs`
2024-02-22std support for wasm32 panic=unwindNoa-4/+4
2024-02-22Auto merge of #117174 - Ayush1325:uefi-stdio-improve, r=workingjubileebors-37/+94
Improve UEFI stdio Fixed some things suggested in last PR: #116207 cc `@dvdhrm` cc `@nicholasbishop`
2024-02-21Always use WaitOnAddress on Win10+Chris Denton-106/+154
2024-02-21os::net: expanding TcpStreamExt for Linux with `tcp_deferaccept`.David Carlier-0/+12
allows for socket to process only when there is data to process, the option sets a number of seconds until the data is ready.
2024-02-21rename ptr::invalid -> ptr::without_provenanceRalf Jung-16/+27
also introduce ptr::dangling matching NonNull::dangling
2024-02-20Delete architecture-specific memchr code in std::sysArthur Carcano-91/+6
Currently all architecture-specific memchr code is only used in `std::io`. Most of the actual `memchr` capacity exposed to the user through the slice API is instead implemented in core::slice::memchr. Hence this commit deletes memchr from std::sys[_common] and replace calls to it by calls to core::slice::memchr functions. This deletes (r)memchr from the list of symbols linked to libc.
2024-02-19Auto merge of #121177 - joboet:move_pal_locks, r=ChrisDentonbors-164/+141
Move locks to `sys` Part of #117276. r? `@ChrisDenton`
2024-02-18Auto merge of #121101 - GnomedDev:dyn-small-c-string, r=Nilstriebbors-57/+60
Reduce monomorphisation bloat in small_c_string This is a code path usually next to an FFI call, so taking the `dyn` slowdown for the 1159 llvm-line (fat lto, codegen-units 1, release build) drop in my testing program [t2fanrd](https://github.com/GnomedDev/t2fanrd) is worth it imo.
2024-02-18Dyn erase at call siteDavid Thomas-59/+50
2024-02-18Add some comments to prevent regressionDavid Thomas-0/+5
2024-02-18Reduce monomorphisation bloat in small_c_stringDavid Thomas-8/+15
2024-02-18Rollup merge of #118569 - blyxxyz:platform-os-str-slice, r=Mark-SimulacrumMatthias Krüger-1/+49
Move `OsStr::slice_encoded_bytes` validation to platform modules This delegates OS string slicing (`OsStr::slice_encoded_bytes`) validation to the underlying platform implementation. For now that results in increased performance and better error messages on Windows without any changes to semantics. In the future we may want to provide different semantics for different platforms. The existing implementation is still used on Unix and most other platforms and is now optimized a little better. Tracking issue: https://github.com/rust-lang/rust/issues/118485 cc `@epage,` `@BurntSushi`
2024-02-18Improve wording of static_mut_refObei Sideg-4/+6
Rename `static_mut_ref` lint to `static_mut_refs`.
2024-02-17Rollup merge of #119032 - smmalis37:patch-1, r=ChrisDentonGuillaume Boisseau-5/+25
Use a hardcoded constant instead of calling OpenProcessToken. Now that Win 7 support is dropped, we can resurrect #90144. GetCurrentProcessToken is defined in processthreadsapi.h as: FORCEINLINE HANDLE GetCurrentProcessToken ( VOID ) { return (HANDLE)(LONG_PTR) -4; } Since it's very unlikely that this constant will ever change, let's just use it instead of making calls to get the same information.
2024-02-17Auto merge of #120741 - a1phyr:safe_buffer_advance, r=m-ou-sebors-9/+9
Make `io::BorrowedCursor::advance` safe This also keeps the old `advance` method under `advance_unchecked` name. This makes pattern like `std::io::default_read_buf` safe to write.
2024-02-16Remove cfg_attrSteven-1/+0
2024-02-16Use a hardcoded constant instead of calling OpenProcessToken.Steven-5/+26
Now that Win 7 support is dropped, we can resurrect #90144. GetCurrentProcessToken is defined in processthreadsapi.h as: FORCEINLINE HANDLE GetCurrentProcessToken ( VOID ) { return (HANDLE)(LONG_PTR) -4; } Since it's very unlikely that this constant will ever change, let's just use it instead of making calls to get the same information.
2024-02-16std: move locks to `sys` on platforms without threadsjoboet-17/+10
2024-02-16std: move locks to `sys` on xousjoboet-10/+11
2024-02-16std: move locks to `sys` on Windowsjoboet-8/+10
2024-02-16std: move locks to `sys` on UNIX and other futex platformsjoboet-218/+55
2024-02-16std: move locks to `sys` on teeosjoboet-10/+158
2024-02-16std: move locks to `sys` on SGXjoboet-23/+19
2024-02-16std: move locks to `sys` on µITRONjoboet-41/+41
2024-02-16Auto merge of #120486 - reitermarkus:use-generic-nonzero, r=dtolnaybors-80/+80
Use generic `NonZero` internally. Tracking issue: https://github.com/rust-lang/rust/issues/120257
2024-02-16Auto merge of #120889 - Ayush1325:uefi-instant, r=joshtriplettbors-0/+116
Implement Instant for UEFI - Uses Timestamp Protocol if present. Else use rdtsc for x86 and x86-64
2024-02-15Rollup merge of #120672 - devnexen:update_thread_stack_guardpages_fbsd, ↵Guillaume Gomez-5/+25
r=m-ou-se std::thread update freebsd stack guard handling. up to now, it had been assumed the stack guard setting default is not touched in the field but some user might just want to disable it or increase it. checking it once at runtime should be enough.