about summary refs log tree commit diff
path: root/library/std/src/sys
AgeCommit message (Collapse)AuthorLines
2024-08-03Auto merge of #128404 - compiler-errors:revert-dead-code-changes, r=pnkfelixbors-0/+4
Revert recent changes to dead code analysis This is a revert to recent changes to dead code analysis, namely: * efdf219 Rollup merge of #128104 - mu001999-contrib:fix/128053, r=petrochenkov * a70dc297a899b76793a14c5705f6ec78fd7a57a7 Rollup merge of #127017 - mu001999-contrib:dead/enhance, r=pnkfelix * 31fe9628cf830a08e7194a446f66c668aaea86e9 Rollup merge of #127107 - mu001999-contrib:dead/enhance-2, r=pnkfelix * 2724aeaaeb127a8073e39461caacbe21a128ce7b Rollup merge of #126618 - mu001999-contrib:dead/enhance, r=pnkfelix * 977c5fd419ade52467f7de79d5bfc25c0c893275 Rollup merge of #126315 - mu001999-contrib:fix/126289, r=petrochenkov * 13314df21b0bb0cdd02c6760581d1b9f1052fa7e Rollup merge of #125572 - mu001999-contrib:dead/enhance, r=pnkfelix There is an additional change stacked on top, which suppresses false-negatives that were masked by this work. I believe the functions that are touched in that code are legitimately unused functions and the types are not reachable since this `AnonPipe` type is not publically reachable -- please correct me if I'm wrong cc `@NobodyXu` who added these in ##127153. Some of these reverts (#126315 and #126618) are only included because it makes the revert apply cleanly, and I think these changes were only done to fix follow-ups from the other PRs? I apologize for the size of the PR and the churn that it has on the codebase (and for reverting `@mu001999's` work here), but I'm putting this PR up because I am concerned that we're making ad-hoc changes to fix bugs that are fallout of these PRs, and I'd like to see these changes reimplemented in a way that's more separable from the existing dead code pass. I am happy to review any code to reapply these changes in a more separable way. cc `@mu001999` r? `@pnkfelix` Fixes #128272 Fixes #126169
2024-08-03Suppress new false-negatives that were masked by dead code analysis changesMichael Goulet-0/+4
2024-08-03Rollup merge of #128368 - nnethercote:rustfmt-tweaks, r=cuviperMatthias Krüger-0/+2
Formatting tweaks Some small post-#125443 formatting tweaks. r? ``@cuviper``
2024-08-03Rollup merge of #128303 - NobodyXu:specialise-for-pipe, r=cuviperMatthias Krüger-0/+25
Enable `std::io::copy` specialisation for `std::pipe::{PipeReader, PipeWriter}` Enable `std::io::copy` specialisation on unix for the newly added anonymous pipe API, tracking issue rust-lang/rust#127154
2024-08-03Rollup merge of #127586 - zachs18:more-must-use, r=cuviperMatthias Krüger-3/+3
Add `#[must_use]` to some `into_raw*` functions. cc #121287 r? ``@cuviper`` Adds `#[must_use = "losing the pointer will leak memory"]`[^1] to `Box::into_raw(_with_allocator)`, `Vec::into_raw_parts(_with_alloc)`, `String::into_raw_parts`[^2], and `rc::{Rc, Weak}::into_raw_with_allocator` (Rc's normal `into_raw` and all of `Arc`'s `into_raw*`s are already `must_use`). Adds `#[must_use = "losing the raw <resource name may leak resources"]` to `IntoRawFd::into_raw_fd`, `IntoRawSocket::into_raw_socket`, and `IntoRawHandle::into_raw_handle`. [^1]: "*will* leak memory" may be too-strong wording (since `Box`/`Vec`/`String`/`rc::Weak` might not have a backing allocation), but I left it as-is for simplicity and consistency. [^2]: `String::into_raw_parts`'s `must_use` message is changed from the previous (possibly misleading) "`self` will be dropped if the result is not used".
2024-08-03Forbid unsafe_op_in_unsafe_fn in vxworks specific os and sys filesB I Mohammed Abbas-0/+1
2024-08-03Auto merge of #128528 - ↵bors-8/+0
workingjubilee:you-dont-need-to-see-this-cpuid-move-along, r=Amanieu Finish removing `has_cpuid` The one use of it was guaranteed to be always true. try-job: test-various
2024-08-02Rollup merge of #128491 - c410-f3r:unlock-rfc-2011, r=workingjubileeMatthias Krüger-16/+2
[`macro_metavar_expr_concat`] Dogfooding cc #124225 Starts inner usage to test the robustness of the implementation.
2024-08-01std: Remove has_cpuidJubilee Young-8/+0
The one use of it was guaranteed to be always true.
2024-08-01DogfoodCaio-16/+2
2024-08-01Add math functions for `f16` and `f128`Trevor Gross-0/+15
This adds missing functions for math operations on the new float types. Platform support is pretty spotty at this point, since even platforms with generally good support can be missing math functions. `std/build.rs` is updated to reflect this.
2024-08-01Rollup merge of #128433 - hermit-os:hermit-unsafe_op_in_unsafe_fn, r=joboetMatthias Krüger-55/+57
fix(hermit): `deny(unsafe_op_in_unsafe_fn)` Tracking issue: https://github.com/rust-lang/rust/issues/127747 r? workingjubilee CC: ``@stlankes``
2024-08-01fix(pal/hermit): `deny(unsafe_op_in_unsafe_fn)`Martin Kröning-20/+40
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-08-01refactor(pal/hermit): make `ENV` a non-mutable staticMartin Kröning-19/+15
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-08-01Rollup merge of #128416 - maurer:remove-android-hack, r=tgross35Matthias Krüger-104/+0
android: Remove libstd hacks for unsupported Android APIs Our minimum supported API version is 21, remove hacks to support older Android APIs. try-job: arm-android r? tgross35
2024-08-01Rollup merge of #128162 - ChrisDenton:cleanup, r=joboetMatthias Krüger-59/+27
Cleanup sys module to match house style This moves a test file out of sys as it's just testing std types. Also cleans up some assorted bits including making the `use` statements match the house style.
2024-07-31std: fix busy-waiting in `Once::wait_force`, add more testsjoboet-4/+8
2024-07-31std: implement the `once_wait` featurejoboet-94/+178
2024-07-31Remove unneeded `pub(crate)`Chris Denton-1/+1
2024-07-31refactor(pal/hermit): use default impl of `GlobalAlloc::alloc_zeroed`Martin Kröning-10/+0
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-07-31refactor(pal/hermit): return `!` to satisfy rust-analyzerMartin Kröning-7/+3
This silences this rust-analyzer-specific error: `expected !, found ()` Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-07-31PinCoerceUnsized trait into coreXiangfei Ding-0/+4
2024-07-31android: Remove libstd hacks for unsupported Android APIsMatthew Maurer-104/+0
Our minimum supported API version is 21, remove hacks to support older Android APIs.
2024-07-30Move Windows implementation of anon pipeChris Denton-21/+12
2024-07-30Cleanup sys module to match house styleChris Denton-37/+14
2024-07-30Rollup merge of #128315 - zetanumbers:psvita-unsafe-in-unsafe, r=workingjubileeMatthias Krüger-0/+4
Fix vita build of std and forbid unsafe in unsafe in the os/vita module See #127747 r? `@workingjubilee` `@pheki` `@nikarh`
2024-07-30Insert some blank lines.Nicholas Nethercote-0/+2
After things that are immediately followed by a `use` declaration and look like they might apply to that `use` item but actually don't.
2024-07-29Sparkle some attributes over `CloneToUninit` stuffPavel Grigorenko-0/+2
2024-07-29impl CloneToUninit for Path and OsStrPavel Grigorenko-0/+24
2024-07-29Rollup merge of #128055 - ↵Matthias Krüger-53/+61
workingjubilee:deny-unsafe-ops-in-sys-personality-dwarf-eh, r=Amanieu std: unsafe-wrap personality::dwarf::eh Moves the forbiddance up a little. This is another largely whitespace diff, except for hoisting some variable declarations to allow enclosing the `unsafe {}` scope fully and make it clearer where the bounds of some temporaries are.
2024-07-29Reformat `use` declarations.Nicholas Nethercote-629/+441
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-28fix: psvita's std codeDaria Sukhonina-0/+4
2024-07-28Enable `std::io::copy` specialisation for `std::pipe::{PipeReader, PipeWriter}`Jiahao XU-0/+25
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2024-07-26Fix doc nitsJohn Arundel-50/+54
Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits. https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
2024-07-25fix: compilation issue w/ refactored typeJulius Liu-2/+2
2024-07-25Auto merge of #128195 - matthiaskrgr:rollup-195dfdf, r=matthiaskrgrbors-41/+26
Rollup of 6 pull requests Successful merges: - #126908 (Use Cow<'static, str> for InlineAsmTemplatePiece::String) - #127999 (Inject arm32 shims into Windows metadata generation) - #128137 (CStr: derive PartialEq, Eq; add test for Ord) - #128185 (Fix a span error when parsing a wrong param of function.) - #128187 (Fix 1.80.0 version in RELEASES.md) - #128189 (Turn an unreachable code path into an ICE) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-25Rollup merge of #127999 - ChrisDenton:arm32, r=AmanieuMatthias Krüger-41/+26
Inject arm32 shims into Windows metadata generation I had been keen to eventually move to using windows-sys as a normal Cargo dependency. But for linking, compile times and other reasons that's unlikely to ever happen. So if we're sticking with generated bindings then injecting any necessary missing type definitions (i.e. for the MS unsupported arm32) is simpler than defining whole functions ourselves just because we need to manually implement those types on a tier 3 platform. This also reduces the places we need to change when making changes to how we use `#[link]`. r? libs
2024-07-25Rollup merge of #128158 - workingjubilee:unsafe-wrap-personality-gcc, ↵Matthias Krüger-141/+180
r=ChrisDenton std: unsafe-wrap personality::gcc Nothing seems obviously wrong with these implementations except for some unanswered questions. Admittedly, I don't want to burn excessive time on exceptional exception handlers. Thus this is mostly a brute-force syntactic wrapping and some comments where they seemed correct, creating another largely whitespace diff. try-job: armhf-gnu
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.