about summary refs log tree commit diff
path: root/library/std/src/sys
AgeCommit message (Collapse)AuthorLines
2024-07-25Rollup merge of #127300 - biabbas:fix_connect_timeout, r=tgross35Matthias Krüger-10/+19
Fix connect timeout for non-linux targets, read readiness of socket connection, Read readiness to detect errors. `Fixes #127018` Fixes #127018 Connect_timeout would call `poll` and check `pollfd.revents` for POLLHUP error, rather that checking readiness. This behavior was meant for Linux as it returns POLLHUP | POLLOUT | POLLERR in case of errors. But on targets that do not return POLLHUP in `pollfd.revents`, this would indicate a false success and result in this issue. To resolve this we will check readiness of socket using `getsockopt():` and return success from connect_timeout when there are no errors. Changes were tested on Linux and an rtos. ![Screenshot 2024-07-04 105820](https://github.com/rust-lang/rust/assets/88673422/5ef5a87f-f2af-4fb7-98da-7612d5e27e9a) Thank you.
2024-07-25In connect timeout, read readiness of socket for vxworks. Check pollhup or ↵B I Mohammed Abbas-10/+19
pollerr for refused connections in linux
2024-07-24std: update comments on gcc personality fnJubilee Young-10/+32
2024-07-24std: unsafe-wrap gcc::rust_eh_personality and implJubilee Young-131/+148
2024-07-24Rollup merge of #128131 - ChrisDenton:stuff, r=workingjubileeMatthias Krüger-32/+35
Import `c_void` rather than using the full path Follow up to #128092. As requested, this imports `c_void` in more places. I also fixed up some imports to use `core` for core types instead of `crate`. While that is not strictly necessary, I think ideally things in `sys/pal` should only depend on itself or core so that the code is less spaghetti. We're far away from that ideal at the moment but I can at least try to slowly move in that direction. Also this forbids `unsafe_op_in_unsafe_fn` for library/std/src/sys/pal/windows by fixing up the remaining unsafe bits that are just punting their unsafe requirements onto the caller of the `unsafe` function (or definition macro). <!-- r? workingjubilee -->
2024-07-24Rollup merge of #127733 - GrigorenkoPV:don't-forget, r=AmanieuMatthias Krüger-43/+24
Replace some `mem::forget`'s with `ManuallyDrop` > but I would like to see a larger effort to replace all uses of `mem::forget`. _Originally posted by `@saethlin` in https://github.com/rust-lang/rust/issues/127584#issuecomment-2226087767_ So, r? `@saethlin` Sorry, I have finished writing all of this before I got your response.
2024-07-24Rollup merge of #127480 - biabbas:vxworks, r=workingjubileeMatthias Krüger-4/+34
Fix build failure on vxworks #127084 PR to address issue #127084 . 1. Skip `reset_segpipe` for vxworks 2. Return unimplemented error for vxworks from settimes and lchown 3. Temporarily skip dirfd for vxworks 4. Add allow unused unsafe on read_at and write_at functions in unix/fs.rs 5. Using cfg disable ON_BROKEN_PIPE_FLAG_USED and on_broken_pipe_flag_used() for vxworks 6. Remove old crate::syscommon::thread::min_stack() reference from process_vxworks.rs and update to set stack size of rtpthread Thank you.
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-1/+7
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/+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.