about summary refs log tree commit diff
path: root/library/std/src
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-12Auto merge of #125012 - RalfJung:format-error, r=Mark-Simulacrum,workingjubileebors-1/+5
io::Write::write_fmt: panic if the formatter fails when the stream does not fail Follow-up to https://github.com/rust-lang/rust/pull/124954
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-11io::Write::write_fmt: panic if the formatter fails when the stream does not failRalf Jung-1/+5
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-21/+32
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 #124782 - anatawa12:docs-create-new-already-exists, ↵Jubilee-0/+9
r=workingjubilee add note about `AlreadyExists` to `create_new` Fixes #119244
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-06Rollup merge of #124520 - tbu-:pr_create_dir_all_doc, r=AmanieuMatthias Krüger-3/+7
Document that `create_dir_all` calls `mkdir`/`CreateDirW` multiple times
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-06Apply suggestions from code reviewanatawa12-2/+6
Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2024-05-06iOS/tvOS/watchOS/visionOS: Default to kernel-defined backlog in listenMads Marquart-4/+8
This behavior is defined in general for the XNU kernel, not just macOS: https://github.com/apple-oss-distributions/xnu/blob/rel/xnu-10002/bsd/kern/uipc_socket.c
2024-05-06add note about `AlreadyExists` to `create_new`anatawa12-0/+5
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-04Rollup merge of #124721 - ids1024:netbsd-32-bit-ulong, r=workingjubileeMatthias Krüger-2/+2
library/std: Fix build for NetBSD targets with 32-bit `c_long` 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-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 #122441 - a1phyr:improve_read_impls, r=ChrisDentonMatthias Krüger-10/+33
Improve several `Read` implementations - `read_to_end` and `read_to_string` for `Cursor` - Error on OOM in `read_to_string` of `&[u8]` and `VecDeque<u8>` - Avoid making the slices contiguous in `VecDeque::read_to_string` - ~`read_exact` and (unstable) `read_buf_exact` for `Take`~ - ~`read_buf` for `UnixStream` and `&UnixStream`~ (moved to #123084) - `read_to_end` for `ChildStdErr`
2024-05-04Rollup merge of #124159 - joboet:move_pal_thread_parking, r=ChrisDentonMatthias Krüger-57/+25
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-04Rollup merge of #123356 - joboet:set_current_size, r=ChrisDentonMatthias Krüger-2/+7
Reduce code size of `thread::set_current` #123265 introduced a rather large binary size regression, because it added an `unwrap()` call on a `Result<(), Thread>`, which in turn pulled its rather heavy `Debug` implementation. This PR fixes this by readding the `rtassert!` that was removed.
2024-05-03Rollup merge of #124480 - Enselic:on-broken-pipe, r=jieyouxuMichael Goulet-16/+16
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-03Rollup merge of #124059 - RalfJung:default_alloc_error_hook, r=workingjubileeMatthias Krüger-0/+6
default_alloc_error_hook: explain difference to default __rdl_oom in alloc Though I'm not sure if that is really the reason that this code is duplicated. On no_std it may already be possible to call user-defined code on allocation failure.
2024-05-03default_alloc_error_hook: explain difference to default __rdl_oom in allocRalf Jung-0/+6
2024-05-03Rollup merge of #124649 - Meziu:master, r=ChrisDentonMatthias Krüger-0/+1
Fix HorizonOS build broken by #124210 HorizonOS (for the Tier-3 target `armv6k-nintendo-3ds`) does not support `dirfd()`, as many other similar targets.
2024-05-03Horizon OS: dirfd unavailableAndrea Ciliberti-0/+1
2024-05-03Rollup merge of #124609 - RalfJung:float-precision, r=cuviperMatthias Krüger-116/+174
variable-precision float operations can differ depending on optimization levels Follow-up to https://github.com/rust-lang/rust/pull/121793 and https://github.com/rust-lang/rust/pull/118217 that accounts for optimizations changing the precision of these functions. Fixes https://github.com/rust-lang/rust/issues/109118 Fixes https://github.com/rust-lang/rust/issues/71355
2024-05-03Rollup merge of #124412 - RalfJung:io-safety, r=AmanieuMatthias Krüger-11/+22
io safety: update Unix explanation to use `Arc` Fixes https://github.com/rust-lang/rust/issues/124384 Cc ```@jsgf```
2024-05-02Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...`Martin Nordholts-16/+16
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-02variable-precision float operations behave non-deterministicallyRalf Jung-116/+174
2024-05-02std: move thread parking to `sys::sync`joboet-57/+25
2024-05-01Step bootstrap cfgsMark Rousskov-3/+1
2024-05-01Replace version placeholders for 1.79Mark Rousskov-9/+9
2024-05-01Auto merge of #124491 - madsmtm:target_vendor-apple, r=workingjubileebors-354/+81
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-29Document that `create_dir_all` calls `mkdir`/`CreateDirW` multiple timesTobias Bucher-3/+7
Also mention that there might be leftover directories in the error case.
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-336/+74
2024-04-28Auto merge of #124210 - the8472:consign-ebadf-to-the-fire, r=Mark-Simulacrumbors-1/+39
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-29/+32
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-27io safety: update Unix explanationRalf Jung-11/+22