about summary refs log tree commit diff
path: root/library/std/src/sys
AgeCommit message (Collapse)AuthorLines
2024-09-03More robust extension checkingChris Denton-6/+24
2024-09-03Port std library to RTEMSJan Sommer-10/+48
2024-09-03Rollup merge of #129913 - saethlin:l4re-read-buf, r=NoratriebMatthias Krüger-0/+4
Add missing read_buf stub for x86_64-unknown-l4re-uclibc Before this PR, `x check library/std --target x86_64-unknown-l4re-uclibc` will fail with ``` error[E0599]: no method named `read_buf` found for struct `Socket` in the current scope --> std/src/os/unix/net/stream.rs:598:16 | 598 | self.0.read_buf(buf) | ^^^^^^^^ | ::: std/src/sys/pal/unix/l4re.rs:23:5 | 23 | pub struct Socket(FileDesc); | ----------------- method `read_buf` not found for this struct | = help: items from traits can only be used if the trait is implemented and in scope ``` This target doesn't have a maintainer to cc.
2024-09-03Rollup merge of #129800 - ChrisDenton:remove-dir-all2, r=AmanieuMatthias Krüger-169/+253
Move the Windows remove_dir_all impl into a module and make it more race resistant This attempts to make the Windows implementation of `remove_dir_all` easier to understand and work with by separating out different concerns into their own functions. The code is mostly the same as before just moved around. There are some changes to make it more robust against races (e.g. two calls to `remove_dir_all` running concurrently). The module level comment explains the issue. try-job: x86_64-msvc try-job: i686-msvc
2024-09-02Rollup merge of #129907 - saethlin:solid-io-error, r=WaffleLapkinMatthias Krüger-1/+1
Fix compile error in solid's remove_dir_all Before this PR, `x check library/std --target=aarch64-kmc-solid_asp3` will fail with: ``` error[E0382]: use of partially moved value: `result` --> std/src/sys/pal/solid/fs.rs:544:20 | 541 | if let Err(err) = result | --- value partially moved here ... 544 | return result; | ^^^^^^ value used here after partial move | = note: partial move occurs because value has type `io::error::Error`, which does not implement the `Copy` trait help: borrow this binding in the pattern to avoid moving the value | 541 | if let Err(ref err) = result | +++ ``` cc `@kawadakk` I think this will clear up https://solid-rs.github.io/toolstate/ :)
2024-09-02Add missing read_buf stub for x86_64-unknown-l5re-uclibcBen Kimock-0/+4
2024-09-02Fix compile error in solid's remove_dir_allBen Kimock-1/+1
2024-09-02Rollup merge of #129804 - ranger-ross:fixed-documentation-typos, r=NoratriebMatthias Krüger-2/+2
Fixed some typos in the standard library documentation/comments I spent some time to fix a few typos in `library/std` and `library/core`
2024-09-01Auto merge of #127897 - nyurik:add-qnx-70-target, r=saethlinbors-5/+8
add `aarch64_unknown_nto_qnx700` target - QNX 7.0 support for aarch64le This backports the QNX 7.1 aarch64 implementation to 7.0. * [x] required `-lregex` disabled, see https://github.com/rust-lang/libc/pull/3775 (released in libc 0.2.156) * [x] uses `libgcc.a` instead of `libgcc_s.so` (7.0 used ancient GCC 5.4 which didn't have gcc_s) * [x] a fix in `backtrace` crate to support stack traces https://github.com/rust-lang/backtrace-rs/pull/648 This PR bumps libc dependency to 0.2.158 CC: to the folks who did the [initial implementation](https://doc.rust-lang.org/rustc/platform-support/nto-qnx.html): `@flba-eb,` `@gh-tr,` `@jonathanpallant,` `@japaric` # Compile target ```bash # Configure qcc build environment source _path_/_to_/qnx7.0/qnxsdp-env.sh # Tell rust to use qcc when building QNX 7.0 targets export build_env=' CC_aarch64-unknown-nto-qnx700=qcc CFLAGS_aarch64-unknown-nto-qnx700=-Vgcc_ntoaarch64le_cxx CXX_aarch64-unknown-nto-qnx700=qcc AR_aarch64_unknown_nto_qnx700=ntoaarch64-ar' # Build rust compiler, libs, and the remote test server env $build_env ./x.py build \ --target x86_64-unknown-linux-gnu,aarch64-unknown-nto-qnx700 \ rustc library/core library/alloc library/std src/tools/remote-test-server rustup toolchain link stage1 build/host/stage1 ``` # Compile "hello world" ```bash source _path_/_to_/qnx7.0/qnxsdp-env.sh cargo new hello_world cd hello_world cargo +stage1 build --release --target aarch64-unknown-nto-qnx700 ``` # Configure a remote for testing Do this from a new shell - we will need to run more commands in the previous one. I ran into these two issues, and found some workarounds. * Temporary dir might not work properly * Default `remote-test-server` has issues binding to an address ``` # ./remote-test-server starting test server thread 'main' panicked at src/tools/remote-test-server/src/main.rs:175:29: called `Result::unwrap()` on an `Err` value: Os { code: 249, kind: AddrNotAvailable, message: "Can't assign requested address" } note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` Specifying `--bind` param actually fixes that, and so does setting `TMPDIR` properly. ```bash # Copy remote-test-server to remote device. You may need to use sftp instead. # ATTENTION: Note that the path is different from the one in the remote testing documentation for some reason scp ./build/x86_64-unknown-linux-gnu/stage1-tools-bin/remote-test-server qnxdevice:/path/ # Run ssh with port forwarding - so that rust tester can connect to the local port instead ssh -L 12345:127.0.0.1:12345 qnxdevice # on the device, run rm -rf tmp && mkdir -p tmp && TMPDIR=$PWD/tmp ./remote-test-server --bind 0.0.0.0:12345 ``` # Run test suit Assume all previous environment variables are still set, or re-init them ```bash export TEST_DEVICE_ADDR="localhost:12345" # tidy needs to be skipped due to using un-published libc dependency export exclude_tests=' --exclude src/bootstrap --exclude src/tools/error_index_generator --exclude src/tools/linkchecker --exclude src/tools/tidy --exclude tests/ui-fulldeps --exclude rustc --exclude rustdoc --exclude tests/run-make-fulldeps' env $build_env ./x.py test $exclude_tests --stage 1 --target aarch64-unknown-nto-qnx700 ``` try-job: dist-x86_64-msvc
2024-08-31Move remove_dir_all impl into a moduleChris Denton-169/+253
2024-08-31Fixed some typos in the standard library documentation/commentsranger-ross-2/+2
2024-08-30Squashed `aarch64_unknown_nto_qnx700` supportYuri Astrakhan-5/+8
2024-08-29wasi: Fix sleeping for `Duration::MAX`Alex Crichton-30/+31
This commit fixes an assert in the WASI-specific implementation of thread sleep to ensure that sleeping for a very large period of time blocks instead of panicking. This can come up when testing programs that sleep "forever", for example.
2024-08-28Rollup merge of #129378 - goffrie:patch-3, r=ChrisDentonJubilee-13/+9
Clean up cfg-gating of ProcessPrng extern This removes a bit of duplication and is consistent with how `api-ms-win-core-synch-l1-2-0` externs are imported.
2024-08-27Auto merge of #128134 - joboet:move_pal_alloc, r=cupiverbors-146/+78
std: move allocators to `sys` Part of #117276.
2024-08-27std: move allocators to `sys`joboet-146/+78
2024-08-26pal/hermit: saturate `usleep` microseconds at `u64::MAX`Martin Kröning-1/+2
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-08-25pal/hermit: correctly round up microseconds in `Thread::sleep`Martin Kröning-1/+3
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-08-23Rollup merge of #127623 - lolbinarycat:fix_remove_dir_all, r=AmanieuMatthias Krüger-30/+66
fix: fs::remove_dir_all: treat internal ENOENT as success fixes #127576 try-job: test-various
2024-08-22fix: fs::remove_dir_all: treat ENOENT as successbinarycat-30/+66
fixes #127576 windows implementation still needs some work
2024-08-22Rollup merge of #128432 - g0djan:godjan/wasi_prohibit_implicit_unsafe, ↵Matthias Krüger-16/+22
r=tgross35 WASI: forbid `unsafe_op_in_unsafe_fn` for `std::{os, sys}` Part of https://github.com/rust-lang/rust/issues/127747 for WASI try-job: test-various
2024-08-21formatGeoffry Song-9/+2
2024-08-21Clean up cfg-gating of ProcessPrng externGeoffry Song-13/+16
2024-08-21Rollup merge of #129232 - ivmarkov:master, r=workingjubileeMatthias Krüger-6/+24
Fix `thread::sleep` Duration-handling for ESP-IDF Addresses the ESP-IDF specific aspect of https://github.com/rust-lang/rust/issues/129212 #### A short summary of the problems addressed by this PR: ================================================ 1. **Problem 1** - the current implementation of `std::thread::sleep` does not properly round up the passed `Duration` As per the documentation of `std::thread::sleep`, the implementation should sleep _at least_ for the provided duration, but not less. Since the minimum supported resolution of the `usleep` syscall which is used with ESP-IDF is one microsecond, this means that we need to round-up any sub-microsecond nanos to one microsecond. Moreover, in the edge case where the user had passed a duration of < 1000 nanos (i.e. less than one microsecond), the current implementation will _not_ sleep _at all_. This is addressed by this PR. 2. **Problem 2** - the implementation of `usleep` on the ESP-IDF can overflow if the passed number of microseconds is >= `u32::MAX - 1_000_000` This is also addressed by this PR. Extra details for Problem 2: `u32::MAX - 1_000_000` is chosen to accommodate for the longest possible systick on the ESP IDF which is 1000ms. The systick duration is selected when compiling the ESP IDF FreeRTOS task scheduler itself, so we can't know it from within `STD`. The default systick duration is 10ms, and might be lowered down to 1ms. (Making it longer I have never seen, but in theory it can go up to a 1000ms max, even if obviously a one second systick is unrealistic - but we are paranoid in the PR.) While the overflow is reported upstream in the ESP IDF repo[^1], I still believe we should workaround it in the Rust wrappers as well, because it might take time until it is fixed, and they might not fix it for all released ESP IDF versions. For big durations, rather than calling `usleep` repeatedly on the ESP-IDF in chunks of `u32::MAX - 1_000_000`us, it might make sense to call instead with 1_000_000us (one second) as this is the max period that seems to be agreed upon as a safe max period in the `usleep` POSIX spec. On the other hand, that might introduce less precision (as we need to call more times `usleep` in a loop) and, we would be fighting a theoretical problem only, as I have big doubts the ESP IDF will stop supporting durations higher than 1_000_000us - ever - because of backwards compatibility with code which already calls `usleep` on the ESP IDF with bigger durations. [^1]: https://github.com/espressif/esp-idf/issues/14390
2024-08-20Avoid extra `cast()`s after `CStr::as_ptr()`Josh Stone-2/+2
These used to be `&str` literals that did need a pointer cast, but that became a no-op after switching to `c""` literals in #118566.
2024-08-18Fix for issue #129212 for the ESP-IDFivmarkov-6/+24
2024-08-17Auto merge of #126877 - GrigorenkoPV:clone_to_uninit, r=dtolnaybors-0/+26
CloneToUninit impls As per #126799. Also implements it for `Wtf8` and both versions of `os_str::Slice`. Maybe it is worth to slap `#[inline]` on some of those impls. r? `@dtolnay`
2024-08-14Rollup merge of #128873 - ChrisDenton:windows-targets, r=Mark-SimulacrumMatthias Krüger-41/+1
Add windows-targets crate to std's sysroot With this PR, when backtrace is used as a crate from crates.io it will (once updated) use the real [windows-targets](https://crates.io/crates/windows-targets) crate. But when used from std it'll use std's replacement version. This allows sharing our customized `windows_tagets::link!` macro between std proper and the backtrace crate when used as part of std, ensuring a consistent linking story. This will be especially important once we move to using [`raw-dylib`](https://doc.rust-lang.org/reference/items/external-blocks.html#dylib-versus-raw-dylib) by default.
2024-08-13Auto merge of #129046 - matthiaskrgr:rollup-9x4xgak, r=matthiaskrgrbors-173/+137
Rollup of 7 pull requests Successful merges: - #128643 (Refactor `powerpc64` call ABI handling) - #128655 (std: refactor UNIX random data generation) - #128745 (Remove unused lifetime parameter from spawn_unchecked) - #128841 (bootstrap: don't use rustflags for `--rustc-args`) - #128983 (Slightly refactor `TargetSelection` in bootstrap) - #129026 (CFI: Move CFI ui tests to cfi directory) - #129040 (Fix blessing of rmake tests) r? `@ghost` `@rustbot` modify labels: rollup
2024-08-13Rollup merge of #128655 - joboet:play_with_the_dice, r=ChrisDentonMatthias Krüger-173/+137
std: refactor UNIX random data generation This PR makes a number of changes to the UNIX randomness implementation: * Use `io::Error` for centralized error handling * Move the file-fallback logic out of the `getrandom`-specific module * Stop redefining the syscalls on macOS and DragonFly, they have appeared in `libc` * Add a `OnceLock` to cache the random device file descriptor
2024-08-12trying common codepath for every unixesDavid Carlier-29/+0
2024-08-12std::fs: get_mode implementation for haiku.David Carlier-0/+2
2024-08-12std: use `/scheme/rand` on Redoxjoboet-1/+1
2024-08-09Rollup merge of #128859 - MinxuanZ:mips-sig, r=AmanieuMatthias Krüger-0/+13
Fix the name of signal 19 in library/std/src/sys/pal/unix/process/process_unix/tests.rs for mips/sparc linux relate to #128816
2024-08-09Add windows-targets crate to std's sysrootChris Denton-41/+1
2024-08-09VxWorks: Add safety comment for vxCpuEnabledGetB I Mohammed Abbas-1/+1
Co-authored-by: Trevor Gross <t.gross35@gmail.com>
2024-08-09delete spacemonstercatss-2/+2
2024-08-09fix formatmonstercatss-4/+6
2024-08-09[SPARC] fix the name of signal 19 in sparc archMin-1/+9
2024-08-09[MIPS] fix the name of signal 19 in mipsMin-0/+3
2024-08-08Vxworks: Extern taskNameSet and fix build errorsB I Mohammed Abbas-20/+8
2024-08-08Fix VxWorks available parallelism: Move nonzero::uncheked into unsafe blockB I Mohammed Abbas-3/+5
2024-08-06Rollup merge of #128417 - tgross35:f16-f128-math, r=dtolnayTrevor Gross-0/+15
Add `f16` and `f128` math functions This adds intrinsics and math functions for `f16` and `f128` floating point types. Support is quite limited and some things are broken so tests don't run on many platforms, but this provides a starting point.
2024-08-07Rollup merge of #128751 - devnexen:vxworks_set_thread_name, r=tgross35Matthias Krüger-3/+30
std::thread: set_name implementation proposal for vxWorks.
2024-08-07Rollup merge of #128539 - biabbas:deny_unsafe, r=workingjubileeMatthias Krüger-0/+1
Forbid unused unsafe in vxworks-specific std modules Tracking issue #127747 Adding deny(unsafe_op_in_unsafe_fn) in VxWorks specific files did not cause any error. Most of VxWorks falls back on Unix libraries. So we'll have to wait for Unix changes. r? ```@workingjubilee```
2024-08-07Rollup merge of #125048 - dingxiangfei2009:stable-deref, r=amanieuMatthias Krüger-0/+4
PinCoerceUnsized trait into core cc ``@Darksonn`` ``@wedsonaf`` ``@ojeda`` This is a PR to introduce a `PinCoerceUnsized` trait in order to make trait impls generated by the proc-macro `#[derive(SmartPointer)]`, proposed by [RFC](https://github.com/rust-lang/rfcs/blob/e17e19ac7ad1c8ccad55d4babfaee1aa107d1da5/text/3621-derive-smart-pointer.md#pincoerceunsized-1), sound. There you may find explanation, justification and discussion about the alternatives. Note that we do not seek stabilization of this `PinCoerceUnsized` trait in the near future. The stabilisation of this trait does not block the eventual stabilization process of the `#[derive(SmartPointer)]` macro. Ideally, use of `DerefPure` is more preferrable except this will actually constitute a breaking change. `PinCoerceUnsized` emerges as a solution to the said soundness hole while avoiding the breaking change. More details on the `DerefPure` option have been described in this [section](https://github.com/rust-lang/rfcs/blob/e17e19ac7ad1c8ccad55d4babfaee1aa107d1da5/text/3621-derive-smart-pointer.md#derefpure) of the RFC linked above. Earlier discussion can be found in this [Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/Pin.20and.20soundness.20of.20unsizing.20coercions) and [rust-for-linux thread](https://rust-lang.zulipchat.com/#narrow/stream/425075-rust-for-linux/topic/.23.5Bderive.28SmartPointer.29.5D.20and.20pin.20unsoundness.20rfc.233621). try-job: dist-various-2
2024-08-06std::thread: set_name implementation proposal for vxWorks.David Carlier-3/+30
2024-08-05WASI fixing unsafe_op_in_unsafe_fn for std::{os, sys}Georgii Rylov-16/+22
2024-08-05Rollup merge of #128026 - devnexen:available_parallelism_vxworks, ↵Matthias Krüger-1/+11
r=Mark-Simulacrum std::thread: available_parallelism implementation for vxWorks proposal.
2024-08-04std: refactor UNIX random data generationjoboet-173/+137
This PR makes a number of changes to the UNIX randomness implementation: * Use `io::Error` for centralized error handling * Move the file-fallback logic out of the `getrandom`-specific module * Stop redefining the syscalls on macOS and DragonFly, they have appeared in `libc` * Add a `OnceLock` to cache the random device file descriptor