about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2024-07-24Forbid unsafe_op_in_unsafe_fn in sys/pal/windowsChris Denton-10/+14
2024-07-24Import `core::ffi::c_void` in more placesChris Denton-22/+21
2024-07-24Add chroot unsupported implementation for VxWorksB I Mohammed Abbas-2/+8
2024-07-24Rollup merge of #128106 - hallfox:patch-1, r=ChrisDentonMatthias Krüger-3/+3
Fix return type of FileAttr methods on AIX target 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-24Rollup merge of #128092 - ChrisDenton:wrappers, r=workingjubileeMatthias Krüger-126/+43
Remove wrapper functions from c.rs I'd like for the windows `c.rs` just to contain the basic platform definitions and not anything higher level unless absolutely necessary. So this removes some wrapper functions that weren't really necessary in any case. The functions are only used in a few places which themselves are relatively thin wrappers. The "interesting" bit is that we had an `AlertableIoFn` that abstracted over `ReadFileEx` and `WriteFileEx`. I've replaced this with a closure. Also I removed an `#[allow(unsafe_op_in_unsafe_fn)]` while I was moving things around.
2024-07-24Auto merge of #127153 - NobodyXu:pipe, r=ChrisDentonbors-4/+468
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/+468
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/+3
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/+3
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-22Fix some `#[cfg_attr(not(doc), repr(..))]`Pavel Grigorenko-8/+4
Now that #90435 seems to have been resolved.
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-2/+5
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 #127918 - ChrisDenton:thread-name-string, r=joboetMatthias Krüger-23/+51
Safely enforce thread name requirements The requirements for the thread name to be both UTF-8 and null terminated are easily enforced by a wrapper type so lets do that. The fact this used to be just a bare `CString` has tripped me up before because it was entirely safe to use a non UTF-8 `CString`.
2024-07-20Rollup merge of #123196 - Ayush1325:uefi-process, r=joboetMatthias Krüger-3/+887
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-2/+4
2024-07-19Auto merge of #127982 - matthiaskrgr:rollup-nzyvphj, r=matthiaskrgrbors-2/+2
Rollup of 6 pull requests Successful merges: - #127295 (CFI: Support provided methods on traits) - #127814 (`C-cmse-nonsecure-call`: improved error messages) - #127949 (fix: explain E0120 better cover cases when its raised) - #127966 (Use structured suggestions for unconstrained generic parameters on impl blocks) - #127976 (Lazy type aliases: Diagostics: Detect bivariant ty params that are only used recursively) - #127978 (Avoid ref when using format! for perf) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-19Rollup merge of #127978 - nyurik:lib-refs, r=workingjubileeMatthias Krüger-2/+2
Avoid ref when using format! for perf Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse.
2024-07-19Avoid ref when using format! for perfYuri Astrakhan-2/+2
Clean up a few minor refs in `format!` macro, as it has a tiny perf cost. A few more minor related cleanups.
2024-07-19Rollup merge of #112328 - juliusl:pr/windows-add-change-time, r=ChrisDentonMatthias Krüger-0/+21
Feat. adding ext that returns change_time Addresses #112327
2024-07-19uefi: process: Fixes from PRAyush Singh-151/+231
- 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-19Use `#[rustfmt::skip]` on some `use` groups to prevent reordering.Nicholas Nethercote-0/+2
`use` declarations will be reformatted in #125443. Very rarely, there is a desire to force a group of `use` declarations together in a way that auto-formatting will break up. E.g. when you want a single comment to apply to a group. #126776 dealt with all of these in the codebase, ensuring that no comments intended for multiple `use` declarations would end up in the wrong place. But some people were unhappy with it. This commit uses `#[rustfmt::skip]` to create these custom `use` groups in an idiomatic way for a few of the cases changed in #126776. This works because rustfmt treats any `use` item annotated with `#[rustfmt::skip]` as a barrier and won't reorder other `use` items around it.
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>