about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2024-07-12Rollup merge of #126827 - the8472:pidfd-spawn, r=workingjubileeMatthias Krüger-6/+131
Use pidfd_spawn for faster process spawning when a PidFd is requested glibc 2.39 added `pidfd_spawnp` and `pidfd_getpid` which makes it possible to get pidfds while staying on the CLONE_VFORK path. verified that vfork gets used with strace: ``` $ strace -ff -e pidfd_open,clone3,openat,execve,waitid,close ./x test std --no-doc -- pidfd [...] [pid 2820532] clone3({flags=CLONE_VM|CLONE_PIDFD|CLONE_VFORK|CLONE_CLEAR_SIGHAND, pidfd=0x7b7f885fec6c, exit_signal=SIGCHLD, stack=0x7b7f88aff000, stack_size=0x9000}strace: Process 2820533 attached <unfinished ...> [pid 2820533] execve("/home/the8472/bin/sleep", ["sleep", "1000"], 0x7ffdd0e268d8 /* 107 vars */) = -1 ENOENT (No such file or directory) [pid 2820533] execve("/home/the8472/.cargo/bin/sleep", ["sleep", "1000"], 0x7ffdd0e268d8 /* 107 vars */) = -1 ENOENT (No such file or directory) [pid 2820533] execve("/usr/local/bin/sleep", ["sleep", "1000"], 0x7ffdd0e268d8 /* 107 vars */) = -1 ENOENT (No such file or directory) [pid 2820533] execve("/usr/bin/sleep", ["sleep", "1000"], 0x7ffdd0e268d8 /* 107 vars */ <unfinished ...> [pid 2820532] <... clone3 resumed> => {pidfd=[3]}, 88) = 2820533 [pid 2820533] <... execve resumed>) = 0 [pid 2820532] openat(AT_FDCWD, "/proc/self/fdinfo/3", O_RDONLY|O_CLOEXEC) = 4 [pid 2820532] close(4) = 0 ``` Tracking issue: #82971
2024-07-11Rollup merge of #127599 - tgross35:lazy_cell_consume-rename, r=workingjubileeMatthias Krüger-2/+2
Rename `lazy_cell_consume` to `lazy_cell_into_inner` Name this something that is less confusable with an atomic consume API for `{Lazy,Once}Lock`.
2024-07-11Rename `lazy_cell_consume` to `lazy_cell_into_inner`Trevor Gross-2/+2
Name this something that is less confusable with an atomic consume API for `{Lazy,Once}Lock`.
2024-07-10Don't mark `DEBUG_EVENT` struct as `repr(packed)`Tobias Bucher-1/+1
That would give it alignment of 1 which is ABI-incompatible with its C definition.
2024-07-09Fixed doc linksAndres Olivares-2/+2
2024-07-09Few changes to doc comments. Added tracking issue number.Andres Olivares-4/+5
2024-07-09Exposing STARTUPINFOW.wShowWindow in CommandExt (show_window function) to ↵Andres Olivares-0/+22
control how a new process should display its window (normal, minimized, maximized, etc)
2024-07-08Rollup merge of #127460 - Borgerr:clarify-drop-comment, r=jhprattMatthias Krüger-0/+5
clarify `sys::unix::fd::FileDesc::drop` comment closes #66876 simply clarifies some resource-relevant things regarding the `close` syscall to reduce the amount of search needed in other parts of the web.
2024-07-07clarify `sys::unix::fd::FileDesc::drop` comment (#66876)Ashton Hunt-0/+5
2024-07-07Rollup merge of #127447 - RalfJung:once_lock_miri, r=joboetMatthias Krüger-6/+13
once_lock: make test not take as long in Miri Allocating 1000 list elements takes a while (`@zachs18` reported >5min), so let's reduce the iteration count when running in Miri. Unfortunately due to this clever `while let i @ 0..LEN =` thing, the count needs to be a constants, and constants cannot be shadowed, so we need to use another trick to hide the `cfg!(miri)` from the docs. (I think this loop condition may be a bit too clever, it took me a bit to decipher. Ideally this would be `while let i = ... && i < LEN`, but that is not stable yet.)
2024-07-07Rollup merge of #127297 - the8472:path-new-hash, r=NilstriebMatthias Krüger-4/+44
Improve std::Path's Hash quality by avoiding prefix collisions This adds a bit rotation to the already existing state so that the same sequence of characters chunked at different offsets into separate path components results in different hashes. The tests are from #127255 Closes #127254
2024-07-07once_lock: make test not take as long in MiriRalf Jung-6/+13
2024-07-05Rollup merge of #123600 - tisonkun:path_with_extension, r=dtolnayMichael Goulet-0/+168
impl PathBuf::add_extension and Path::with_added_extension See the ACP for motivation and discussions - https://github.com/rust-lang/libs-team/issues/368
2024-07-05add unit tests for extra extension featuretison-0/+74
Signed-off-by: tison <wander4096@gmail.com>
2024-07-05update commentstison-4/+1
Signed-off-by: tison <wander4096@gmail.com>
2024-07-05Rollup merge of #127320 - ChrisDenton:win-sys, r=Mark-SimulacrumGuillaume Gomez-851/+162
Update windows-bindgen to 0.58.0 This also switches from the bespoke `std` generated bindings to the normal `sys` ones everyone else uses. This has almost no difference except that the `sys` bindings use the `windows_targets::links!` macro for FFI imports, which we implement manually. This does cause the diff to look much larger than it really is but the bulk of the changes are mostly contained to the generated code.
2024-07-04Add comments to windows_targets.rsChris Denton-0/+9
2024-07-04Update windows-bindgen to 0.58.0Chris Denton-851/+153
2024-07-04Rollup merge of #127195 - biabbas:vxworks_cleanup, r=jhprattJacob Pratt-2/+4
Remove unqualified form import of io::Error in process_vxworks.rs and fallback on remove_dir_impl for vxworks Hi all, This is to address issue #127084. On inspections it was found that io::Error refrences were all of qualified form and there was no need to add a unqualified form import. Also to successfully build rust for vxworks, we need to fallback on the remove_impl_dir implementations. Thank you.
2024-07-04Rollup merge of #126792 - wooden-worm:master, r=Mark-SimulacrumJacob Pratt-10/+16
wasm64 build with target-feature=+simd128,+atomics Fixes https://github.com/rust-lang/rust/issues/126778
2024-07-03impl PathBuf::add_extension and Path::with_added_extensiontison-0/+97
Signed-off-by: tison <wander4096@gmail.com>
2024-07-04stir the hash state a little to avoid prefix collisionsThe 8472-4/+9
2024-07-03Add more test cases for path comparisonsZanie Blue-0/+28
2024-07-03Add test case demonstrating equality of paths "foo/bar" and "foobar"Zanie Blue-0/+7
2024-07-03Rollup merge of #123588 - tgross35:stabilize-assert_unchecked, r=dtolnayJacob Pratt-1/+0
Stabilize `hint::assert_unchecked` Make the following API stable, including const: ```rust // core::hint, std::hint pub const unsafe fn assert_unchecked(p: bool); ``` This PR also reworks some of the documentation and adds an example. Tracking issue: https://github.com/rust-lang/rust/issues/119131 FCP: https://github.com/rust-lang/rust/issues/119131#issuecomment-1906394087. The docs update should resolve the remaining concern.
2024-07-03Fall back on remove dir implementation for vxworksB I Mohammed Abbas-1/+3
2024-07-02Rollup merge of #127230 - hattizai:patch01, r=saethlinMatthias Krüger-3/+3
chore: remove duplicate words remove duplicate words in comments to improve readability.
2024-07-02chore: remove duplicate wordshattizai-3/+3
2024-07-01Rollup merge of #126732 - StackOverflowExcept1on:master, r=m-ou-seGuillaume Gomez-1/+0
Stabilize `PanicInfo::message()` and `PanicMessage` Resolves #66745 This stabilizes the [`PanicInfo::message()`](https://doc.rust-lang.org/nightly/core/panic/struct.PanicInfo.html#method.message) and [`PanicMessage`](https://doc.rust-lang.org/nightly/core/panic/struct.PanicMessage.html). Demonstration of [custom panic handler](https://github.com/StackOverflowExcept1on/panicker): ```rust #![no_std] #![no_main] extern crate libc; #[no_mangle] extern "C" fn main() -> libc::c_int { panic!("I just panic every time"); } #[panic_handler] fn my_panic(panic_info: &core::panic::PanicInfo) -> ! { use arrayvec::ArrayString; use core::fmt::Write; let message = panic_info.message(); let location = panic_info.location().unwrap(); let mut debug_msg = ArrayString::<1024>::new(); let _ = write!(&mut debug_msg, "panicked with '{message}' at '{location}'"); if debug_msg.try_push_str("\0").is_ok() { unsafe { libc::puts(debug_msg.as_ptr() as *const _); } } unsafe { libc::exit(libc::EXIT_FAILURE) } } ``` ``` $ cargo +stage1 run --release panicked with 'I just panic every time' at 'src/main.rs:8:5' ``` - [x] FCP: https://github.com/rust-lang/rust/issues/66745#issuecomment-2198143725 r? libs-api
2024-07-01Remove unqualified import io:: Error for vxworks as all Error references are ↵B I Mohammed Abbas-1/+1
qualified in process_vxworks.rs
2024-06-29Rollup merge of #126953 - joboet:lazy_key, r=jhprattMatthias Krüger-128/+115
std: separate TLS key creation from TLS access Currently, `std` performs an atomic load to get the OS key on every access to `StaticKey` even when the key is already known. This PR thus replaces `StaticKey` with the platform-specific `get` and `set` function and a new `LazyKey` type that acts as a `LazyLock<Key>`, allowing the reuse of the retreived key for multiple accesses. Related to #110897.
2024-06-28std: add safety commentsjoboet-4/+16
2024-06-27Rollup merge of #126980 - Borgerr:fix-extendfromslice-check, r=workingjubileeJacob Pratt-1/+25
set self.is_known_utf8 to false in extend_from_slice try-job: x86_64-msvc closes #126977 Related to #126885, #126333, and [this conversation](<https://github.com/rust-lang/rust/commit/aa46a3368eb017eba41bfab956c7787d46c09935#r143539097>)
2024-06-26Auto merge of #126608 - tgross35:f16-f128-library, r=Mark-Simulacrumbors-90/+1198
Add more constants, functions, and tests for `f16` and `f128` This adds everything that was in some way blocked on const eval, since https://github.com/rust-lang/rust/pull/126429 landed. There is a lot of `cfg(bootstrap)` since that is a fairly recent change. `f128` tests are disabled on everything except x86_64 and Linux aarch64, which are two platforms I know have "good" support for these types - meaning basic math symbols are available and LLVM doesn't hit selection crashes. `f16` tests are enabled on almost everything except for known LLVM crashes. Doctests are only enabled on x86_64. Tracking issue: https://github.com/rust-lang/rust/issues/116909
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-25std: separate TLS key creation from TLS accessjoboet-125/+100
Currently, `std` performs an atomic load to get the OS key on every access to `StaticKey` even when the key is already known. This PR thus replaces `StaticKey` with the platform-specific `get` and `set` function and a new `LazyKey` type that acts as a `LazyLock<Key>`, allowing the reuse of the retreived key for multiple accesses.
2024-06-25`PathBuf::as_mut_vec` removed and verified for UEFI and Windows platforms ↵ash-27/+42
#126333
2024-06-25remove references to `PathBuf::as_mut_vec` in `PathBuf::_set_extension`ash-6/+5
2024-06-25inner truncate methods for UEFI platformsash-3/+13
2024-06-25#126333 remove `PathBuf::as_mut_vec` reference at top of `PathBuf::_push`ash-1/+2
2024-06-25Add tests for `f16` and `f128`Trevor Gross-35/+1029
This suite tests all library functions that are now available for the types. Tests are only run on certain platforms where `f16` and `f128` are known to work (have symbols available and don't crash LLVM).
2024-06-25Add more `f16` and `f128` library functions and constantsTrevor Gross-0/+59
This adds everything that was directly or transitively blocked on const arithmetic for these types, which was recently merged. Since const arithmetic is recent, most of these need to be gated by `bootstrap`. Anything that relies on intrinsics that are still missing is excluded.
2024-06-25Check that we get somewhat sane PIDs when spawning with pidfdsThe 8472-0/+3
2024-06-25more fine-grained feature-detection for pidfd spawningThe 8472-21/+33
we now distinguish between pidfd_spawn support, pidfd-via-fork/exec and not-supported
2024-06-25document safety properties of the internal Process::new constructorThe 8472-0/+6
2024-06-25use pidfd_spawn for faster process creation when pidfds are requestedThe 8472-6/+106
2024-06-25document the cvt methodsThe 8472-0/+4
2024-06-24Rollup merge of #125082 - kpreid:const-uninit, r=dtolnayMichael Goulet-6/+4
Remove `MaybeUninit::uninit_array()` and replace it with inline const blocks. \[This PR originally contained the changes in #125995 too. See edit history for the original PR description.] The documentation of `MaybeUninit::uninit_array()` says: > Note: in a future Rust version this method may become unnecessary when Rust allows [inline const expressions](https://github.com/rust-lang/rust/issues/76001). The example below could then use `let mut buf = [const { MaybeUninit::<u8>::uninit() }; 32];`. The PR adding it also said: <https://github.com/rust-lang/rust/pull/65580#issuecomment-544200681> > if it’s stabilized soon enough maybe it’s not worth having a standard library method that will be replaceable with `let buffer = [MaybeUninit::<T>::uninit(); $N];` That time has come to pass — inline const expressions are stable — so `MaybeUninit::uninit_array()` is now unnecessary. The only remaining question is whether it is an important enough *convenience* to keep it around. I believe it is net good to remove this function, on the principle that it is better to compose two orthogonal features (`MaybeUninit` and array construction) than to have a specific function for the specific combination, now that that is possible.
2024-06-24Replace `MaybeUninit::uninit_array()` with array repeat expression.Kevin Reid-6/+4
This is possible now that inline const blocks are stable; the idea was even mentioned as an alternative when `uninit_array()` was added: <https://github.com/rust-lang/rust/pull/65580#issuecomment-544200681> > if it’s stabilized soon enough maybe it’s not worth having a > standard library method that will be replaceable with > `let buffer = [MaybeUninit::<T>::uninit(); $N];` Const array repetition and inline const blocks are now stable (in the next release), so that circumstance has come to pass, and we no longer have reason to want `uninit_array()` other than convenience. Therefore, let’s evaluate the inconvenience by not using `uninit_array()` in the standard library, before potentially deleting it entirely.