about summary refs log tree commit diff
path: root/library/std/src/sys
AgeCommit message (Collapse)AuthorLines
2024-05-12Auto merge of #124798 - devnexen:illumos_memalign_fix, r=RalfJungbors-2/+0
std::alloc: use posix_memalign instead of memalign on solarish `memalign` on Solarish requires the alignment to be at least the size of a pointer, which we did not honor. `posix_memalign` also requires that, but that code path already takes care of this requirement. close GH-124787
2024-05-11std::alloc: using posix_memalign instead of memalign on solarish.David Carlier-2/+0
simpler code path since small alignments are already taking care of. close GH-124787
2024-05-11Rollup merge of #124766 - devnexen:getrandom_solarish, r=Mark-SimulacrumMatthias Krüger-1/+12
std::rand: adding solaris/illumos for getrandom support. To help solarish support for miri https://https://github.com/rust-lang/miri/issues/3567
2024-05-08Rollup merge of #124788 - madsmtm:reduce-target_os-macos, r=workingjubileeJubilee-17/+24
Convert instances of `target_os = "macos"` to `target_vendor = "apple"` https://github.com/rust-lang/rust/pull/124491 migrated towards using `target_vendor = "apple"` more, as there's very little difference between iOS, tvOS, watchOS and visionOS. In that PR, I only did the changes where the standard library already had fixes for iOS, that I could confidently apply to the other targets. However, there's actually also not that big of a gap between macOS and the aforementioned platforms - so in this PR, I've gone through a few of the instances of `target_os = "macos"` and replaced it with `target_vendor = "apple"` to improve support on those platforms, see the commits for details. r? workingjubilee CC `@thomcc` `@simlay` (do tell me if I should stop pinging you on these Apple PRs) `@rustbot` label O-apple
2024-05-08Rollup merge of #124470 - devnexen:no_sigpipe_fbsd, r=workingjubileeJubilee-1/+8
std::net: Socket::new_raw now set to SO_NOSIGPIPE on freebsd.
2024-05-06std::rand: adding solaris/illumos for getrandom support.David Carlier-1/+12
To help solarish support for miri https://rust-lang/miri/issues/3567
2024-05-06iOS/tvOS/watchOS/visionOS: Improve File Debug implMads Marquart-9/+9
This uses `libc::fcntl`, which, while not explicitly marked as available in the headers, is already used by `File::sync_all` and `File::sync_data` on these platforms, so should be fine to use here as well.
2024-05-06iOS/tvOS/watchOS/visionOS: Fix reading large filesMads Marquart-5/+6
Tested in the iOS simulator with something like: ``` let mut buf = vec![0; c_int::MAX as usize - 1 + 2]; let read_bytes = f.read(&mut buf).unwrap(); ```
2024-05-06iOS/tvOS/watchOS: Fix alloc w. large alignment on older versionsMads Marquart-1/+7
Tested on an old MacBook and the iOS simulator.
2024-05-06iOS/tvOS/watchOS/visionOS: Set the main thread nameMads Marquart-2/+2
Tested in the iOS simulator that the thread name is not set by default, and that setting it improves the debugging experience in lldb / Xcode.
2024-05-05Fix unwinding on 32-bit watchOS ARMMads Marquart-3/+11
The code is written in a way to support 32-bit iOS and tvOS ARM devices, for future compatibility even though we currently only have a target for 32-bit iOS ARM.
2024-05-04library/std: Fix build for NetBSD targets with 32-bit `c_long`Ian Douglas Scott-2/+2
This fixes building `std` for targets like `mipsel-unknown-netbsd`. If `c_long` is an `i64`, this conversion works with `Into`. But if it's an `i32`, this failed to convert a `u32` to an `i32`.
2024-05-04Rollup merge of #124159 - joboet:move_pal_thread_parking, r=ChrisDentonMatthias Krüger-54/+247
Move thread parking to `sys::sync` Part of #117276. I'll leave the platform-specific API abstractions in `sys::pal`, as per the initial proposal. I'm not entirely sure whether we'll want to keep it that way, but that remains to be seen. r? ``@ChrisDenton`` (if you have time)
2024-05-03Rollup merge of #124480 - Enselic:on-broken-pipe, r=jieyouxuMichael Goulet-15/+15
Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...` In the stabilization [attempt](https://github.com/rust-lang/rust/pull/120832) of `#[unix_sigpipe = "sig_dfl"]`, a concern was [raised ](https://github.com/rust-lang/rust/pull/120832#issuecomment-2007394609) related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward. So as a first step towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature. Another point was [also raised](https://github.com/rust-lang/rust/pull/120832#issuecomment-1987023484), namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization. Tracking issue: https://github.com/rust-lang/rust/issues/97889
2024-05-03Horizon OS: dirfd unavailableAndrea Ciliberti-0/+1
2024-05-02Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...`Martin Nordholts-15/+15
In the stabilization attempt of `#[unix_sigpipe = "sig_dfl"]`, a concern was raised related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward. So as a first step towards towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature. Another point was also raised, namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization.
2024-05-02std: move thread parking to `sys::sync`joboet-54/+247
2024-05-01Auto merge of #124491 - madsmtm:target_vendor-apple, r=workingjubileebors-262/+52
Use `target_vendor = "apple"` instead of `target_os = "..."` Use `target_vendor = "apple"` instead of `all(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos")`. The apple targets are quite close to being identical, with iOS, tvOS, watchOS and visionOS being even closer, so using `target_vendor` when possible makes it clearer when something is actually OS-specific, or just Apple-specific. Note that `target_vendor` will [be deprecated in the future](https://github.com/rust-lang/rust/issues/100343), but not before an alternative (like `target_family = "apple"`) is available. While doing this, I found various inconsistencies and small mistakes in the standard library, see the commits for details. Will follow-up with an extra PR for a similar issue that need a bit more discussion. EDIT: https://github.com/rust-lang/rust/pull/124494 Since you've talked about using `target_vendor = "apple"` in the past: r? workingjubilee CC `@simlay,` `@thomcc` `@rustbot` label O-macos O-ios O-tvos O-watchos O-visionos
2024-04-29Fix Fuchsia build broken by #124210David Koloski-0/+1
Fuchsia doesn't support dirfd although we have a symbol stubbed for it.
2024-04-29Fix ESP IDF build broken by #124210ivmarkov-0/+1
2024-04-28Fix posix_spawn not being used on iOS and visionOSMads Marquart-8/+3
`man posix_spawn` documents it to be able to return `ENOENT`, and there should be nothing preventing this. Tested in the iOS simulator and on Mac Catalyst.
2024-04-28Fix SIGEMT and SIGINFO parsing on watchOS and visionOSMads Marquart-7/+3
2024-04-28Fix available_parallelism on watchOS and visionOSMads Marquart-3/+1
Both `sysconf` and `_SC_NPROCESSORS_ONLN` is available on all Apple platforms.
2024-04-28std::net: Socket::new_raw set to SO_NOSIGPIPE on freebsd/netbsd/dragonfly.David Carlier-1/+8
2024-04-28Use `target_vendor = "apple"` instead of `target_os = "..."`Mads Marquart-244/+45
2024-04-28Auto merge of #124210 - the8472:consign-ebadf-to-the-fire, r=Mark-Simulacrumbors-0/+32
Abort a process when FD ownership is violated When an owned FD has already been closed before it's dropped that means something else touched an FD in ways it is not allowed to. At that point things can already be arbitrarily bad, e.g. clobbered mmaps. Recovery is not possible. All we can do is hasten the fire. Unlike the previous attempt in #124130 this shouldn't suffer from the possibility that FUSE filesystems can return arbitrary errors.
2024-04-28put FD validity behind late debug_asserts checkingThe 8472-18/+29
uses the same machinery as assert_unsafe_precondition
2024-04-28Rollup merge of #124447 - workingjubilee:set-argv-twice-on-gnu, r=ChrisDentonMatthias Krüger-6/+4
Unconditionally call `really_init` on GNU/Linux This makes miri not diverge in behavior, it fixes running Rust linux-gnu binaries on musl with gcompat, it fixes dlopen edge-cases that cranelift somehow hits, etc. Fixes #124126 thou hast gazed into this abyss with me: r? ``@ChrisDenton``
2024-04-27Unconditionally call really_initJubilee Young-6/+4
This makes miri not diverge in behavior, it fixes running Rust linux-gnu binaries on musl with gcompat, it fixes dlopen edge-cases that cranelift somehow hits, etc.
2024-04-27Elaborate in comment about `statx` probeTobias Bucher-8/+4
As requested by @workingjubilee in https://github.com/rust-lang/rust/pull/123928#discussion_r1564916743.
2024-04-27Rollup merge of #124387 - workingjubilee:use-raw-pointers-in-thread-locals, ↵Matthias Krüger-9/+12
r=joboet thread_local: be excruciatingly explicit in dtor code Use raw pointers to accomplish internal mutability, and clearly split references where applicable. This reduces the likelihood that any of these parts are misunderstood, either by humans or the compiler's optimizations. Fixes #124317 r? ``@joboet``
2024-04-26thread_local: refine LazyKeyInner::take safety docJubilee-1/+1
Co-authored-by: joboet <jonasboettiger@icloud.com>
2024-04-26Rollup merge of #124410 - RalfJung:path-buf-transmute, r=NilstriebJacob Pratt-0/+12
PathBuf: replace transmuting by accessor functions The existing `repr(transparent)` was anyway insufficient as `OsString` was not `repr(transparent)`. And furthermore, on Windows it was blatantly wrong as `OsString` wraps `Wtf8Buf` which is a `repr(Rust)` type with 2 fields: https://github.com/rust-lang/rust/blob/51a7396ad3d78d9326ee1537b9ff29ab3919556f/library/std/src/sys_common/wtf8.rs#L131-L146 So let's just be honest about what happens and add accessor methods that make this abstraction-breaking act of PathBuf visible on the APIs that it pierces through. Fixes https://github.com/rust-lang/rust/issues/124409
2024-04-26Auto merge of #123909 - dtolnay:utf8chunks, r=joboetbors-4/+2
Stabilize `Utf8Chunks` Pending FCP in https://github.com/rust-lang/rust/issues/99543. This PR includes the proposed modification in https://github.com/rust-lang/libs-team/issues/190 as agreed in https://github.com/rust-lang/rust/issues/99543#issuecomment-2050406568.
2024-04-26PathBuf: replace transmuting by accessor functionsRalf Jung-0/+12
2024-04-25thread_local: split refs to fields of KeyJubilee Young-3/+4
2024-04-25thread_local: use less &mut T in LazyKeyInner::takeJubilee Young-6/+8
Instead, use raw pointers to accomplish internal mutability throughout.
2024-04-24Stabilize Utf8ChunksDavid Tolnay-4/+2
2024-04-24Rollup merge of #124282 - RalfJung:fill_utf16_buf, r=ChrisDentonLeón Orell Valerian Liehr-5/+14
windows fill_utf16_buf: explain the expected return value The comment just says "return what the syscall returns", but that doesn't work for all syscalls as the Windows API is not consistent in how buffer size is negotiated. For instance, GetUserProfileDirectoryW works a bit differently, and so home_dir_crt has to translate this to the usual protocol itself. So it's worth describing that protocol. r? ``@ChrisDenton``
2024-04-24Rollup merge of #124281 - RalfJung:win-tls, r=joboetLeón Orell Valerian Liehr-4/+22
fix weak memory bug in TLS on Windows We need to store the `key` *after* we register the dtor. Now I hope there isn't also some other reason why we have to actually register the dtor last... `@joboet` is there a reason you picked this particular order in https://github.com/rust-lang/rust/pull/102655? Fixes https://github.com/rust-lang/rust/issues/123583
2024-04-23fix weak memory bug in TLS on WindowsRalf Jung-4/+22
2024-04-23windows fill_utf16_buf: explain the expected return valueRalf Jung-5/+14
2024-04-21Rollup merge of #124089 - ↵Guillaume Gomez-38/+66
simlay:fix-preadv64-and-pwritev64-link-for-watchos-and-visionos, r=workingjubilee Fix watchOS and visionOS for pread64 and pwrite64 calls In #122880, links to `preadv64` and `pwritev64` were added for `watchOS` however the underlying [`weak!` macro did not include `target_os = "watchos"`](https://github.com/rust-lang/rust/blob/c45dee5efd0c042e9d1e24559ebd0d6424d8aa70/library/std/src/sys/pal/unix/weak.rs#L30-L74). This resulted in an `xcodebuild` error when targeting `watchOS`: ``` Undefined symbols for architecture arm64: "_preadv64", referenced from: __rust_extern_with_linkage_preadv64 in libliveview_native_core.a[274](std-324fdd8d31e8eaa2.std.e18cf7e8d0336778-cgu.08.rcgu.o) "_pwritev64", referenced from: __rust_extern_with_linkage_pwritev64 in libliveview_native_core.a[274](std-324fdd8d31e8eaa2.std.e18cf7e8d0336778-cgu.08.rcgu.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` So I added them. I also went ahead and added the same for visionOS because it's bound to create the same issue.
2024-04-21Fix watchOS and visionOS for pread64 and pwrite64 callsSebastian Imlay-38/+66
* Refactor apple OSs to use pwritev and preadv rather pwritev64 and preadv64 * Updated the comments for preadv and pwritev
2024-04-20Abort a process when FD ownership is violatedThe 8472-0/+21
When an EBADF happens then something else already touched an FD in ways it is not allowed to. At that point things can already be arbitrarily bad, e.g. clobbered mmaps. Recovery is not possible. All we can do is hasten the fire.
2024-04-20Rollup merge of #123967 - RalfJung:static_mut_refs, r=Nilstrieb许杰友 Jieyou Xu (Joe)-3/+2
static_mut_refs: use raw pointers to remove the remaining FIXME Using `SyncUnsafeCell` would not make a lot of sense IMO.
2024-04-18Rollup merge of #124019 - ChrisDenton:futex-raw-dylib, r=joboetJubilee-1/+13
Use raw-dylib for Windows synchronization functions Fixes #123999 by using the raw-dylib feature to specify the DLL to load the Windows futex functions from (e.g. [`WaitOnAddress`](https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitonaddress)). This avoids reliance on the import library causing that issue. With apologies to ``@bjorn3,`` as it's currently necessary to revert this for cranelift.
2024-04-18Auto merge of #123144 - dpaoliello:arm64eclib, ↵bors-21/+22
r=GuillaumeGomez,ChrisDenton,wesleywiser Add support for Arm64EC to the Standard Library Adds the final pieces so that the standard library can be built for arm64ec-pc-windows-msvc (initially added in #119199) * Bumps `windows-sys` to 0.56.0, which adds support for Arm64EC. * Correctly set the `isEC` parameter for LLVM's `writeArchive` function. * Add `#![feature(asm_experimental_arch)]` to library crates where Arm64EC inline assembly is used, as it is currently unstable.
2024-04-16Rollup merge of #123811 - joboet:queue_em_up, r=ChrisDentonGuillaume Gomez-387/+58
Use queue-based `RwLock` on more platforms This switches over Windows 7, SGX and Xous to the queue-based `RwLock` implementation added in #110211, thereby fixing #121949 for Windows 7 and partially resolving #114581 on SGX. TEEOS can't currently be switched because it doesn't have a good thread parking implementation. CC `@roblabla` `@raoulstrackx` `@xobs` Could you help me test this, please? r? `@ChrisDenton` the Windows stuff should be familiar to you
2024-04-16Use raw-dylib for Windows futex APIsChris Denton-1/+13
This is a workaround for older mingw `synchronization` import library not working on at least some system.