| Age | Commit message (Collapse) | Author | Lines |
|
|
|
Revert "Constify SystemTime methods"
This reverts https://github.com/rust-lang/rust/pull/144519. The const-hacks introduces bugs, and they make the code harder to maintain. Let's wait until we can constify these functions without changing their implementation.
Fixes https://github.com/rust-lang/rust/issues/146228.
Closes https://github.com/rust-lang/rust/issues/144517 (since the feature is gone).
r? `@tgross35`
Cc `@clarfonthey`
|
|
This reverts commit 7ce620dd7c6fc3371290b40a1ea28146f0d37031.
The const-hacks introduces bugs, and they make the code harder to maintain.
Let's wait until we can constify these functions without changing their implementation.
|
|
Implement `Socket::take_error` for Hermit
This PR fixes an unused-imports compilation error introduced in 845311a065a5638c516ed96c73b09862b176b329 and implements `Socket::take_error` for Hermit.
Hermit's `Socket::take_error` implementation works exactly like the one for Unix.
r? joboet
|
|
This fixes
```
error: unused import: `str`
--> library/std/src/sys/pal/hermit/os.rs:6:22
|
6 | use crate::{fmt, io, str};
| ^^^
|
= note: `-D unused-imports` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(unused_imports)]`
```
This was caused by 845311a065a5638c516ed96c73b09862b176b329.
|
|
|
|
|
|
|
|
|
|
`panic!` does not print any identifying information for threads that are
unnamed. However, in many cases, the thread ID can be determined.
This changes the panic message from something like this:
thread '<unnamed>' panicked at src/main.rs:3:5:
explicit panic
To something like this:
thread '<unnamed>' (0xff9bf) panicked at src/main.rs:3:5:
explicit panic
Stack overflow messages are updated as well.
This change applies to both named and unnamed threads. The ID printed is
the OS integer thread ID rather than the Rust thread ID, which should
also be what debuggers print.
|
|
|
|
Using clock nanosleep leads to more accurate sleep times on platforms
where it is supported.
To enable using clock_nanosleep this makes `sleep_until` platform
specific. That unfortunatly requires identical placeholder
implementations for the other platforms (windows/mac/wasm etc).
we will land platform specific implementations for those later. See the
`sleep_until` tracking issue.
This requires an accessors for the Instant type. As that accessor is only
used on the platforms that have clock_nanosleep it is marked as allow_unused.
32bit time_t targets do not use clock_nanosleep atm, they instead rely
on the same placeholder as the other platforms. We could make them
use clock_nanosleep too in the future using `__clock_nanosleep_time64`.
__clock_nanosleep_time64 is documented at:
https://www.gnu.org/software/libc/manual/html_node/64_002dbit-time-symbol-handling.html
|
|
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.
|
|
in core/alloc/std only for now, and ignoring test files
Co-authored-by: Pavel Grigorenko <GrigorenkoPV@ya.ru>
|
|
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`.
|
|
|
|
|
|
|
|
As per #117276, this moves the implementations of `Process` and friends out of the `pal` module and into the `sys` module, removing quite a lot of error-prone `#[path]` imports in the process (hah, get it ;-)). I've also made the `zircon` module a dedicated submodule of `pal::unix`, hopefully we can move some other definitions there as well (they are currently quite a lot of duplications in `sys`). Also, the `ensure_no_nuls` function on Windows now lives in `sys::pal::windows` – it's not specific to processes and shared by the argument implementation.
|
|
|
|
Support `File::seek` for Hermit
`lseek` was added in `hermit-abi` in commit [87dd201](https://github.com/hermit-os/hermit-rs/commit/87dd201a14ac7661e1a4b761273e24d750496286) (add missing interface for lseek, 2024-07-15), which was just released in version 0.5.0.
cc ``@mkroening,`` ``@stlankes``
Fixes https://github.com/hermit-os/hermit-rs/issues/652
|
|
As per #117276, this moves the platform definitions of `Stdout` and friends into `sys`. This PR also unifies the UNIX and Hermit implementations and moves the `__rust_print_err` function needed by libunwind on SGX into the dedicated module for such helper functions.
|
|
|
|
|
|
Error messages are supposed to start with lowercase letters, but a lot
of `io::const_error` messages did not. This fixes them to start with a
lowercase letter.
I did consider adding a const check for this to the macro, but some of
them start with proper nouns that make sense to uppercase them.
See https://doc.rust-lang.org/1.85.0/std/error/trait.Error.html
|
|
Use `tell` for `<File as Seek>::stream_position`
Some platforms have a more efficient way to get the current offset of the file than by seeking. For example, Wasi has `fd_tell` and SOLID has `SOLID_FS_Ftell`. Implement `<File as Seek>::stream_position()` in terms of those.
I do not use any APIs that were not already used in `std`. Although, the `libc` crate has [`ftell`](https://docs.rs/libc/latest/libc/fn.ftell.html), [`ftello`](https://docs.rs/libc/latest/libc/fn.ftello.html), and [`ftello64`](https://docs.rs/libc/latest/libc/fn.ftello64.html), I do not know platform coverage. It appears that Windows has no `tell`-like API.
I have checked that it builds on each relevant platform.
|
|
|
|
Use `const_error!` when possible
Replace usages of `io::Error::new(io::ErrorKind::Variant, "constant string")` with `io::const_error!(io::ErrorKind::Variant, "constant string")` to avoid allocations when possible. Additionally, fix `&&str` error messages in SGX and missing/misplaced trailing commas in `const_error!`.
|
|
|
|
|
|
|
|
|
|
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.
|
|
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.
|
|
|
|
|
|
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
|
|
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
|
|
Co-authored-by: Mike Pedersen <mike@mikepedersen.dk>
Co-authored-by: Nathan West <Lucretiel@gmail.com>
|
|
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}.
|
|
This adds lock(), lock_shared(), try_lock(), try_lock_shared(), and
unlock() to File gated behind the file_lock feature flag
|
|
|
|
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.
|
|
Implements the ACP https://github.com/rust-lang/libs-team/issues/393.
|
|
|
|
std: move allocators to `sys`
Part of #117276.
|
|
|
|
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
|
|
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
|
|
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
|