about summary refs log tree commit diff
path: root/library/std/src/sys
AgeCommit message (Collapse)AuthorLines
2024-07-24Auto merge of #127153 - NobodyXu:pipe, r=ChrisDentonbors-4/+336
Initial implementation of anonymous_pipe API ACP completed in rust-lang/libs-team#375 Tracking issue: #127154 try-job: x86_64-msvc try-job: i686-mingw
2024-07-23Fix return type of FileAttr methods on AIX targetTaylor Foxhall-3/+3
At some point it seems `SystemTime::new` changed from returning `SystemTime` to `io::Result<SystemTime>`. This seems to have been addressed on other platforms, but was never changed for AIX. This was caught by running ``` python3 x.py build --host x86_64-unknown-linux-gnu --target powerpc64-ibm-aix ```
2024-07-23Initial implementation of anonymous_pipeJiahao XU-4/+336
Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com> Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com> Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2024-07-23Update process vxworks, set default stack size of 256 Kib for vxworks. User ↵B I Mohammed Abbas-2/+7
can set the stack size using RUST_MIN_STACK, with min size of libc::PTHREAD_STACK_MIN(4kib)
2024-07-23Remove wrapper functions from c.rsChris Denton-126/+43
2024-07-23std: Unsafe-wrap backtrace code held in-commonJubilee Young-57/+61
2024-07-23std: Unsafe-wrap alloc code held in-commonJubilee Young-8/+11
2024-07-23Cfg disable on_broken_pipe_flag_used() for vxworksB I Mohammed Abbas-0/+2
2024-07-23Disable dirfd for vxworks, Return unsupported error from set_times and ↵B I Mohammed Abbas-2/+16
lchown for vxworks
2024-07-23Allow unused unsafe for vxworks in read_at and write atB I Mohammed Abbas-0/+2
2024-07-22std: unsafe-wrap personality::dwarf::ehJubilee Young-53/+61
In so doing, move the forbid up to the top of personality::dwarf
2024-07-22Rollup merge of #127996 - ↵许杰友 Jieyou Xu (Joe)-2/+1
ian-h-chamberlain:fix/horizon-warnings-unsafe-in-unsafe, r=tgross35 Clean up warnings + `unsafe_op_in_unsafe_fn` when building std for armv6k-nintendo-3ds See #127747 ping `@AzureMarker` `@Meziu` I could only find one instance needing an extra `unsafe` that was not also shared with many other `unix` targets (presumably these will get covered in larger sweeping changes, I didn't want to introduce churn that would potentially conflict with those). The one codepath I found is shared with `vita` however, so also pinging `@nikarh` `@pheki` `@zetanumbers` just to make sure they're aware of this change. Also removed one unused import from `process_unsupported` which should simply fix the warning for any target that uses it.
2024-07-21Rollup merge of #127583 - Nilstrieb:invalid-utf8, r=joboetJubilee-2/+3
Deal with invalid UTF-8 from `gai_strerror` When the system is using a non-UTF-8 locale, the value will indeed not be UTF-8. That sucks for everyone involved, but is no reason for panic. We can "handle" this gracefully by just using from lossy, replacing the invalid UTF-8 with � and keeping the accidentally valid UTF-8. Good luck when debugging, but at least it's not a crash. We already do this for `strerror_r`. fixes #127563
2024-07-21Fix warnings when checking armv6k-nintendo-3dsIan Chamberlain-2/+1
Also fix one instance of unsafe_op_in_unsafe_fn that's specific to horizon + vita - most others should be common with other code.
2024-07-21Deal with invalid UTF-8 from `gai_strerror`Nilstrieb-2/+3
When the system is using a non-UTF-8 locale, the value will indeed not be UTF-8. That sucks for everyone involved, but is no reason for panic. We can "handle" this gracefully by just using from lossy, replacing the invalid UTF-8 with the ? and keeping the accidentally valid UTF-8. Good luck when debugging, but at least it's not a crash. We already do this for `strerror_r`.
2024-07-21std::thread: available_parallelism implementation for vxWorks proposal.David Carlier-1/+11
2024-07-20Rollup merge of #128005 - ChrisDenton:msvc-include, r=joboetMatthias Krüger-13/+0
Remove _tls_used hack All the MSVC targets use `target_thread_locals` (see the [base spec](https://github.com/rust-lang/rust/blob/1afc5fd042f7583b9668dd62be98325487483d1c/compiler/rustc_target/src/spec/base/windows_msvc.rs#L34)) so this hack is no longer needed. The compiler will ensure that thread locals work properly.
2024-07-20Rollup merge of #127734 - ChrisDenton:netc, r=Mark-SimulacrumMatthias Krüger-109/+109
Windows: move BSD socket shims to netc On Windows we need to alter a few types so that they can be used in the cross-platform socket code. Currently these alterations are spread throughout the `c` module with some more in the `netc` module. Let's gather all our BSD compatibility shims in the `netc` module so it's all in one place and easier to discover.
2024-07-20Remove _tls_used hackChris Denton-13/+0
2024-07-20Rollup merge of #127873 - workingjubilee:forbid-unsafe-ops-for-kmc-solid, ↵Matthias Krüger-1/+4
r=Amanieu kmc-solid: `#![forbid(unsafe_op_in_unsafe_fn)]` The path logic _should_ handle the forbiddance in the itron sources correctly, despite them being an "out-of-line" module.
2024-07-20Rollup merge of #127843 - workingjubilee:break-up-big-ass-stack-overflow-fn, ↵Matthias Krüger-24/+61
r=joboet unix: document unsafety for std `sig{action,altstack}` I found many surprising elements here while trying to wrap a measly 5 functions with `unsafe`. I would rather not "just" mindlessly wrap this code with `unsafe { }`, so I decided to document it properly. On Unix, this code covers the "create and setup signal handler" part of the stack overflow code, and serves as the primary safety boundary for the signal handler. It is rarely audited, very gnarly, and worth extra attention. It calls other unsafe functions defined in this module, but "can we correctly map the right memory, or find the right address ranges?" are separate questions, and get increasingly platform-specific. The question here is the more general "are we doing everything in the correct order, and setting up the handler in the correct way?" As part of this audit, I noticed that we do some peculiar things that we should probably refrain from. However, I avoided making changes that I deemed might have a different final result in Rust programs. I did, however, reorder some events so that the signal handler is installed _after_ we install the alternate stack. We do not run much code between these events, but it is probably best if the timespan between the handler being available and the new stack being installed is 0 nanoseconds.
2024-07-20Inject win arm32 shims into metadata generationChris Denton-41/+26
2024-07-20Rollup merge of #123196 - Ayush1325:uefi-process, r=joboetMatthias Krüger-3/+886
Add Process support for UEFI UEFI does not have an actual process. However, it does provide methods to launch and execute another UEFI image. Having process support is important since it is possible to run rust test suit using `Command::output` and is the first step towards being able to run it for UEFI. Here is an overview of how the support is implemented. - We create a copy of the SystemTable. This is required since at least OVMF seems to crash if the original system table is modified. - Stdout and Stderr pipe works by registering a new `simple_text_output` Protocol and pointing the child system table to use those. - `Stdio::Inherit` just points the console to the current running image console which seems to work with even 3 levels of process. - `spawn` is left unimplemented since it does not make sense for UEFI architecture. Additionally, since https://github.com/rust-lang/rust/pull/105458 was merged, the `spawn` and `output` implementations are completely independent.
2024-07-19std: forbid unwrapped unsafe in unsupported_backslashJubilee Young-0/+1
2024-07-19kmc-solid: forbid(unsafe_op_in_unsafe_fn)Jubilee Young-1/+3
2024-07-19Rollup merge of #112328 - juliusl:pr/windows-add-change-time, r=ChrisDentonMatthias Krüger-0/+11
Feat. adding ext that returns change_time Addresses #112327
2024-07-19uefi: process: Fixes from PRAyush Singh-151/+230
- Update system table crc32 - Fix unsound use of Box - Free exit data - Code improvements - Introduce OwnedTable - Update r-efi to latest version - Use extended_varargs_abi_support for install_multiple_protocol_interfaces and uninstall_multiple_protocol_interfaces - Fix comments - Stub out args implementation Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-07-19uefi: process: Final TouchupsAyush Singh-19/+19
Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-07-19uefi: process: Add CommandArgs supportAyush Singh-14/+26
Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-07-19uefi: process: Add support for argsAyush Singh-21/+55
Also fix stdio inherit Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-07-19uefi: process Implement inheritAyush Singh-20/+37
Only tested in 2 levels right now. Need args support for 3 levels Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-07-19uefi: process: Add null protocolAyush Singh-38/+100
Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-07-19uefi: process: Add stderr supportAyush Singh-2/+34
Implement stderr support in similar fashion. Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-07-19uefi: process: Add support to capture stdoutAyush Singh-8/+258
Use a custom simple_text_output protocol to capture output. Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-07-19uefi: Add processAyush Singh-2/+399
Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-07-18unix: acquire-load NEED_ALTSTACKJubilee-1/+1
Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
2024-07-18unix: Unsafe-wrap stack_overflow::{drop,make}_handlerJubilee Young-10/+27
Note that current_guard is probably not unsafe for future work.
2024-07-18unix: Unsafe-wrap stack_overflow::cleanupJubilee Young-1/+6
Editorialize on the wisdom of this as we do.
2024-07-18unix: lift init of sigaltstack before sigactionJubilee Young-9/+17
This is technically "not necessary", as we will "just" segfault instead if we e.g. arrive inside the handler fn with the null altstack. However, it seems incorrect to go about this hoping that segfaulting is okay, seeing as how our purpose here is to mitigate stack overflow problems. Make sure NEED_ALTSTACK syncs with PAGE_SIZE when we do. Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
2024-07-18unix: Unsafe-wrap stack_overflow::signal_handlerJubilee Young-3/+10
sometimes a safety comment is a prayer. avoid fuzzy provenance casts after deref. Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
2024-07-17Rollup merge of #127845 - ↵Trevor Gross-90/+119
workingjubilee:actually-break-up-big-ass-stack-overflow-fn, r=joboet unix: break `stack_overflow::install_main_guard` into smaller fn This was one big deeply-indented function for no reason. This made it hard to reason about the boundaries of its safety. Or just, y'know, read. Simplify it by splitting it into platform-specific functions, but which are still asked to keep compiling (a desirable property, since all of these OS use a similar API). This is mostly a whitespace change, so I suggest reviewing it only after setting Files changed -> (the options gear) -> [x] Hide whitespace as that will make it easier to see how the code was actually broken up instead of raw line diffs.
2024-07-17feat: adding ext that returns change_time for WindowsJulius Liu-0/+11
2024-07-17Auto merge of #125942 - timokroeger:windows-once-futex, r=ChrisDentonbors-0/+1
Windows: Use futex implementation for `Once` Keep the queue implementation for win7. Inspired by PR #121956 <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r​? <reviewer name> -->
2024-07-17Rollup merge of #127813 - ChrisDenton:win-futex, r=joboetTrevor Gross-5/+8
Prevent double reference in generic futex In the Windows futex implementation we were a little lax at allowing references to references (i.e. `&&`) which can lead to deadlocks due to reading the wrong memory address. This uses a trait to tighten the constraints and ensure this doesn't happen. r? libs
2024-07-17Rollup merge of #127763 - ChrisDenton:safe-unsafe-unsafe, r=tgross35Trevor Gross-90/+111
Make more Windows functions `#![deny(unsafe_op_in_unsafe_fn)]` As part of #127747, I've evaluated some more Windows functions and added `unsafe` blocks where necessary. Some are just trivial wrappers that "inherit" the full unsafety of their function, but for others I've added some safety comments. A few functions weren't actually unsafe at all. I think they were just using `unsafe fn` to avoid an `unsafe {}` block. I'm not touching `c.rs` yet because that is partially being addressed by another PR and also I have plans to further reduce the number of wrapper functions we have in there. r? libs
2024-07-17unix: unsafe-wrap install_main_guard_defaultJubilee Young-9/+12
2024-07-17unix: clean up install_main_guard_freebsdJubilee Young-13/+12
This just was a mess.
2024-07-16unix: stack_start_aligned is a safe fnJubilee Young-7/+9
This function is purely informative, answering where a stack starts. This is a safe operation, even if an answer requires unsafe code, and even if the result is some unsafe code decides to trust the answer. It also doesn't need to fetch the PAGE_SIZE when its caller just did so! Let's complicate its signature and in doing so simplify its operation. This allows sprinkling around #[forbid(unsafe_op_in_unsafe_fn)]
2024-07-16unix: split stack_overflow::install_main_guard by osJubilee Young-90/+115
2024-07-17Prevent double reference in generic futexChris Denton-5/+8