about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2024-02-16Auto merge of #120538 - kornelski:read-not-exact, r=m-ou-sebors-2/+2
Make File::read_to_end less special Follow-up to #117925
2024-02-16std: move locks to `sys` on platforms without threadsjoboet-17/+10
2024-02-16std: move locks to `sys` on xousjoboet-10/+11
2024-02-16std: move locks to `sys` on Windowsjoboet-8/+10
2024-02-16std: move locks to `sys` on UNIX and other futex platformsjoboet-218/+55
2024-02-16std: move locks to `sys` on teeosjoboet-10/+158
2024-02-16std: move locks to `sys` on SGXjoboet-23/+19
2024-02-16std: move locks to `sys` on µITRONjoboet-41/+41
2024-02-16Auto merge of #120486 - reitermarkus:use-generic-nonzero, r=dtolnaybors-91/+91
Use generic `NonZero` internally. Tracking issue: https://github.com/rust-lang/rust/issues/120257
2024-02-16Auto merge of #120889 - Ayush1325:uefi-instant, r=joshtriplettbors-0/+120
Implement Instant for UEFI - Uses Timestamp Protocol if present. Else use rdtsc for x86 and x86-64
2024-02-15Update library/std/src/fs.rsHaydon Ryan-2/+2
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2024-02-15Update library/std/src/fs.rsHaydon Ryan-2/+2
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2024-02-15Rollup merge of #120672 - devnexen:update_thread_stack_guardpages_fbsd, ↵Guillaume Gomez-5/+25
r=m-ou-se std::thread update freebsd stack guard handling. 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-15Rollup merge of #121098 - ShoyuVanilla:thread-local-unnecessary-else, ↵Matthias Krüger-1/+2
r=Nilstrieb Remove unnecessary else block from `thread_local!` expanded code Some expanded codes make ["unnecessary else block" warnings](https://github.com/rust-lang/rust-analyzer/issues/16556#issuecomment-1944271716) for Rust Analyzer
2024-02-15Rollup merge of #118749 - ChrisDenton:winsys, r=cuviperMatthias Krüger-9/+10
Make contributing to windows bindings easier This PR does three things: - Automatically sorts bindings so contributors don't have to. I should have done this to begin with but was lazy. - Renames `windows_sys.lst` to `bindings.txt`. This [matches the windows-rs repository](https://github.com/microsoft/windows-rs/blob/8e71051ea8a57594478e585d2740126893f9dbb7/crates/tools/sys/bindings.txt) (and repos that copy it). I believe consistency with other projects helps get people orientated. - Adds a `README.md` file explaining what this is about and how to add bindings. This has the benefit of being directly editable and it's rendered when viewed online. Also people are understandably jumping right into the `windows_sys.rs` file via ripgrep or github search and so missing that it's generated. A `README.md` alongside it is at least slightly more obvious in that case. There is still a small note at the top of `windows_sys` in case people do read from the beginning. None of this has any impact on the actual code generated. It's purely to make the new contributors workflow a bit nicer.
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-5/+7
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-4/+6
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-4/+6
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-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