about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
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-6/+14
Update stdarch submodule Splits up #27731 into multiple tracking issues. Closes #27731
2024-02-05Rollup merge of #120657 - mu001999:clean, r=NilstriebMatthias Krüger-9/+0
Remove unused struct Detected by #118257
2024-02-05Rollup merge of #120607 - conradludgate:fix-120603, r=dtolnayMatthias Krüger-2/+36
fix #120603 by adding a check in default_read_buf Fixes #120603 by checking the returned read n is in-bounds of the cursor. Interestingly, I noticed that `BorrowedBuf` side-steps this issue by using checked accesses. Maybe this can be switched to unchecked to mirror what BufReader does https://github.com/rust-lang/rust/blob/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/core/src/io/borrowed_buf.rs#L95
2024-02-05Remove unused structr0cky-9/+0
2024-02-04Document various I/O handle conversionsRyan Lowe-0/+25
2024-02-03Rollup merge of #120528 - GnomedDev:atomicu8-backtrace-style, r=cuviperMatthias Krüger-6/+6
Store SHOULD_CAPTURE as AtomicU8 `BacktraceStyle` easily fits into a u8, so `SHOULD_CAPTURE`, which is just `Atomic<Option<BacktraceStyle>>`, should be stored as `AtomicU8`
2024-02-03Rollup merge of #120523 - a1phyr:improve_read_buf_exact, r=the8472Matthias Krüger-1/+4
Improve `io::Read::read_buf_exact` error case - Use `const_io_error` instead of `Error::new` - Use the same message as `read_exact`
2024-02-03add another test to make sure it still works with full readsConrad Ludgate-2/+15
2024-02-03fix #120603 by adding a check in default_read_bufConrad Ludgate-1/+22
2024-01-31Make File::read_to_end less specialKornel-2/+2
Follow-up to #117925
2024-01-31Store SHOULD_CAPTURE as AtomicU8GnomedDev-6/+6
2024-01-31Rollup merge of #120430 - devnexen:fix_tls_dtor_fbsd, r=cuviperNadrieril-2/+2
std: thread_local::register_dtor fix proposal for FreeBSD. following-up 5d3d347 commit, rust started to spin __cxa_thread_call_dtors warnings even without any TLS usage. using instead home made TLS destructor handler `register_dtor_fallback`. close #120413
2024-01-31Improve `io::Read::read_buf_exact` error caseBenoît du Garreau-1/+4
- Use `const_io_error` instead of `Error::new` - Use the same message as `read_exact`
2024-01-30Rollup merge of #120485 - chenyukang:yukang-add-query-instability-check, ↵Guillaume Gomez-0/+3
r=michaelwoerister add missing potential_query_instability for keys and values in hashmap From https://github.com/rust-lang/rust/pull/120435#discussion_r1468883787, These API are also returning iterator, so we need add `potential_query_instability` for them?
2024-01-30Rollup merge of #120434 - fmease:revert-speeder, r=petrochenkovGuillaume Gomez-223/+124
Revert outdated version of "Add the wasm32-wasi-preview2 target" An outdated version of #119616 was merged in rollup #120309. This reverts those changes to enable #119616 to “retain the intended diff” after a rebase. ```@rylev``` has agreed that this would be the cleanest approach with respect to the history. Unblocks #119616. r? ```@petrochenkov``` or compiler or libs
2024-01-30Rollup merge of #120295 - reitermarkus:remove-ffi-nonzero, r=dtolnayGuillaume Gomez-17/+12
Remove `raw_os_nonzero` feature. This feature is superseded by a generic `NonZero` type: https://github.com/rust-lang/rust/issues/120257 Closes https://github.com/rust-lang/rust/issues/82363.
2024-01-30Rollup merge of #120452 - alexcrichton:update-windows-seek-write-docs, ↵Guillaume Gomez-1/+1
r=ChrisDenton std: Update documentation of seek_write on Windows Currently the documentation of `FileExt::seek_write` on Windows indicates that writes beyond the end of the file leave intermediate bytes uninitialized. This commentary dates back to the original inclusion of these functions in #35704 (wow blast from the past!). At the time the functionality here was implemented using `WriteFile`, but nowadays the `NtWriteFile` method is used instead. The documentation for `NtWriteFile` explicitly states: > If Length and ByteOffset specify a write operation past the current > end-of-file mark, NtWriteFile automatically extends the file and updates > the end-of-file mark; any bytes that are not explicitly written between > such old and new end-of-file marks are defined to be zero. This commentary has had a downstream impact in the `system-interface` crate where it tries to handle this by explicitly writing zeros, but I don't believe that's necessary any more. I'm sending a PR upstream here to avoid future confusion and codify that zeros are written in the intermediate bytes matching what Windows currently provides.
2024-01-30Rollup merge of #119991 - kornelski:endless-read, r=the8472Guillaume Gomez-0/+10
Reject infinitely-sized reads from io::Repeat These calls would always run out of memory. Related to #117925
2024-01-30Auto merge of #117925 - kornelski:read-to-oom, r=Amanieubors-7/+47
Handle out of memory errors in io:Read::read_to_end() #116570 got stuck due to a [procedural confusion](https://github.com/rust-lang/rust/pull/116570#issuecomment-1768271068). Retrying so that it can get FCP with the proper team now. cc `@joshtriplett` `@BurntSushi` ---- I'd like to propose handling of out-of-memory errors in the default implementation of `io::Read::read_to_end()` and `fs::read()`. These methods create/grow a `Vec` with a size that is external to the program, and could be arbitrarily large. Due to being I/O methods, they can already fail in a variety of ways, in theory even including `ENOMEM` from the OS too, so another failure case should not surprise anyone. While this may not help much Linux with overcommit, it's useful for other platforms like WASM. [Internals thread](https://internals.rust-lang.org/t/io-read-read-to-end-should-handle-oom/19662). I've added documentation that makes it explicit that the OOM handling is a nice-to-have, and not a guarantee of the trait. I haven't changed the implementation of `impl Read for &[u8]` and `VecDeque` out of caution, because in these cases users could assume `read` can't fail. This code uses `try_reserve()` + `extend_from_slice()` which is optimized since #117503.
2024-01-30add missing potential_query_instability for keys and values in hashmapyukang-0/+3
2024-01-30Add stdarch_wasm_atomic_wait feature in stdAmanieu d'Antras-0/+1
2024-01-30Update feature names for new stdarchAmanieu d'Antras-6/+8
2024-01-30Update stdarch submoduleAmanieu d'Antras-0/+5
2024-01-29Handle out of memory errors in fs::read/read_to_stringKornel-4/+6
2024-01-29Handle out of memory errors in io:Read::read_to_end()Kornel-3/+41
2024-01-29Remove `raw_os_nonzero` feature.Markus Reiter-17/+12
2024-01-29std: always check the result of `pthread_mutex_lock`joboet-1/+18
2024-01-29Rollup merge of #120462 - mu001999:clean, r=NilstriebDylan DPC-3/+0
Clean dead code Detected by #118257
2024-01-29Rollup merge of #120373 - HTGAzureX1212:HTGAzureX1212/issue-120040, ↵Dylan DPC-1/+33
r=ChrisDenton Adjust Behaviour of `read_dir` and `ReadDir` in Windows Implementation: Check Whether Path to Search In Exists This pull request changes the `read_dir` function's and the `ReadDir` structure's internal implementations for the Windows operating system to make its behaviour more accurate. It should be noted that `ERROR_FILE_NOT_FOUND` is returned by the `FindFirstFileW` function when *no matching files can be found*, not necessarily that the path to search in does not exist in the first place. Therefore, directly returning the "The system cannot find the file specified." may not be accurate. An extra check for whether the path to search in exists is added, returning a constructed `ReadDir` iterator with its handle being an `INVALID_HANDLE_VALUE` returned by the `FindFirstFileW` function if `ERROR_FILE_NOT_FOUND` is indeed the last OS error. The `ReadDir` implementation for the Windows operating system is correspondingly updated to always return `None` if the handle it has is an `INVALID_HANDLE_VALUE` which can only be the case if and only if specifically constructed by the `read_dir` function in the aforementioned conditions. It should also be noted that `FindFirstFileW` would have returned `ERROR_PATH_NOT_FOUND` if the path to search in does not exist in the first place. Presumably fixes #120040.
2024-01-29Clean dead coder0cky-3/+0
2024-01-28Make `impl<T: AsHandle>` impl take `?Sized`Gary Guo-5/+5
2024-01-28Make `impl<Fd: AsFd>` impl take `?Sized`Gary Guo-5/+5
2024-01-28std: Update documentation of seek_write on WindowsAlex Crichton-1/+1
Currently the documentation of `FileExt::seek_write` on Windows indicates that writes beyond the end of the file leave intermediate bytes uninitialized. This commentary dates back to the original inclusion of these functions in #35704 (wow blast from the past!). At the time the functionality here was implemented using `WriteFile`, but nowadays the `NtWriteFile` method is used instead. The documentation for `NtWriteFile` explicitly states: > If Length and ByteOffset specify a write operation past the current > end-of-file mark, NtWriteFile automatically extends the file and updates > the end-of-file mark; any bytes that are not explicitly written between > such old and new end-of-file marks are defined to be zero. This commentary has had a downstream impact in the `system-interface` crate where it tries to handle this by explicitly writing zeros, but I don't believe that's necessary any more. I'm sending a PR upstream here to avoid future confusion and codify that zeros are written in the intermediate bytes matching what Windows currently provides.
2024-01-28Revert "Add the wasm32-wasi-preview2 target"León Orell Valerian Liehr-223/+124
This reverts commit 31ecf341250a889ac1154b2cbe3f0b97f9d008c1. Co-authored-by: Ryan Levick <me@ryanlevick.com>
2024-01-27std: thread_local::register_dtor fix proposal for FreeBSD.David Carlier-2/+2
following-up 5d3d347 commit, rust started to spin __cxa_thread_call_dtors warnings even without any TLS usage. using instead home made TLS destructor handler `register_dtor_fallback`. close #120413
2024-01-27Reject infinitely-sized reads from io::RepeatKornel-0/+10
Related to #117925
2024-01-27Switch `NonZero` alias direction.Markus Reiter-0/+11
2024-01-27add extra check for invalid handle in ReadDir::nextHTGAzureX1212.-1/+8
2024-01-27make modifications as per reviewsHTGAzureX1212.-21/+25