about summary refs log tree commit diff
path: root/library/std/src/sys_common
AgeCommit message (Collapse)AuthorLines
2025-07-11docs: clarify “dag” in std::sys_common doc commentColten-1/+1
2025-05-24make `OsString::new` and `PathBuf::new` unstably constcyrgani-1/+1
2025-04-28std: get rid of `sys_common::process`joboet-154/+0
Move the public `CommandEnvs` into the `process` module (and make it a wrapper type for an internal iterator type) and everything else into `sys::process` as per #117276.
2025-03-08Move fs into sysThalia Archibald-61/+0
2025-02-19Skip scanning for surrogates when not known validThalia Archibald-1/+1
2025-02-19Add fast path for displaying pre-validated Wtf8BufThalia Archibald-0/+24
2025-02-19Rollup merge of #137155 - thaliaarchi:wtf8-organize, r=ChrisDentonMatthias Krüger-35/+35
Organize `OsString`/`OsStr` shims Synchronize the `bytes.rs` and `wtf8.rs` shims for `OsString`/`OsStr` so they're easier to diff between each other. This is mostly ordering items the same between the two. I tried to minimize moves and went for the average locations between the files. With them in the same order, it is clear that `FromInner<_>` is not implemented for `bytes::Buf` and `Clone::clone_from` is not implemented for `wtf8::Buf`, but they are for the other. Fix that. I added #[inline] to all inherent methods of the `OsString`/`OsStr` shims, because it seemed that was already the rough pattern. `bytes.rs` has more inlining than `wtf8.rs`, so I added the corresponding ones to `wtf8.rs`. Then, the common missing ones have no discernible pattern to me. They're not divided by non-allocating/allocating. Perhaps the pattern is that UTF-8 validation isn't inlined? Since these types are merely the inner values in `OsStr`/`OsString`, I put inline on all methods and let those public types dictate inlining. I have not inspected codegen or run benchmarks. Also, touch up some (private) documentation comments. r? ``````@ChrisDenton``````
2025-02-19Rollup merge of #120580 - HTGAzureX1212:HTGAzureX1212/issue-45795, r=m-ou-seMatthias Krüger-3/+3
Add `MAX_LEN_UTF8` and `MAX_LEN_UTF16` Constants This pull request adds the `MAX_LEN_UTF8` and `MAX_LEN_UTF16` constants as per #45795, gated behind the `char_max_len` feature. The constants are currently applied in the `alloc`, `core` and `std` libraries.
2025-02-16Simplify control flow with while-letThalia Archibald-22/+14
2025-02-16Improve WTF-8 commentsThalia Archibald-15/+23
2025-02-16add MAX_LEN_UTF8 and MAX_LEN_UTF16 constantsHTGAzureX1212-3/+3
2025-02-09Auto merge of #136751 - bjorn3:update_rustfmt, r=Mark-Simulacrumbors-55/+56
Update bootstrap compiler and rustfmt The rustfmt version we previously used formats things differently from what the latest nightly rustfmt does. This causes issues for subtrees that get formatted both in-tree and in their own repo. Updating the rustfmt used in-tree solves those issues. Also bumped the bootstrap compiler as the stage0 update command always updates both at the same time.
2025-02-08Rustfmtbjorn3-55/+56
2025-02-07std: get rid of `sys_common::io`joboet-50/+0
2025-02-02std: move network code into `sys`joboet-793/+0
As per #117276, this PR moves `sys_common::net` and the `sys::pal::net` into the newly created `sys::net` module. In order to support #135141, I've moved all the current network code into a separate `connection` module, future functions like `hostname` can live in separate modules. I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
2025-01-07Avoid naming variables `str`Josh Triplett-2/+2
This renames variables named `str` to other names, to make sure `str` always refers to a type. It's confusing to read code where `str` (or another standard type name) is used as an identifier. It also produces misleading syntax highlighting.
2024-12-23Use `#[derive(Default)]` instead of manually implementing itEsteban Küber-7/+1
2024-11-26std: update internal uses of `io::const_error!`joboet-3/+3
2024-11-12Make `CloneToUninit` dyn-compatibleZachary S-3/+3
2024-10-01std: replace `LazyBox` with `OnceBox`joboet-89/+0
This PR replaces the `LazyBox` wrapper used to allocate the pthread primitives with `OnceBox`, which has a more familiar API mirroring that of `OnceLock`. This cleans up the code in preparation for larger changes like #128184 (from which this PR was split) and allows some neat optimizations, like avoid an acquire-load of the allocation pointer in `Mutex::unlock`, where the initialization of the allocation must have already been observed. Additionally, I've gotten rid of the TEEOS `Condvar` code, it's just a duplicate of the pthread one anyway and I didn't want to repeat myself.
2024-09-29Fix std tests for wasm32-wasip2 targetNicola Krumschmidt-1/+1
2024-09-29Hook up std::net to wasi-libc on wasm32-wasip2 targetNicola Krumschmidt-1/+2
2024-09-25Use `&raw` in the standard libraryJosh Stone-6/+5
Since the stabilization in #127679 has reached stage0, 1.82-beta, we can start using `&raw` freely, and even the soft-deprecated `ptr::addr_of!` and `ptr::addr_of_mut!` can stop allowing the unstable feature. I intentionally did not change any documentation or tests, but the rest of those macro uses are all now using `&raw const` or `&raw mut` in the standard library.
2024-09-24Initial std library support for NuttXHuang Qi-0/+1
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-58/+57
2024-08-23Rollup merge of #127623 - lolbinarycat:fix_remove_dir_all, r=AmanieuMatthias Krüger-6/+23
fix: fs::remove_dir_all: treat internal ENOENT as success fixes #127576 try-job: test-various
2024-08-22fix: fs::remove_dir_all: treat ENOENT as successbinarycat-6/+23
fixes #127576 windows implementation still needs some work
2024-07-29Sparkle some attributes over `CloneToUninit` stuffPavel Grigorenko-0/+1
2024-07-29impl CloneToUninit for Path and OsStrPavel Grigorenko-0/+11
2024-07-29Reformat `use` declarations.Nicholas Nethercote-24/+10
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-28Rollup merge of #127765 - bitfield:fix_stdlib_doc_nits, r=dtolnayGuillaume Gomez-1/+1
Fix doc nits Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo"), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits.
2024-07-27[illumos/solaris] set MSG_NOSIGNAL while writing to socketsRain-0/+1
Both these platforms have MSG_NOSIGNAL available, and we should set it for socket writes in the event that the SIGPIPE handler has been reset to SIG_DFL (i.e. terminate the process). I've verified via a quick program at https://github.com/sunshowers/msg-nosignal-test/ that even when the SIGPIPE handler is reset to SIG_DFL, writes to closed sockets now error out with EPIPE. (Under ordinary circumstances UDP writes won't cause MSG_NOSIGNAL.)
2024-07-26Fix doc nitsJohn Arundel-1/+1
Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits. https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
2024-07-14std: Unsafe-wrap in Wtf8 implJubilee Young-5/+10
2024-07-14std: deny(unsafe_op_in_unsafe_fn) but allow sitesJubilee Young-0/+1
This provides a list of locations to hunt down issues in.
2024-06-25std: test a variety of ways to extend a Wtf8BufJubilee Young-0/+24
2024-06-25set self.is_known_utf8 to false in extend_from_sliceash-1/+1
2024-06-25`PathBuf::as_mut_vec` removed and verified for UEFI and Windows platforms ↵ash-6/+6
#126333
2024-06-24Auto merge of #126523 - joboet:the_great_big_tls_refactor, r=Mark-Simulacrumbors-256/+0
std: refactor the TLS implementation As discovered by Mara in #110897, our TLS implementation is a total mess. In the past months, I have simplified the actual macros and their expansions, but the majority of the complexity comes from the platform-specific support code needed to create keys and register destructors. In keeping with #117276, I have therefore moved all of the `thread_local_key`/`thread_local_dtor` modules to the `thread_local` module in `sys` and merged them into a new structure, so that future porters of `std` can simply mix-and-match the existing code instead of having to copy the same (bad) implementation everywhere. The new structure should become obvious when looking at `sys/thread_local/mod.rs`. Unfortunately, the documentation changes associated with the refactoring have made this PR rather large. That said, this contains no functional changes except for two small ones: * the key-based destructor fallback now, by virtue of sharing the implementation used by macOS and others, stores its list in a `#[thread_local]` static instead of in the key, eliminating one indirection layer and drastically simplifying its code. * I've switched over ZKVM (tier 3) to use the same implementation as WebAssembly, as the implementation was just a way worse version of that Please let me know if I can make this easier to review! I know these large PRs aren't optimal, but I couldn't think of any good intermediate steps. `@rustbot` label +A-thread-locals
2024-06-22Rollup merge of #126140 - eduardosm:stabilize-fs_try_exists, r=AmanieuMatthias Krüger-1/+1
Rename `std::fs::try_exists` to `std::fs::exists` and stabilize fs_try_exists FCP completed in tracking issue. Tracking issue: https://github.com/rust-lang/rust/issues/83186 Closes https://github.com/rust-lang/rust/issues/83186 Stabilized API: ```rust mod fs { pub fn exists<P: AsRef<Path>>(path: P) -> io::Result<bool>; } ```
2024-06-16std: move `sys_common::backtrace` to `sys`joboet-228/+0
2024-06-15std: refactor the TLS implementationjoboet-256/+0
As discovered by Mara in #110897, our TLS implementation is a total mess. In the past months, I have simplified the actual macros and their expansions, but the majority of the complexity comes from the platform-specific support code needed to create keys and register destructors. In keeping with #117276, I have therefore moved all of the `thread_local_key`/`thread_local_dtor` modules to the `thread_local` module in `sys` and merged them into a new structure, so that future porters of `std` can simply mix-and-match the existing code instead of having to copy the same (bad) implementation everywhere. The new structure should become obvious when looking at `sys/thread_local/mod.rs`. Unfortunately, the documentation changes associated with the refactoring have made this PR rather large. That said, this contains no functional changes except for two small ones: * the key-based destructor fallback now, by virtue of sharing the implementation used by macOS and others, stores its list in a `#[thread_local]` static instead of in the key, eliminating one indirection layer and drastically simplifying its code. * I've switched over ZKVM (tier 3) to use the same implementation as WebAssembly, as the implementation was just a way worse version of that Please let me know if I can make this easier to review! I know these large PRs aren't optimal, but I couldn't think of any good intermediate steps. @rustbot label +A-thread-locals
2024-06-12Make PathBuf less Ok with adding UTF-16 then `into_string`Jubilee Young-0/+3
2024-06-11Rename `std::fs::try_exists` to `std::fs::exists` and stabilize fs_try_existsEduardo Sánchez Muñoz-1/+1
2024-06-04impl OsString::leak & PathBuf::leakschvv31n-0/+5
2024-05-02std: move thread parking to `sys::sync`joboet-225/+0
2024-04-28Use `target_vendor = "apple"` instead of `target_os = "..."`Mads Marquart-4/+11
2024-04-26PathBuf: replace transmuting by accessor functionsRalf Jung-0/+6
2024-04-12Rollup merge of #123857 - devnexen:tcp_listener_update_backlog, r=ChrisDentonMatthias Krüger-0/+4
std::net: TcpListener shrinks the backlog argument to 32 for Haiku.
2024-04-12std::net: TcpListener shrinks the backlog argument to 32 for Haiku.David Carlier-0/+4