about summary refs log tree commit diff
path: root/library/std/src/sys
AgeCommit message (Collapse)AuthorLines
2025-05-17Auto merge of #138087 - tgross35:core-float-math, r=Amanieubors-4/+0
Initial implementation of `core_float_math` Since [1], `compiler-builtins` makes a certain set of math symbols weakly available on all platforms. This means we can begin exposing some of the related functions in `core`, so begin this process here. It is not possible to provide inherent methods in both `core` and `std` while giving them different stability gates, so standalone functions are added instead. This provides a way to experiment with the functionality while unstable; once it is time to stabilize, they can be converted to inherent. For `f16` and `f128`, everything is unstable so we can move the inherent methods. The following are included to start: * floor * ceil * round * round_ties_even * trunc * fract * mul_add * div_euclid * rem_euclid * powi * sqrt * abs_sub * cbrt These mirror the set of functions that we have in `compiler-builtins` since [1], with the exception of `powi` that has been there longer. Details for each of the changes is in the commit messages. Tracking issue: https://github.com/rust-lang/rust/issues/137578 [1]: https://github.com/rust-lang/compiler-builtins/pull/763 try-job: aarch64-gnu tru-job: armhf-gnu try-job: i686-msvc-1 try-job: test-various try-job: x86_64-mingw-1 try-job: x86_64-mingw-2
2025-05-17Rollup merge of #139103 - joboet:abort_dedup, r=tgross35Matthias Krüger-29/+17
deduplicate abort implementations Currently, the code for process aborts is duplicated across `panic_abort` and `std`. This PR uses `#[rustc_std_internal_symbol]` to make the `std` implementation available to `panic_abort` via the linker, thereby deduplicating the code.
2025-05-16Rollup merge of #141013 - federico-terzi:feat/command_startupinfo_windows, ↵Matthias Krüger-0/+36
r=joboet Implement methods to set STARTUPINFO flags for Command API on Windows Implements https://github.com/rust-lang/rust/issues/141010
2025-05-15improve internal fastfail explainerjoboet-3/+2
2025-05-15deduplicate abort implementationsjoboet-29/+18
Currently, the code for process aborts is duplicated across `panic_abort` and `std`. This PR uses `#[rustc_std_internal_symbol]` to make the `std` implementation available to `panic_abort` via the linker, thereby deduplicating the code.
2025-05-14wire up startupinfo methodsFederico Terzi-0/+36
2025-05-14Fix settimes for vxworksB I Mohammed Abbas-2/+1
2025-05-14Fix set_name for vxworks. Length of name should be truncated to ↵B I Mohammed Abbas-10/+2
VX_TASK_RENAME_LENGTH-1
2025-05-13Initial implementation of `core_float_math`Trevor Gross-4/+0
Since [1], `compiler-builtins` makes a certain set of math symbols weakly available on all platforms. This means we can begin exposing some of the related functions in `core`, so begin this process here. It is not possible to provide inherent methods in both `core` and `std` while giving them different stability gates, so standalone functions are added instead. This provides a way to experiment with the functionality while unstable; once it is time to stabilize, they can be converted to inherent. For `f16` and `f128`, everything is unstable so we can move the inherent methods. The following are included to start: * floor * ceil * round * round_ties_even * trunc * fract * mul_add * div_euclid * rem_euclid * powi * sqrt * abs_sub * cbrt These mirror the set of functions that we have in `compiler-builtins` since [1]. Tracking issue: https://github.com/rust-lang/rust/issues/137578 [1]: https://github.com/rust-lang/compiler-builtins/pull/763
2025-05-07Fix regression from #140393 for espidf / horizon / nuttx / vitaivmarkov-0/+1
2025-05-07Rollup merge of #140656 - joboet:fuchsia_pal, r=workingjubileeJacob Pratt-282/+122
collect all Fuchsia bindings into the `fuchsia` module The Fuchsia bindings are currently spread out across multiple modules in `sys/pal/unix` leading to unnecessary duplication. This PR moves all of these definitions into `sys::pal::unix::fuchsia` and additionally: * deduplicates the definitions * makes the error names consistent * marks `zx_thread_self` and `zx_clock_get_monotonic` as safe extern functions * removes unused items (there's no need to maintain these bindings if we're not going to use them) * removes the documentation for the definitions (contributors should always consult the platform documentation, duplicating that here is just an extra maintenance burden) `@rustbot` ping fuchsia
2025-05-06Rollup merge of #140393 - joboet:sys_common_process, r=thomccStuart Cook-88/+242
std: get rid of `sys_common::process` 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. Something went wrong with a force push, so I can't reopen #139020. This is unchanged from that PR, apart from a rebase. r? ```@thomcc```
2025-05-06Rollup merge of #139773 - thaliaarchi:vec-into-iter-last, r=workingjubileeStuart Cook-2/+2
Implement `Iterator::last` for `vec::IntoIter` Avoid iterating everything when we have random access to the last element.
2025-05-05collect all Fuchsia bindings into the `fuchsia` modulejoboet-282/+122
The Fuchsia bindings are currently spread out across multiple modules in `sys/pal/unix` leading to unnecessary duplication. This PR moves all of these definitions into `sys::pal::unix::fuchsia` and additionally: * deduplicates the definitions * makes the error names consistent * marks some extern functions as safe * removes unused items (there's no need to maintain these bindings if we're not going to use them) * removes the documentation for the definitions (contributors should always consult the platform documentation, duplicating that here is just an extra maintenance burden)
2025-05-03Rollup merge of #139343 - cberner:filelock_wouldblock, r=workingjubileeMatthias Krüger-41/+58
Change signature of File::try_lock and File::try_lock_shared These methods now return Result<(), TryLockError> instead of Result<bool, Error> to make their use less errorprone These methods are unstable under the "file_lock" feature. The related tracking issue is https://github.com/rust-lang/rust/pull/130999 and this PR changes the signatures as discussed by libs-api: https://github.com/rust-lang/rust/issues/130994#issuecomment-2770838848
2025-05-02Implement Iterator::last for vec::IntoIterThalia Archibald-2/+2
2025-05-02Rollup merge of #140159 - thaliaarchi:pathbuf-extension, r=workingjubileeStuart Cook-18/+37
Avoid redundant WTF-8 checks in `PathBuf` Eliminate checks for WTF-8 boundaries in `PathBuf::set_extension` and `add_extension`, where joining WTF-8 surrogate halves is impossible. Don't convert the `str` to `OsStr`, because `OsString::push` specializes to skip the joining when given strings. To assist in this, mark the internal methods `OsString::truncate` and `extend_from_slice` as `unsafe` to communicate their safety invariants better than with module privacy. Similar to #137777. cc `@joboet` `@ChrisDenton`
2025-05-02Rollup merge of #139847 - thaliaarchi:args/delegate-iter, r=workingjubileeStuart Cook-20/+132
Delegate to inner `vec::IntoIter` from `env::ArgsOs` Delegate from `std::env::ArgsOs` to the methods of the inner platform-specific iterators, when it would be more efficient than just using the default methods of its own impl. Most platforms use `vec::IntoIter` as the inner type, so prioritize delegating to the methods it provides. `std::env::Args` is implemented atop `std::env::ArgsOs` and performs UTF-8 validation with a panic for invalid data. This is a visible effect which users certainly rely on, so we can't skip any arguments. Any further iterator methods would skip some elements, so no change is needed for that type. Add `#[inline]` for any methods which simply wrap the inner iterator.
2025-05-02Rollup merge of #139206 - joboet:unique_thread_errno, r=ibraheemdevStuart Cook-24/+21
std: use the address of `errno` to identify threads in `unique_thread_exit` Getting the address of `errno` should be just as cheap as `pthread_self()` and avoids having to use the expensive `Mutex` logic because it always results in a pointer.
2025-05-01Change signature of File::try_lock and File::try_lock_sharedChristopher Berner-41/+58
These methods now return Result<(), TryLockError> instead of Result<bool, Error> to make their use less errorprone
2025-05-01Delegate to inner `vec::IntoIter` from `env::ArgsOs`Thalia Archibald-20/+132
Delegate from `std::env::ArgsOs` to the methods of the inner platform-specific iterators, when it would be more efficient than just using the default methods of its own impl. Most platforms use `vec::IntoIter` as the inner type, so prioritize delegating to the methods it provides. `std::env::Args` is implemented atop `std::env::ArgsOs` and performs UTF-8 validation with a panic for invalid data. This is a visible effect which users certainly rely on, so we can't skip any arguments. Any further iterator methods would skip some elements, so no change is needed for that type. Add `#[inline]` for any methods which simply wrap the inner iterator.
2025-04-30Make internal `OsString::truncate` and `extend_from_slice` unsafeThalia Archibald-18/+37
Communicate the safety invariants of these methods with `unsafe fn` rather than privacy.
2025-04-28std: get rid of `sys_common::process`joboet-88/+242
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-04-28Auto merge of #123239 - Urgau:dangerous_implicit_autorefs, ↵bors-1/+1
r=jdonszelmann,traviscross Implement a lint for implicit autoref of raw pointer dereference - take 2 *[t-lang nomination comment](https://github.com/rust-lang/rust/pull/123239#issuecomment-2727551097)* This PR aims at implementing a lint for implicit autoref of raw pointer dereference, it is based on #103735 with suggestion and improvements from https://github.com/rust-lang/rust/pull/103735#issuecomment-1370420305. The goal is to catch cases like this, where the user probably doesn't realise it just created a reference. ```rust pub struct Test { data: [u8], } pub fn test_len(t: *const Test) -> usize { unsafe { (*t).data.len() } // this calls <[T]>::len(&self) } ``` Since #103735 already went 2 times through T-lang, where they T-lang ended-up asking for a more restricted version (which is what this PR does), I would prefer this PR to be reviewed first before re-nominating it for T-lang. ---- Compared to the PR it is as based on, this PR adds 3 restrictions on the outer most expression, which must either be: 1. A deref followed by any non-deref place projection (that intermediate deref will typically be auto-inserted) 2. A method call annotated with `#[rustc_no_implicit_refs]`. 3. A deref followed by a `addr_of!` or `addr_of_mut!`. See bottom of post for details. There are several points that are not 100% clear to me when implementing the modifications: - ~~"4. Any number of automatically inserted deref/derefmut calls." I as never able to trigger this. Am I missing something?~~ Fixed - Are "index" and "field" enough? ---- cc `@JakobDegen` `@WaffleLapkin` r? `@RalfJung` try-job: dist-various-1 try-job: dist-various-2
2025-04-27Fix SGX library code implicit auto-refUrgau-1/+1
2025-04-27use generic Atomic type where possibleChristopher Durham-194/+202
in core/alloc/std only for now, and ignoring test files Co-authored-by: Pavel Grigorenko <GrigorenkoPV@ya.ru>
2025-04-25Auto merge of #140282 - matthiaskrgr:rollup-g6ze4jj, r=matthiaskrgrbors-1212/+956
Rollup of 8 pull requests Successful merges: - #137653 (Deprecate the unstable `concat_idents!`) - #138957 (Update the index of Option to make the summary more comprehensive) - #140006 (ensure compiler existance of tools on the dist step) - #140143 (Move `sys::pal::os::Env` into `sys::env`) - #140202 (Make #![feature(let_chains)] bootstrap conditional in compiler/) - #140236 (norm nested aliases before evaluating the parent goal) - #140257 (Some drive-by housecleaning in `rustc_borrowck`) - #140278 (Don't use item name to look up associated item from trait item) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-25Auto merge of #140273 - matthiaskrgr:rollup-rxmuvkg, r=matthiaskrgrbors-1/+4
Rollup of 8 pull requests Successful merges: - #137096 (Stabilize flags for doctest cross compilation) - #140148 (CI: use aws codebuild for job dist-arm-linux) - #140187 ([AIX] Handle AIX dynamic library extensions within c-link-to-rust-dylib run-make test) - #140196 (Improved diagnostics for non-primitive cast on non-primitive types (`Arc`, `Option`)) - #140210 (Work around cygwin issue on condvar timeout) - #140213 (mention about `x.py setup` in `INSTALL.md`) - #140229 (`DelimArgs` tweaks) - #140248 (Fix impl block items indent) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-25Rollup merge of #140143 - thaliaarchi:move-env-pal, r=joboetMatthias Krüger-1212/+956
Move `sys::pal::os::Env` into `sys::env` Although `Env` (as `Vars`), `Args`, path functions, and OS constants are publicly exposed via `std::env`, their implementations are each self-contained. Keep them separate in `std::sys` and make a new module, `sys::env`, for `Env`. Also fix `unsafe_op_in_unsafe_fn` for Unix and update the `!DynSend` and `!DynSync` impls which had grown out of sync with the platforms (see #48005 for discussion on that). r? joboet Tracked in #117276.
2025-04-25Rollup merge of #140210 - Berrysoft:cygwin-timedwait, r=joboetMatthias Krüger-1/+4
Work around cygwin issue on condvar timeout This workaround *just works*... Actually I don't quite understand why does it work in such way. With a simple test on Cygwin, it seems that the maximum value of `tv_sec` could be 12899331056917, while the maximum value of `tv_nsec` should be a value floating around 464600000. A larger `timespec` could block the syscall forever. r? `@joboet`
2025-04-24Rollup merge of #140141 - thaliaarchi:env-consts/zkvm, r=joboetMatthias Krüger-9/+11
Move zkVM constants into `sys::env_consts` I missed this in #139868. Its `mod` declaration was removed, but the contents were not moved. r? joboet
2025-04-24Rollup merge of #139450 - NobodyXu:new-api/make-fifo, r=tgross35Matthias Krüger-1/+7
Impl new API `std::os::unix::fs::mkfifo` under feature `unix_fifo` Tracking issue #139324
2025-04-24Work around cygwin issue on timeout王宇逸-1/+4
2025-04-23Impl new API `std::os::unix::fs::mkfifo` under feature `unix_fifo`Jiahao XU-1/+7
Tracking issue #139324 Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2025-04-22Rollup merge of #139617 - Berrysoft:cygwin-posix-spawn, r=joboetChris Denton-2/+6
Use posix_spawn on cygwin r? ``@joboet`` Depends on: - [x] https://github.com/rust-lang/libc/pull/4387 - [x] https://github.com/rust-lang/rust/pull/140081
2025-04-21Unify owned `Env` types between platformsThalia Archibald-348/+98
Also, update the same pattern of reuse in `sys::args` to match.
2025-04-21Deduplicate unsupported env itemsThalia Archibald-42/+8
2025-04-21Fix `unsafe_op_in_unsafe_fn` for Unix envThalia Archibald-6/+4
2025-04-21Move zkVM constants into `sys::env_consts`Thalia Archibald-9/+11
I missed this in #139868. Its `mod` declaration was removed, but the contents were not moved.
2025-04-21Move `sys::pal::os::Env` into `sys::env`Thalia Archibald-1192/+1222
Although `Env` (as `Vars`), `Args`, path functions, and OS constants are publicly exposed via `std::env`, their implementations are each self-contained. Keep them separate in `std::sys` and make a new module, `sys::env`, for `Env`.
2025-04-21Rollup merge of #139795 - jethrogb:jb/sgx-linkage-comments, r=joboetChris Denton-6/+14
Clarify why SGX code specifies linkage/symbol names for certain statics Specifying linkage/symbol name is solely to ensure a single instance between the `std` crate and its unit tests. Also update the symbol names as items have moved around a bit. The actual name isn't that important, it just needs to be unique. But for debugging it can be useful for it to point to the right place.
2025-04-21Rollup merge of #139711 - thaliaarchi:hermit-args, r=jhprattChris Denton-40/+9
Hermit: Unify `std::env::args` with Unix The only differences between these implementations of `std::env::args` are that Unix uses relaxed ordering, but Hermit uses acquire/release, and Unix truncates `argv` at the first null pointer, but Hermit doesn't. Since Hermit aims for Unix compatibility, unify it with Unix. The atomic orderings were established in https://github.com/rust-lang/rust/pull/74006 (cc `@euclio)` for Unix and https://github.com/rust-lang/rust/pull/100579 (cc `@joboet)` for Hermit and, before those, they used mutexes and non-atomic statics. I think the difference in orderings is simply from them being changed at different times. The commented explanation for using acquire/release for Hermit is “to broadcast writes by the OS”. I'm not experienced enough with atomics to accurately judge, but I think acquire/release is stronger than needed. Either way, they should match. Truncating at the first null pointer seems desirable, though I don't know whether it is necessary in practice on Hermit. cc `@mkroening` `@stlankes` for Hermit
2025-04-20Auto merge of #140043 - ChrisDenton:rollup-vwf0s9j, r=ChrisDentonbors-186/+191
Rollup of 8 pull requests Successful merges: - #138934 (support config extensions) - #139091 (Rewrite on_unimplemented format string parser.) - #139753 (Make `#[naked]` an unsafe attribute) - #139762 (Don't assemble non-env/bound candidates if projection is rigid) - #139834 (Don't canonicalize crate paths) - #139868 (Move `pal::env` to `std::sys::env_consts`) - #139978 (Add citool command for generating a test dashboard) - #139995 (Clean UI tests 4 of n) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-19Rollup merge of #139868 - thaliaarchi:move-env-consts-pal, r=joboetChris Denton-186/+191
Move `pal::env` to `std::sys::env_consts` Combine the `std::env::consts` platform implementations as a single file. Use the Unix file as the base, since it has 28 entries, and fold the 8 singleton platforms into it. The Unix file was roughly grouped into Linux, Apple, BSD, and everything else, roughly in alphabetical order. Alphabetically order them to make it easier to maintain and discard the Unix-specific groups to generalize it to all platforms. I'd prefer to have no fallback implementation, as I consider it a bug; however TEEOS, Trusty, and Xous have no definitions here. Since they otherwise have `pal` abstractions, that indicates that there are several platforms without `pal` abstractions which are also missing here. To support unsupported, create a little macro to handle the fallback case and not introduce ordering between the `cfg`s like `cfg_if!`. I've named the module `std::sys::env_consts`, because they are used in `std::env::consts` and I intend to use the name `std::sys::env` for the combination of `Args` and `Vars`. cc `@joboet` `@ChrisDenton` Tracked in #117276.
2025-04-18Handle unsupported fallbackThalia Archibald-1/+28
2025-04-18Combine env consts into std::sys::env_constsThalia Archibald-94/+70
2025-04-18Sort Unix env constants alphabetically by target_osThalia Archibald-98/+100
They were roughly grouped into Linux, Apple, BSD, and everything else, roughly in alphabetical order. Alphabetically order them to make it easier to maintain and discard the Unix-specific groups to generalize it to all platforms.
2025-04-18std: Use fstatat() on illumosPatrick Mooney-3/+6
2025-04-17Rollup merge of #139667 - 1c3t3a:remove-no-sanitize, r=m-ou-seMatthias Krüger-40/+0
cfi: Remove #[no_sanitize(cfi)] for extern weak functions Previously (https://github.com/rust-lang/rust/pull/115200, https://github.com/rust-lang/rust/pull/138002), we added `#[no_sanitize(cfi)]` to all code paths that call to a weakly linked function. In https://github.com/rust-lang/rust/pull/138349 we fixed the root cause for this issue, which means we can now remove the corresponding attributes. r? `@rcvalle`
2025-04-15Rollup merge of #139822 - 0x79de:fix-eopnotsupp-mapping, r=dtolnayStuart Cook-0/+1
Fix: Map EOPNOTSUPP to ErrorKind::Unsupported on Unix This change maps the EOPNOTSUPP errno value (95) to std::io::ErrorKind::Unsupported in the decode_error_kind function for Unix platforms. Previously, it was incorrectly mapped to ErrorKind::Uncategorized. Fixes #139803