about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2024-02-15Replace `NonZero::<_>::new` with `NonZero::new`.Markus Reiter-29/+27
2024-02-15Use generic `NonZero` internally.Markus Reiter-89/+91
2024-02-15Remove unnecessary else block from `thread_local!` expanded codeShoyu Vanilla-1/+2
2024-02-14Auto merge of #121078 - oli-obk:rollup-p11zsav, r=oli-obkbors-6/+10
Rollup of 13 pull requests Successful merges: - #116387 (Additional doc links and explanation of `Wake`.) - #118738 (Netbsd10 update) - #118890 (Clarify the lifetimes of allocations returned by the `Allocator` trait) - #120498 (Uplift `TypeVisitableExt` into `rustc_type_ir`) - #120530 (Be less confident when `dyn` suggestion is not checked for object safety) - #120915 (Fix suggestion span for `?Sized` when param type has default) - #121015 (Optimize `delayed_bug` handling.) - #121024 (implement `Default` for `AsciiChar`) - #121039 (Correctly compute adjustment casts in GVN) - #121045 (Fix two UI tests with incorrect directive / invalid revision) - #121049 (Do not point at `#[allow(_)]` as the reason for compat lint triggering) - #121071 (Use fewer delayed bugs.) - #121073 (Fix typos in `OneLock` doc) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-14Rollup merge of #121073 - IgorLaborieWefox:patch-1, r=workingjubileeOli Scherer-1/+1
Fix typos in `OneLock` doc
2024-02-14Rollup merge of #118738 - devnexen:netbsd10_update, r=cuviperOli Scherer-5/+9
Netbsd10 update
2024-02-14Auto merge of #100603 - tmandry:zst-guards, r=dtolnaybors-2/+49
Optimize away poison guards when std is built with panic=abort > **Note**: To take advantage of this PR, you will have to use `-Zbuild-std` or build your own toolchain. rustup toolchains always link to a libstd that was compiled with `panic=unwind`, since it's compatible with `panic=abort` code. When std is compiled with `panic=abort` we can remove a lot of the poison machinery from the locks. This changes the `Flag` and `Guard` types to be ZSTs. It also adds an uninhabited member to `PoisonError` so the compiler knows it can optimize away the `Result::Err` paths, and make `LockResult<T>` layout-equivalent to `T`. ### Is this a breaking change? `PoisonError::new` now panics if invoked from a libstd built with `panic="abort"` (or any non-`unwind` strategy). It is unclear to me whether to consider this a breaking change. In order to encounter this behavior, **both of the following must be true**: #### Using a libstd with `panic="abort"` This is pretty uncommon. We don't build libstd with that in rustup, except in (Tier 2-3) platforms that do not support unwinding, **most notably wasm**. Most people who do this are using cargo's `-Z build-std` feature, which is unstable. `panic="abort"` is not a supported option in Rust's build system. It is possible to configure it using `CARGO_TARGET_xxx_RUSTFLAGS`, but I believe this only works on **non-host** platforms. #### Creating `PoisonError` manually This is also unlikely. The only common use case I can think of is in tests, and you can't run tests with `panic="abort"` without the unstable `-Z panic_abort_tests` flag. It's possible that someone is implementing their own locks using std's `PoisonError` **and** defining "thread failure" to mean something other than "panic". If this is the case then we would break their code if it was used with a `panic="abort"` libstd. The locking crates I know of don't replicate std's poison API, but I haven't done much research into this yet. I've touched on a fair number of considerations here. Which ones do people consider relevant?
2024-02-14Automatically sort windows_sys bindingsChris Denton-8/+1
2024-02-14Add windows_sys readmeChris Denton-0/+9
2024-02-14Move windows_sys.lst to bindings.txtChris Denton-1/+0
2024-02-14Fix typos in `OneLock` docIgor-1/+1
2024-02-13Fix incorrect use of `compile_fail`Noah Lev-3/+3
`compile_fail` should only be used when the code is meant to show what *not* to do. In other words, there should be a fundamental flaw in the code. However, in this case, the example is just incomplete, so we should use `ignore` to avoid confusing readers.
2024-02-13Implement Instant for UEFIAyush Singh-0/+120
- Uses Timestamp Protocol if present. Else use rdtsc for x86 and x86-64 Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-02-13Auto merge of #120938 - Ayush1325:uefi-thread, r=joboet,Nilstriebbors-1/+60
Implement sys/thread for UEFI Since UEFI has no concept of threads, most of this module can be ignored. However, implementing parts that make sense. - Implement sleep - Implement available_parallelism
2024-02-12Auto merge of #110211 - joboet:queue_lock, r=Amanieubors-198/+571
Replace pthread `RwLock` with custom implementation This is one of the last items in #93740. I'm doing `RwLock` first because it is more self-contained and has less tradeoffs to make. The motivation is explained in the documentation, but in short: the pthread rwlock is slow and buggy and `std` can do much better. I considered implementing a parking lot, as was discussed in the tracking issue, but settled for the queue-based version because writing self-balancing binary trees is not fun in Rust... This is a rather complex change, so I have added quite a bit of documentation to help explain it. Please point out any part that could be explained better. ~~The read performance is really good, I'm getting 4x the throughput of the pthread version and about the same performance as usync/parking_lot on an Apple M1 Max in the usync benchmark suite, but the write performance still falls way behind what usync and parking_lot achieve. I tried using a separate queue lock like what usync uses, but that didn't help. I'll try to investigate further in the future, but I wanted to get some eyes on this first.~~ [Resolved](https://github.com/rust-lang/rust/pull/110211#issuecomment-1513682336) r? `@m-ou-se` CC `@kprotty`
2024-02-11Rollup merge of #120740 - ChrisDenton:cmaths, r=Mark-SimulacrumMatthias Krüger-140/+88
Make cmath.rs a single file It makes sense to have this all in one file. There's essentially only one target that has missing symbols and that's easy enough to handle inline. Note that the Windows definitions used to use `c_float` and `c_double` whereas the other platforms all used `f32` and `f64`. They've now been made consistent. However, `c_float` and `c_double` have the expected definitions on all Windows platforms we support.
2024-02-11std: use `stream_position` where applicableJoão Marcos P. Bezerra-29/+31
by replacing `seek(SeekFrom::Current(0))` calls
2024-02-11Implement sys/thread for UEFIAyush Singh-1/+60
Since UEFI has no concept of threads, most of this module can be ignored. However, implementing parts that make sense. - Implement sleep - Implement available_parallelism Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-02-11add doc-comment to `unlock_queue`joboet-0/+3
2024-02-11std: enabling new netbsd (10) calls.David Carlier-5/+9
Introducing a new config for this purpose as NetBSD 9 or 8 will be still around for a good while. For now, we re finally enabling sys::unix::rand::getrandom.
2024-02-11Rollup merge of #120459 - rytheo:handle-conversion-docs, r=Mark-SimulacrumMatthias Krüger-0/+25
Document various I/O descriptor/handle conversions Related to #51430
2024-02-10Fix typoJosh Triplett-1/+1
Co-authored-by: Benjamin Peter <145429680+benjamin-nw@users.noreply.github.com>
2024-02-11Auto merge of #120232 - c272:json-buildstd, r=Mark-Simulacrumbors-35/+41
Add support for custom JSON targets when using build-std. Currently, when building with `build-std`, some library build scripts check properties of the target by inspecting the target triple at `env::TARGET`, which is simply set to the filename of the JSON file when using JSON target files. This patch alters these build scripts to use `env::CARGO_CFG_*` to fetch target information instead, allowing JSON target files describing platforms without `restricted_std` to build correctly when using `-Z build-std`. There are some weak assertions here (for example, `nintendo && newlib`), however this seems at least a marginal improvement on the existing solution. Fixes https://github.com/rust-lang/wg-cargo-std-aware/issues/60.
2024-02-09Auto merge of #120852 - matthiaskrgr:rollup-01pr8gj, r=matthiaskrgrbors-52/+157
Rollup of 11 pull requests Successful merges: - #120351 (Implement SystemTime for UEFI) - #120354 (improve normalization of `Pointee::Metadata`) - #120776 (Move path implementations into `sys`) - #120790 (better error message on download CI LLVM failure) - #120806 (Clippy subtree update) - #120815 (Improve `Option::inspect` docs) - #120822 (Emit more specific diagnostics when enums fail to cast with `as`) - #120827 (Print image input file and checksum in CI only) - #120836 (hide impls if trait bound is proven from env) - #120844 (Build DebugInfo for async closures) - #120851 (Remove duplicate release note) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-09std::thread update freebsd stack guard handling.David Carlier-5/+25
up to now, it had been assumed the stack guard setting default is not touched in the field but some user might just want to disable it or increase it. checking it once at runtime should be enough.
2024-02-09Rollup merge of #120776 - joboet:move_pal_path, r=ChrisDentonMatthias Krüger-51/+24
Move path implementations into `sys` Part of #117276. r? `@ChrisDenton`
2024-02-09Rollup merge of #120351 - Ayush1325:uefi-time, r=m-ou-seMatthias Krüger-1/+133
Implement SystemTime for UEFI - Uses SystemTable->RuntimeServices->GetTime() - Uses the algorithm described [here](https://blog.reverberate.org/2020/05/12/optimizing-date-algorithms.html) for conversion to UNIX time
2024-02-09Auto merge of #120676 - Mark-Simulacrum:bootstrap-bump, r=clubby789bors-11/+10
Bump bootstrap compiler to just-built 1.77 beta https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-02-09address review commentsjoboet-21/+19
2024-02-09be more explicit about why adding backlinks eagerly makes sensejoboet-6/+7
2024-02-09format using latest rustfmtjoboet-4/+12
2024-02-09inline some single-use functions, add documentationjoboet-23/+23
2024-02-09queue_rwlock: use a separate `QUEUE_LOCKED` bit to synchronize waiter queue ↵joboet-144/+195
updates
2024-02-09use exponential backoff in `lock_contended`joboet-2/+4
2024-02-09immediately register writer node if threads are queuedjoboet-2/+3
2024-02-09avoid unnecessary `Thread` handle allocationjoboet-1/+2
2024-02-09use braces to make operator precedence less ambiguousjoboet-1/+1
2024-02-09adjust code documentationjoboet-4/+4
2024-02-09std: replace pthread `RwLock` with custom implementation inspired by usyncjoboet-198/+506
2024-02-09Auto merge of #120238 - joboet:always_confirm_lock_success, r=Mark-Simulacrumbors-1/+18
Always check the result of `pthread_mutex_lock` Fixes #120147. Instead of manually adding a list of "good" platforms, I've simply made the check unconditional. pthread's mutex is already quite slow on most platforms, so one single well-predictable branch shouldn't hurt performance too much.
2024-02-09Implement SystemTime for UEFIAyush Singh-1/+133
- Uses SystemTable->RuntimeServices->GetTime() Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-02-08Step all bootstrap cfgs forwardMark Rousskov-6/+5
This also takes care of other bootstrap-related changes.
2024-02-08Bump version placeholdersMark Rousskov-5/+5
2024-02-08std: move path into `sys`joboet-51/+24
2024-02-07Make `io::BorrowedCursor::advance` safeBenoît du Garreau-21/+13
This also keeps the old `advance` method under `advance_unchecked` name. This makes pattern like `std::io::default_read_buf` safe to write.
2024-02-07Make cmath.rs a single fileChris Denton-140/+88
2024-02-07Update testsr0cky-0/+2
2024-02-05Auto merge of #117372 - Amanieu:stdarch_update, r=Mark-Simulacrumbors-12/+24
Update stdarch submodule Splits up #27731 into multiple tracking issues. Closes #27731
2024-02-05Add support for custom JSON targets when using build-std.Lawrence Tang-35/+41
Currently, when building with `build-std`, some library build scripts check properties of the target by inspecting the target triple at `env::TARGET`, which is simply set to the filename of the JSON file when using JSON target files. This patch alters these build scripts to use `env::CARGO_CFG_*` to fetch target information instead, allowing JSON target files describing platforms without `restricted_std` to build correctly when using `-Z build-std`. Fixes wg-cargo-std-aware/#60.
2024-02-05Rollup merge of #120657 - mu001999:clean, r=NilstriebMatthias Krüger-9/+0
Remove unused struct Detected by #118257