about summary refs log tree commit diff
path: root/library/std/src/sys
AgeCommit message (Collapse)AuthorLines
2024-04-27Rollup merge of #124387 - workingjubilee:use-raw-pointers-in-thread-locals, ↵Matthias Krüger-9/+12
r=joboet thread_local: be excruciatingly explicit in dtor code Use raw pointers to accomplish internal mutability, and clearly split references where applicable. This reduces the likelihood that any of these parts are misunderstood, either by humans or the compiler's optimizations. Fixes #124317 r? ``@joboet``
2024-04-26thread_local: refine LazyKeyInner::take safety docJubilee-1/+1
Co-authored-by: joboet <jonasboettiger@icloud.com>
2024-04-26Rollup merge of #124410 - RalfJung:path-buf-transmute, r=NilstriebJacob Pratt-0/+12
PathBuf: replace transmuting by accessor functions The existing `repr(transparent)` was anyway insufficient as `OsString` was not `repr(transparent)`. And furthermore, on Windows it was blatantly wrong as `OsString` wraps `Wtf8Buf` which is a `repr(Rust)` type with 2 fields: https://github.com/rust-lang/rust/blob/51a7396ad3d78d9326ee1537b9ff29ab3919556f/library/std/src/sys_common/wtf8.rs#L131-L146 So let's just be honest about what happens and add accessor methods that make this abstraction-breaking act of PathBuf visible on the APIs that it pierces through. Fixes https://github.com/rust-lang/rust/issues/124409
2024-04-26Auto merge of #123909 - dtolnay:utf8chunks, r=joboetbors-4/+2
Stabilize `Utf8Chunks` Pending FCP in https://github.com/rust-lang/rust/issues/99543. This PR includes the proposed modification in https://github.com/rust-lang/libs-team/issues/190 as agreed in https://github.com/rust-lang/rust/issues/99543#issuecomment-2050406568.
2024-04-26PathBuf: replace transmuting by accessor functionsRalf Jung-0/+12
2024-04-25thread_local: split refs to fields of KeyJubilee Young-3/+4
2024-04-25thread_local: use less &mut T in LazyKeyInner::takeJubilee Young-6/+8
Instead, use raw pointers to accomplish internal mutability throughout.
2024-04-24Stabilize Utf8ChunksDavid Tolnay-4/+2
2024-04-24Rollup merge of #124282 - RalfJung:fill_utf16_buf, r=ChrisDentonLeón Orell Valerian Liehr-5/+14
windows fill_utf16_buf: explain the expected return value The comment just says "return what the syscall returns", but that doesn't work for all syscalls as the Windows API is not consistent in how buffer size is negotiated. For instance, GetUserProfileDirectoryW works a bit differently, and so home_dir_crt has to translate this to the usual protocol itself. So it's worth describing that protocol. r? ``@ChrisDenton``
2024-04-24Rollup merge of #124281 - RalfJung:win-tls, r=joboetLeón Orell Valerian Liehr-4/+22
fix weak memory bug in TLS on Windows We need to store the `key` *after* we register the dtor. Now I hope there isn't also some other reason why we have to actually register the dtor last... `@joboet` is there a reason you picked this particular order in https://github.com/rust-lang/rust/pull/102655? Fixes https://github.com/rust-lang/rust/issues/123583
2024-04-23fix weak memory bug in TLS on WindowsRalf Jung-4/+22
2024-04-23windows fill_utf16_buf: explain the expected return valueRalf Jung-5/+14
2024-04-21Rollup merge of #124089 - ↵Guillaume Gomez-38/+66
simlay:fix-preadv64-and-pwritev64-link-for-watchos-and-visionos, r=workingjubilee Fix watchOS and visionOS for pread64 and pwrite64 calls In #122880, links to `preadv64` and `pwritev64` were added for `watchOS` however the underlying [`weak!` macro did not include `target_os = "watchos"`](https://github.com/rust-lang/rust/blob/c45dee5efd0c042e9d1e24559ebd0d6424d8aa70/library/std/src/sys/pal/unix/weak.rs#L30-L74). This resulted in an `xcodebuild` error when targeting `watchOS`: ``` Undefined symbols for architecture arm64: "_preadv64", referenced from: __rust_extern_with_linkage_preadv64 in libliveview_native_core.a[274](std-324fdd8d31e8eaa2.std.e18cf7e8d0336778-cgu.08.rcgu.o) "_pwritev64", referenced from: __rust_extern_with_linkage_pwritev64 in libliveview_native_core.a[274](std-324fdd8d31e8eaa2.std.e18cf7e8d0336778-cgu.08.rcgu.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` So I added them. I also went ahead and added the same for visionOS because it's bound to create the same issue.
2024-04-21Fix watchOS and visionOS for pread64 and pwrite64 callsSebastian Imlay-38/+66
* Refactor apple OSs to use pwritev and preadv rather pwritev64 and preadv64 * Updated the comments for preadv and pwritev
2024-04-20Rollup merge of #123967 - RalfJung:static_mut_refs, r=Nilstrieb许杰友 Jieyou Xu (Joe)-3/+2
static_mut_refs: use raw pointers to remove the remaining FIXME Using `SyncUnsafeCell` would not make a lot of sense IMO.
2024-04-18Rollup merge of #124019 - ChrisDenton:futex-raw-dylib, r=joboetJubilee-1/+13
Use raw-dylib for Windows synchronization functions Fixes #123999 by using the raw-dylib feature to specify the DLL to load the Windows futex functions from (e.g. [`WaitOnAddress`](https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitonaddress)). This avoids reliance on the import library causing that issue. With apologies to ``@bjorn3,`` as it's currently necessary to revert this for cranelift.
2024-04-18Auto merge of #123144 - dpaoliello:arm64eclib, ↵bors-21/+22
r=GuillaumeGomez,ChrisDenton,wesleywiser Add support for Arm64EC to the Standard Library Adds the final pieces so that the standard library can be built for arm64ec-pc-windows-msvc (initially added in #119199) * Bumps `windows-sys` to 0.56.0, which adds support for Arm64EC. * Correctly set the `isEC` parameter for LLVM's `writeArchive` function. * Add `#![feature(asm_experimental_arch)]` to library crates where Arm64EC inline assembly is used, as it is currently unstable.
2024-04-16Rollup merge of #123811 - joboet:queue_em_up, r=ChrisDentonGuillaume Gomez-387/+58
Use queue-based `RwLock` on more platforms This switches over Windows 7, SGX and Xous to the queue-based `RwLock` implementation added in #110211, thereby fixing #121949 for Windows 7 and partially resolving #114581 on SGX. TEEOS can't currently be switched because it doesn't have a good thread parking implementation. CC `@roblabla` `@raoulstrackx` `@xobs` Could you help me test this, please? r? `@ChrisDenton` the Windows stuff should be familiar to you
2024-04-16Use raw-dylib for Windows futex APIsChris Denton-1/+13
This is a workaround for older mingw `synchronization` import library not working on at least some system.
2024-04-16std: fix lint on SGXjoboet-2/+5
2024-04-16Rollup merge of #123721 - madsmtm:fix-visionos, r=davidtwcoGuillaume Gomez-12/+1
Various visionOS fixes A few small mistakes was introduced in https://github.com/rust-lang/rust/pull/121419, probably after the rename from `xros` to `visionos`. See the commits for details. CC `@agg23` Since you reviewed https://github.com/rust-lang/rust/pull/121419 r? davidtwco
2024-04-15Add support for Arm64EC to the Standard LibraryDaniel Paoliello-21/+22
2024-04-15Rollup merge of #123970 - risc0:erik/zkvm-fix-os-str, r=joboetMichael Goulet-2/+4
zkvm: fix references to `os_str` module The `os_str` module has been moved to `sys`. This change fixes build issues by changing `use` to point to `crate::sys::os_str`.
2024-04-15static_mut_refs: use raw pointers to remove the remaining FIXMERalf Jung-3/+2
2024-04-15zkvm: fix references to `os_str` moduleErik Kaneda-2/+4
The `os_str` module has been moved to `sys`.
2024-04-15Auto merge of #123937 - RalfJung:miri-link-section, r=oli-obkbors-0/+1
Miri on Windows: run .CRT$XLB linker section on thread-end Hopefully fixes https://github.com/rust-lang/rust/issues/123583 First commit is originally by `@bjorn3` r? `@oli-obk` Cc `@ChrisDenton`
2024-04-15Auto merge of #123928 - tbu-:pr_statx_enosys, r=workingjubileebors-8/+5
`statx` probe: `ENOSYS` might come from a faulty FUSE driver Do the availability check regardless of the error returned from `statx`. CC https://github.com/rust-lang/rust/pull/122079#discussion_r1564761281
2024-04-14Miri: run .CRT$XLB linker section on thread-endRalf Jung-0/+1
2024-04-14`statx` probe: `ENOSYS` might come from a faulty FUSE driverTobias Bucher-8/+5
Do the availability check regardless of the error returned from `statx`. CC https://github.com/rust-lang/rust/pull/122079#discussion_r1564761281
2024-04-14Rollup merge of #123879 - beetrees:missing-unsafe, r=Mark-SimulacrumMatthias Krüger-4/+4
Add missing `unsafe` to some internal `std` functions Adds `unsafe` to a few internal functions that have safety requirements but were previously not marked as `unsafe`. Specifically: - `std::sys::pal::unix::thread::min_stack_size` needs to be `unsafe` as `__pthread_get_minstack` might dereference the passed pointer. All callers currently pass a valid initialised `libc::pthread_attr_t`. - `std::thread::Thread::new` (and `new_inner`) need to be `unsafe` as it requires the passed thread name to be valid UTF-8, otherwise `Thread::name` will trigger undefined behaviour. I've taken the opportunity to split out the unnamed thread case into a separate `new_unnamed` function to make the safety requirement clearer. All callers meet the safety requirement now that #123505 has been merged.
2024-04-13Add missing `unsafe` to internal `std::thread::Thread` creation functionsbeetrees-1/+1
2024-04-13Add missing `unsafe` to internal function ↵beetrees-3/+3
`std::sys::pal::unix::thread::min_stack_size`
2024-04-12Rollup merge of #123867 - eduardosm:unsafe-fns, r=ChrisDentonMatthias Krüger-12/+14
Add `unsafe` to two functions with safety invariants
2024-04-12Add `unsafe` to two functions with safety invariantsEduardo Sánchez Muñoz-12/+14
2024-04-12zkvm: remove cmathMarijan Petričević-2/+0
- Remove cmath from zkvm module since cmath was moved to sys and is shared by all platforms (see #120109)
2024-04-11std: use queue-based `RwLock` on Windows 7joboet-50/+6
2024-04-11std: use queue-based `RwLock` on Xousjoboet-74/+0
2024-04-11std: use queue-based `RwLock` on SGXjoboet-261/+47
2024-04-11Factor some common `io::Error` constantsBenoît du Garreau-86/+26
2024-04-10Rollup merge of #123534 - ChrisDenton:name, r=workingjubileeGuillaume Gomez-6/+123
Windows: set main thread name without re-encoding As a minor optimization, we can skip the runtime UTF-8 to UTF-16 conversion.
2024-04-10visionOS: Fix unused import warningMads Marquart-12/+1
The import is used once in this file, inside `posix_spawn`, so let's move the import into that function instead, to reduce the number of `cfg`s that need to be kept in sync.
2024-04-10Auto merge of #122812 - dtolnay:mode, r=workingjubileebors-5/+186
Show mode_t as octal in std::fs Debug impls Example: ```rust fn main() { println!("{:?}", std::fs::metadata("Cargo.toml").unwrap().permissions()); } ``` - Before: `Permissions(FilePermissions { mode: 33204 })` - ~~After: `Permissions(FilePermissions { mode: 0o100664 })`~~ - After: `Permissions(FilePermissions { mode: 0o100664 (-rw-rw-r--) })` ~~I thought about using the format from `ls -l` (`-rw-rw-r--`, `drwxrwxr-x`) but I am not sure how transferable the meaning of the higher bits between different unix systems, and anyway starting the value with a leading negative-sign seems objectionable.~~
2024-04-10Rollup merge of #123633 - bjorn3:unsupported_command_data, r=jhprattMatthias Krüger-31/+119
Store all args in the unsupported Command implementation This allows printing them in the Debug impl as well as getting them again using the get_args() method. This allows programs that would normally spawn another process to more easily show which program they would have spawned if not for the fact that the target doesn't support spawning child processes without requiring intrusive changes to keep the args. For example rustc compiled to wasi will show the full linker invocation that would have been done.
2024-04-09Show mode_t as octal in std::fs Debug implsDavid Tolnay-5/+186
2024-04-09Add comment on UTF-16 surrogatesChris Denton-0/+2
2024-04-09Windows: set main thread name without reencodingChris Denton-4/+8
2024-04-09Add const UTF-8 to UTF-16 conversion macrosChris Denton-2/+113
`wide_str!` creates a null terminated UTF-16 string whereas `utf16!` just creates a UTF-16 string without adding a null.
2024-04-09Auto merge of #123683 - pietroalbini:pa-cve-2024-24576-nightly, r=pietroalbinibors-12/+93
Backport fix of CVE-2024-24576 See https://blog.rust-lang.org/2024/04/09/cve-2024-24576.html r? `@ghost`
2024-04-09Auto merge of #123485 - madsmtm:use-libc-copyfile, r=joboetbors-39/+10
macOS: Use `libc` definitions for copyfile `COPYFILE_ALL` is not yet exposed in `libc`, but the rest of what we need is, so use those definitions instead of manually defining them. The definitions were added in https://github.com/rust-lang/libc/pull/2667 and https://github.com/rust-lang/libc/pull/3346.
2024-04-09Fix dead code warningbjorn3-0/+1