about summary refs log tree commit diff
path: root/library/std/src/sys/pal
AgeCommit message (Collapse)AuthorLines
2024-03-06Document and test minimal stack size on WindowsChris Denton-0/+2
2024-03-06Dynamically size sigaltstk in stdJubilee Young-11/+39
On modern Linux with Intel AMX and 1KiB matrices, Arm SVE with potentially 2KiB vectors, and RISCV Vectors with up to 16KiB vectors, we must handle dynamic signal stack sizes. We can do so unconditionally by using getauxval, but assuming it may return 0 as an answer, thus falling back to the old constant if needed.
2024-03-06Remove unnecessary fixmeChris Denton-5/+0
As the FIXME itself notes, there's nothing to fix here.
2024-03-06Be stricter with `copy_file_range` probe resultsTobias Bucher-33/+35
2024-03-06Less syscalls for the `copy_file_range` probeTobias Bucher-23/+48
If it's obvious from the actual syscall results themselves that the syscall is supported or unsupported, don't do an extra syscall with an invalid file descriptor. CC #122052
2024-03-06unix time module now return resultAntoine PLASKOWSKI-51/+35
2024-03-05Add `Waitable` traitChris Denton-10/+43
2024-03-05Windows: Implement mutex using futexChris Denton-0/+58
Well, the Windows equivalent: `WaitOnAddress`, `WakeByAddressSingle` and `WakeByAddressAll`.
2024-03-04std::threads: revisit stack address calculation on netbsd.David Carlier-2/+21
like older linux glibc versions, we need to get the guard size and increasing the stack's bottom address accordingly.
2024-03-03std::rand: enable getrandom for dragonflybsd too.David Carlier-1/+9
2024-03-03Add missing get_name for wasm::thread.Ian Neumann-0/+4
2024-03-03Auto merge of #121856 - ChrisDenton:abort, r=joboetbors-10/+13
Cleanup windows `abort_internal` As the comments on the functions say, we define abort in both in panic_abort and in libstd. This PR makes the two implementation (mostly) the same. Additionally it: * uses `options(noreturn)` on the asm instead of using `core::intrinsics::unreachable`. * removed unnecessary allow lints * added `FAST_FAIL_FATAL_APP_EXIT` to our generated Windows API bindings instead of defining it manually (std only)
2024-03-02Cleanup windows abort_internalChris Denton-10/+13
2024-03-02Rollup merge of #121758 - joboet:move_pal_thread_local, r=ChrisDentonMatthias Krüger-666/+0
Move thread local implementation to `sys` Part of #117276.
2024-03-02Rollup merge of #121666 - ChrisDenton:thread-name, r=cuviperMatthias Krüger-10/+115
Use the OS thread name by default if `THREAD_INFO` has not been initialized Currently if `THREAD_INFO` hasn't been initialized then the name will be set to `None`. This PR changes it to use the OS thread name by default. This mostly affects foreign threads at the moment but we could expand this to make more use of the OS thread name in the future. Note: I've only implemented `Thread::get_name` for windows, linux and macos (and macos adjacent) targets. The rest just return `None`.
2024-03-01Add `get_name` placeholder to other targetsChris Denton-8/+40
2024-03-01revise interface to read directory entriesStefan Lankes-97/+116
The new interface has some similarities to Linux system call getdents64. The system call reads several dirent64 structures. At the end of each dirent64 is stored the name of the file. The length of file name is implictly part of dirent64 because d_reclen contains size of dirent64 plus the length of the file name.
2024-03-01Extending filesystem support for hermit-ossimonschoening-96/+225
2024-03-01Auto merge of #114016 - krtab:delete_sys_memchr, r=workingjubileebors-91/+6
Delete architecture-specific memchr code in std::sys 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. The interest of putting architecture specific code back in core is linked to the discussion to be had in #113654
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-666/+0
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-21/+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-21/+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-21/+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-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-11/+22
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-3221/+12
Move locks to `sys` Part of #117276. r? `@ChrisDenton`
2024-02-18Dyn erase at call siteDavid Thomas-59/+50
2024-02-18Add some comments to prevent regressionDavid Thomas-0/+5