about summary refs log tree commit diff
path: root/library/std/src/sys/pal/xous
AgeCommit message (Collapse)AuthorLines
2025-07-06sleep_until: use clock_nanosleep where possibledvdsk-1/+9
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
2025-05-15deduplicate abort implementationsjoboet-8/+6
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-04-27use generic Atomic type where possibleChristopher Durham-2/+2
in core/alloc/std only for now, and ignoring test files Co-authored-by: Pavel Grigorenko <GrigorenkoPV@ya.ru>
2025-04-21Move `sys::pal::os::Env` into `sys::env`Thalia Archibald-98/+2
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-18Combine env consts into std::sys::env_constsThalia Archibald-2/+0
2025-04-12Move args into std::sysThalia Archibald-54/+0
2025-03-22std: move process implementations to `sys`joboet-2/+0
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.
2025-03-09std: move stdio to `sys`joboet-134/+0
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.
2025-03-08Move fs into sysThalia Archibald-2/+0
2025-03-06library: Use size_of from the prelude instead of importedThalia Archibald-1/+1
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80.
2025-02-13std: Apply unsafe_attr_outside_unsafeEric Huss-3/+3
2025-02-09Mark extern blocks as unsafeMichael Goulet-1/+1
2025-02-07std: move `io` module out of `pal`joboet-2/+0
2025-02-02std: move network code into `sys`joboet-1338/+0
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.
2024-11-26std: update internal uses of `io::const_error!`joboet-77/+60
2024-10-13net: fix dead code warningSean Cross-0/+3
Signed-off-by: Sean Cross <sean@xobs.io>
2024-10-13std: xous: add support for args and envSean Cross-32/+504
Process arguments and environment variables are both passed by way of Application Parameters. These are a TLV format that gets passed in as the second process argument. This patch combines both as they are very similar in their decode. Signed-off-by: Sean Cross <sean@osdyne.com>
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-6/+6
2024-08-27std: move allocators to `sys`joboet-72/+0
2024-07-29Reformat `use` declarations.Nicholas Nethercote-20/+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-16xous: Forbid unwrapped unsafe in platform modulesJubilee Young-1/+1
2024-06-15std: refactor the TLS implementationjoboet-217/+1
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-05-29Make `std::env::{set_var, remove_var}` unsafe in edition 2024Tobias Bucher-2/+2
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-02std: move thread parking to `sys::sync`joboet-113/+0
2024-04-11Factor some common `io::Error` constantsBenoît du Garreau-16/+4
2024-04-05Revert #121666Chris Denton-5/+1
This reverts #121666 due to #123495
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-20Use less restricted memory ordering in xous::thread_local_key.Mara Bos-5/+5
SeqCst isn't necessary in any of these cases.
2024-03-19SeqCst->Relaxed for xous set_nonblocking.Mara Bos-1/+1
The SeqCst wasn't synchronizing with anything. Relaxed is enough.
2024-03-19SeqCst->{Release,Acquire} for xous DropLock.Mara Bos-3/+6
SeqCst is unnecessary. Release+Acquire is the right ordering for a mutex.
2024-03-01Add `get_name` placeholder to other targetsChris Denton-1/+5
2024-02-16std: move locks to `sys` on xousjoboet-340/+0
2024-02-15Replace `NonZero::<_>::new` with `NonZero::new`.Markus Reiter-1/+1
2024-02-15Use generic `NonZero` internally.Markus Reiter-3/+3
2024-02-08std: move path into `sys`joboet-2/+0
2024-02-05Remove unused structr0cky-3/+0
2024-01-22Rollup merge of #120109 - joboet:move_pal_cmath, r=ChrisDentonMatthias Krüger-2/+0
Move cmath into `sys` Part of #117276. r? ``@ChrisDenton``
2024-01-22Rollup merge of #119408 - betrusted-io:xous-fixes-add-network, r=Mark-SimulacrumMatthias Krüger-166/+1617
xous: misc fixes + add network support This patchset makes several fixes to Xous support. Additionally, this patch adds networking support. Many of these fixes are the result of the recent patch to get `unwinding` support merged. As a result of this patch, we can now run rust tests. As a result of these tests, we now have 729 tests passing: ``` failures: env::tests::test env::tests::test_self_exe_path env::tests::vars_debug env::tests::vars_os_debug os::raw::tests::same path::tests::test_push path::tests::test_set_file_name time::tests::since_epoch test result: FAILED. 729 passed; 8 failed; 1 ignored; 0 measured; 0 filtered out; finished in 214.54s ``` In the course of fixing several tests and getting the test sequence to reliably run, several issues were found. This patchset fixes those issues.
2024-01-22std: move cmath into `sys`joboet-2/+0
2024-01-15std: move OS String implementation into `sys`joboet-2/+0
2024-01-13xous: thread: mark thread_main() as divergentSean Cross-3/+7
The thread wrapper function never returns, so we can mark it as divergent. Signed-off-by: Sean Cross <sean@xobs.io>
2024-01-13std: xous: use constants for stdout and stderrSean Cross-3/+5
Use constants for the opcodes when writing to stdout or stderr. There still is no stdin operation. Signed-off-by: Sean Cross <sean@xobs.io>
2024-01-13std: xous: mark stdio structs as `repr(C)`Sean Cross-2/+2
Ensure these structs have a well-defined ABI layout. Signed-off-by: Sean Cross <sean@xobs.io>
2024-01-13xous: net: initial commit of network supportSean Cross-1/+1364
This is an initial commit of network support for Xous. On hardware, is backed by smoltcp running via a Xous server in a separate process space. This patch adds TCP and UDP client and server support as well as DNS resolution support using the dns Xous server. Signed-off-by: Sean Cross <sean@xobs.io>
2024-01-13std: xous: share allocator symbol in testsSean Cross-0/+8
When using the testing framework, a second copy of libstd is built and linked. Use a global symbol for the `DLMALLOC` variable and mark it as `extern` when building as a test. This ensures we only have a single allocator even when running tests. Signed-off-by: Sean Cross <sean@xobs.io>
2024-01-13std: xous: fix thread_local_key under testsSean Cross-38/+63
When running tests, libstd gets implemented as a second library. Due to this fact, the `create()` and `destroy()` functions come from different libraries. To work around this, stash the `destroy_tls()` pointer in the first unused slot in the thread local storage pool. That way even if the destruction comes from a different version of libstd, the correct `DTORS` list will be consulted. Signed-off-by: Sean Cross <sean@xobs.io>
2024-01-13std: once: use queue implementation on XousSean Cross-2/+0
Use the global queue implementation of Once when running on Xous. This gets us a thread-safe implementation, rather than using the non-threadsafe `unsupported` implementation. Signed-off-by: Sean Cross <sean@xobs.io>
2024-01-13std: xous: rewrite rwlock to be more robustSean Cross-21/+23
Add more checks to RwLock on Xous. As part of this, ensure the variable is in a good state when unlocking. Additionally, use the global `yield_now()` rather than platform-specific `do_yield()`. Signed-off-by: Sean Cross <sean@xobs.io>