about summary refs log tree commit diff
path: root/library/std/src/sys/pal/hermit
AgeCommit message (Collapse)AuthorLines
2024-12-17Use field init shorthand where possibleJosh Triplett-3/+3
Field init shorthand allows writing initializers like `tcx: tcx` as `tcx`. The compiler already uses it extensively. Fix the last few places where it isn't yet used.
2024-12-13Fix building `std` for Hermit after `c_char` changeMartin Kröning-6/+6
2024-11-26std: update internal uses of `io::const_error!`joboet-13/+11
2024-11-14Rollup merge of #132790 - aDotInTheVoid:ioslice-asslice-rides-again, r=cuviperJubilee-1/+6
Add as_slice/into_slice for IoSlice/IoSliceMut. ACP: https://github.com/rust-lang/libs-team/issues/93 Tracking issue: #132818 Based on a623c5233ae7f6b540e5c00f2be02f40b33b0793 (CC `@mpdn)` and #111277 (CC `@Lucretiel).` Closes: #124659 Tracking Issue: TODO try-job: test-various try-job: dist-various-1 try-job: dist-various-2 r? libs
2024-11-11Rollup merge of #130999 - cberner:flock_pr, r=joboetMatthias Krüger-0/+20
Implement file_lock feature This adds lock(), lock_shared(), try_lock(), try_lock_shared(), and unlock() to File gated behind the file_lock feature flag This is the initial implementation of https://github.com/rust-lang/rust/issues/130994 for Unix and Windows platforms. I will follow it up with an implementation for WASI preview 2
2024-11-09Add as_slice/into_slice for IoSlice/IoSliceMut.Alona Enraght-Moony-1/+6
Co-authored-by: Mike Pedersen <mike@mikepedersen.dk> Co-authored-by: Nathan West <Lucretiel@gmail.com>
2024-10-17Abstract the state type for futexesPaul Menage-2/+7
In the same way that we expose SmallAtomic and SmallPrimitive to allow Windows to use a value other than an AtomicU32 for its futex state, this patch switches the primary futex state type from AtomicU32 to futex::Atomic. The futex::Atomic type should be usable as an atomic value with underlying primitive type equal to futex::Primitive. This allows supporting the futex API on systems where the underlying kernel futex implementation requires more state than simply an AtomicU32. All in-tree futex implementations simply define {Atomic,Primitive} directly as {AtomicU32,u32}.
2024-10-13Implement file_lock featureChristopher Berner-0/+20
This adds lock(), lock_shared(), try_lock(), try_lock_shared(), and unlock() to File gated behind the file_lock feature flag
2024-10-02std: make `thread::current` available in all `thread_local!` destructorsjoboet-1/+6
2024-09-25Use `&raw` in the standard libraryJosh Stone-6/+4
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-23std: implement the `random` featurejoboet-14/+0
Implements the ACP https://github.com/rust-lang/libs-team/issues/393.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-4/+4
2024-08-27Auto merge of #128134 - joboet:move_pal_alloc, r=cupiverbors-29/+0
std: move allocators to `sys` Part of #117276.
2024-08-27std: move allocators to `sys`joboet-29/+0
2024-08-26pal/hermit: saturate `usleep` microseconds at `u64::MAX`Martin Kröning-1/+2
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-08-25pal/hermit: correctly round up microseconds in `Thread::sleep`Martin Kröning-1/+3
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-08-01fix(pal/hermit): `deny(unsafe_op_in_unsafe_fn)`Martin Kröning-20/+40
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-08-01refactor(pal/hermit): make `ENV` a non-mutable staticMartin Kröning-19/+15
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-07-31refactor(pal/hermit): use default impl of `GlobalAlloc::alloc_zeroed`Martin Kröning-10/+0
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-07-31refactor(pal/hermit): return `!` to satisfy rust-analyzerMartin Kröning-7/+3
This silences this rust-analyzer-specific error: `expected !, found ()` Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-07-29Reformat `use` declarations.Nicholas Nethercote-34/+20
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-24Rollup merge of #127733 - GrigorenkoPV:don't-forget, r=AmanieuMatthias Krüger-4/+2
Replace some `mem::forget`'s with `ManuallyDrop` > but I would like to see a larger effort to replace all uses of `mem::forget`. _Originally posted by `@saethlin` in https://github.com/rust-lang/rust/issues/127584#issuecomment-2226087767_ So, r? `@saethlin` Sorry, I have finished writing all of this before I got your response.
2024-07-16Use futex.rs for Windows thread parkingChris Denton-0/+5
2024-07-15lib: replace some `mem::forget`'s with `ManuallyDrop`Pavel Grigorenko-4/+2
2024-06-24Auto merge of #126523 - joboet:the_great_big_tls_refactor, r=Mark-Simulacrumbors-36/+2
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-15std: refactor the TLS implementationjoboet-36/+2
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-11Rename `std::fs::try_exists` to `std::fs::exists` and stabilize fs_try_existsEduardo Sánchez Muñoz-1/+1
2024-06-07add HermitOS support of vectored read/write operationsStefan Lankes-91/+180
In general, the I/O interface of hermit-abi is more POSIX-like interface. Consequently, platform abstraction layer for HermitOS has slightly adjusted and some inaccuracies remove.
2024-05-29Make `std::env::{set_var, remove_var}` unsafe in edition 2024Tobias Bucher-9/+5
Allow calling these functions without `unsafe` blocks in editions up until 2021, but don't trigger the `unused_unsafe` lint for `unsafe` blocks containing these functions. Fixes #27970. Fixes #90308. CC #124866.
2024-05-20switch also the default implementation for read_vectoredStefan Lankes-13/+2
2024-05-20switch to the default implementation of `write_vectored`Stefan Lankes-8/+2
2024-04-23increase the readability by using the unique name for the hermit-abiStefan Lankes-79/+80
Take up suggestion from the discussions within rust-lang/rust#115984 to increase readability.
2024-04-23revise the interpretation of ReadDirStefan Lankes-12/+8
HermitOS supports getdents64. As under Linux, the dirent64 entry `d_off` is not longer used, because its definition is not clear. Instead of `d_off` the entry `d_reclen` is used to determine the end of the dirent64 entry.
2024-04-11Factor some common `io::Error` constantsBenoît du Garreau-8/+2
2024-04-08Rollup merge of #115984 - hermit-os:fuse, r=m-ou-seMatthias Krüger-103/+251
extending filesystem support for Hermit Extending `std` to create, change and read a directory for Hermit. Hermit is a tier 3 platform and this PR changes only files, wich are related to the tier 3 platform.
2024-04-05Revert #121666Chris Denton-5/+1
This reverts #121666 due to #123495
2024-04-03rename `expose_addr` to `expose_provenance`joboet-1/+1
2024-04-02Rollup merge of #122935 - RalfJung:with-exposed-provenance, r=AmanieuJacob Pratt-1/+1
rename ptr::from_exposed_addr -> ptr::with_exposed_provenance As discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/To.20expose.20or.20not.20to.20expose/near/427757066). The old name, `from_exposed_addr`, makes little sense as it's not the address that is exposed, it's the provenance. (`ptr.expose_addr()` stays unchanged as we haven't found a better option yet. The intended interpretation is "expose the provenance and return the address".) The new name nicely matches `ptr::without_provenance`.
2024-03-31std: move `thread::current` TLS variable out of `thread_info`joboet-10/+0
2024-03-23rename ptr::from_exposed_addr -> ptr::with_exposed_provenanceRalf Jung-1/+1
2024-03-07Rust is a proper name: rust → RustRalf Jung-1/+1
2024-03-02Rollup merge of #121666 - ChrisDenton:thread-name, r=cuviperMatthias Krüger-1/+5
Use the OS thread name by default if `THREAD_INFO` has not been initialized Currently if `THREAD_INFO` hasn't been initialized then the name will be set to `None`. This PR changes it to use the OS thread name by default. This mostly affects foreign threads at the moment but we could expand this to make more use of the OS thread name in the future. Note: I've only implemented `Thread::get_name` for windows, linux and macos (and macos adjacent) targets. The rest just return `None`.
2024-03-01Add `get_name` placeholder to other targetsChris Denton-1/+5
2024-03-01revise interface to read directory entriesStefan Lankes-97/+116
The new interface has some similarities to Linux system call getdents64. The system call reads several dirent64 structures. At the end of each dirent64 is stored the name of the file. The length of file name is implictly part of dirent64 because d_reclen contains size of dirent64 plus the length of the file name.
2024-03-01Extending filesystem support for hermit-ossimonschoening-96/+225
2024-03-01Auto merge of #114016 - krtab:delete_sys_memchr, r=workingjubileebors-3/+1
Delete architecture-specific memchr code in std::sys Currently all architecture-specific memchr code is only used in `std::io`. Most of the actual `memchr` capacity exposed to the user through the slice API is instead implemented in `core::slice::memchr`. Hence this commit deletes `memchr` from `std::sys[_common]` and replace calls to it by calls to `core::slice::memchr` functions. This deletes `(r)memchr` from the list of symbols linked to libc. The interest of putting architecture specific code back in core is linked to the discussion to be had in #113654
2024-02-28add platform-specific function to get the error number for HermitOSStefan Lankes-5/+5
Extending `std` to get the last error number for HermitOS. HermitOS is a tier 3 platform and this PR changes only files, wich are related to the tier 3 platform.
2024-02-24library: use `addr_of!`Pavel Grigorenko-4/+4
2024-02-20Delete architecture-specific memchr code in std::sysArthur Carcano-3/+1
Currently all architecture-specific memchr code is only used in `std::io`. Most of the actual `memchr` capacity exposed to the user through the slice API is instead implemented in core::slice::memchr. Hence this commit deletes memchr from std::sys[_common] and replace calls to it by calls to core::slice::memchr functions. This deletes (r)memchr from the list of symbols linked to libc.