about summary refs log tree commit diff
path: root/library/std/src/sys
AgeCommit message (Collapse)AuthorLines
2024-01-20Fixes from PRAyush Singh-36/+84
- is_ebadf always returns false - Allow reading partial characters to buffer - Allow full UTF-16 in stdin Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-01-20Use heap for stdout and stderrAyush Singh-9/+2
Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-01-20Improve UEFI stdioAyush Singh-20/+36
- Do not drop any character while reading - eabdf == Unsupported status - loop untill read character or error encountered Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-01-15std: move OS String implementation into `sys`joboet-21/+13
2024-01-13Refactor uses of `objc_msgSend` to no longer have clashing definitionsMads Marquart-37/+44
This is very similar to what Apple's own headers encourage you to do (cast the function pointer before use instead of making new declarations). Additionally, I'm documenting a few of the memory management rules we're following, ensuring that the `args` function doesn't leak memory (if you wrap it in an autorelease pool).
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: move personality implementation out of PALjoboet-1/+2
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>
2024-01-13std: xous: use blocking_scalars for mutex unlockSean Cross-13/+7
Use blocking scalars when unlocking a mutex. This ensures that mutexes are unlocked immediately rather than dangling. Signed-off-by: Sean Cross <sean@xobs.io>
2024-01-13std: xous: rework condvar to fix soundness issuesSean Cross-61/+98
Rework the Condvar implementation on Xous to ensure notifications are not missed. This involves keeping track of how many times a Condvar timed out and synchronizing based on that. Signed-off-by: Sean Cross <sean@xobs.io>
2024-01-13xous: std: thread_parking: fix deadlocksbunnie-22/+40
Fix a deadlock condition that can occur when a thread is awoken in between the point at which it checks its wake state and the point where it actually waits. This change will cause the waker to continuously send Notify messages until it actually wakes up the target thread. Signed-off-by: Sean Cross <sean@xobs.io>
2024-01-12update paths in commentsjoboet-4/+4
2024-01-11std: fix module references on Windowsjoboet-5/+5
2024-01-11std: fix module references on UNIXjoboet-8/+8
2024-01-11std: fix module references on UEFIjoboet-2/+2
2024-01-11std: fix module reference on SGXjoboet-1/+1
2024-01-11std: fix module references on hermitjoboet-15/+13
2024-01-11std: begin moving platform support modules into `pal`joboet-124/+132
2024-01-09Rollup merge of #118241 - fortanix:raoul/gh-530-make_userspace_types_send, ↵Guillaume Gomez-0/+6
r=Nilstrieb,dtolnay Making `User<T>` and `User<[T]>` `Send` All `User` types in SGX point to owned memory in userspace. Special care is always needed when accessing this memory as it must be assumed that an attacker is always able to change its content. Therefore, we can also easily transfer this memory between thread boundaries. cc: ``@mzohreva`` ``@vn971`` ``@belalH`` ``@jethrogb``
2024-01-09Rollup merge of #118748 - devnexen:fbsd_getrandom_simpl, r=Nilstrieb,dtolnayGuillaume Gomez-11/+1
std: getrandom simplification for freebsd. it is in the libcs' crate too now.
2024-01-07Update test for `E0796` and `static_mut_ref` lintObei Sideg-0/+4
2023-12-30openbsd: available_parallelism: use the right APISebastien Marie-26/+6
use the standard sysconf(_SC_NPROCESSORS_ONLN) way to get the number of available processors (capable of running processes), and fallback to sysctl([CTL_HW, HW_NCPU]) (number of CPUs configured) only on error. it permits to differenciate CPUs online vs CPUs configured (and not necessary capable of running processes). while here, use the common code path for BSDs for doing that, and avoid code duplication. Problem initially reported to me by Jiri Navratil.
2023-12-26Rollup merge of #119235 - Urgau:missing-feature-gate-sanitizer-cfi-cfgs, ↵Michael Goulet-1/+1
r=Nilstrieb Add missing feature gate for sanitizer CFI cfgs Found during the review of https://github.com/rust-lang/rust/pull/118494 in https://github.com/rust-lang/rust/pull/118494#discussion_r1416079288. cc `@rcvalle`
2023-12-23Adjust the std library for sanitizer_cfi cfgs changesUrgau-1/+1
2023-12-17Use FileEndOfFileInfo, not FileAllocationInfoChris Denton-6/+8
This fixes WINE support
2023-12-15Cfg remove lang items in doctestCameron Steffen-1/+1
2023-12-14Auto merge of #118566 - klensy:cstr-new, r=WaffleLapkinbors-26/+25
use c literals in compiler and library Relands refreshed https://github.com/rust-lang/rust/pull/111647
2023-12-13Auto merge of #116438 - ChrisDenton:truncate, r=thomccbors-6/+27
Windows: Allow `File::create` to work on hidden files This makes `OpenOptions::new().write(true).create(true).truncate(true).open(&path)` work if the path exists and is a hidden file. Previously it would fail with access denied. This makes it consistent with `OpenOptions::new().write(true).truncate(true).open(&path)` (note the lack of `create`) which does not have this restriction. It's also more consistent with other platforms. Fixes #115745 (see that issue for more details).
2023-12-09Auto merge of #117873 - quininer:android-emutls, r=Amanieubors-1/+7
Add emulated TLS support This is a reopen of https://github.com/rust-lang/rust/pull/96317 . many android devices still only use 128 pthread keys, so using emutls can be helpful. Currently LLVM uses emutls by default for some targets (such as android, openbsd), but rust does not use it, because `has_thread_local` is false. This commit has some changes to allow users to enable emutls: 1. add `-Zhas-thread-local` flag to specify that std uses `#[thread_local]` instead of pthread key. 2. when using emutls, decorate symbol names to find thread local symbol correctly. 3. change `-Zforce-emulated-tls` to `-Ztls-model=emulated` to explicitly specify whether to generate emutls. r? `@Amanieu`
2023-12-08std: getrandom simplification for freebsd.David Carlier-11/+1
it is in the libcs' crate too now.
2023-12-07Auto merge of #116565 - Sword-Destiny:master, r=Amanieubors-6/+1168
add teeos std impl add teeos std library implement. this MR is draft untill the libc update to 0.2.150 this MR is the final step for suppot rust in teeos. first step(add target): https://github.com/rust-lang/rust/pull/113480 second step(add teeos libc): https://github.com/rust-lang/libc/pull/3333
2023-12-07add teeos std impl袁浩-6/+1168
Signed-off-by: 袁浩 <yuanhao34@huawei.com>
2023-12-07Add emulated TLS supportquininer-1/+7
Currently LLVM uses emutls by default for some targets (such as android, openbsd), but rust does not use it, because `has_thread_local` is false. This commit has some changes to allow users to enable emutls: 1. add `-Zhas-thread-local` flag to specify that std uses `#[thread_local]` instead of pthread key. 2. when using emutls, decorate symbol names to find thread local symbol correctly. 3. change `-Zforce-emulated-tls` to `-Ztls-model=emulated` to explicitly specify whether to generate emutls.
2023-12-06library: fix comment about const assert in win apiklensy-1/+1
2023-12-06Auto merge of #118655 - compiler-errors:rollup-vrngyzn, r=compiler-errorsbors-1/+1
Rollup of 9 pull requests Successful merges: - #117793 (Update variable name to fix `unused_variables` warning) - #118123 (Add support for making lib features internal) - #118268 (Pretty print `Fn<(..., ...)>` trait refs with parentheses (almost) always) - #118346 (Add `deeply_normalize_for_diagnostics`, use it in coherence) - #118350 (Simplify Default for tuples) - #118450 (Use OnceCell in cell module documentation) - #118585 (Fix parser ICE when recovering `dyn`/`impl` after `for<...>`) - #118587 (Cleanup error handlers some more) - #118642 (bootstrap(builder.rs): Don't explicitly warn against `semicolon_in_expressions_from_macros`) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-06Auto merge of #117072 - betrusted-io:unwinding-crate-support, r=cuviperbors-1/+29
Use `unwinding` crate for unwinding on Xous platform This patch adds support for using [unwinding](https://github.com/nbdd0121/unwinding) on platforms where libunwinding isn't viable. An example of such a platform is `riscv32imac-unknown-xous-elf`. ### Background The Rust project maintains a fork of llvm at [llvm-project](https://github.com/rust-lang/llvm-project/) where it applies patches on top of the llvm project. This mostly seems to be to get unwinding support for the SGX project, and there may be other patches that I'm unaware of. There is a lot of machinery in the build system to support compiling `libunwind` on other platforms, and I needed to add additional patches to llvm in order to add support for Xous. Rather than continuing down this path, it seemed much easier to use a Rust-based library. The `unwinding` crate by `@nbdd0121` fits this description perfectly. ### Future work This could potentially replace the custom patches for `libunwind` on other platforms such as SGX, and could enable unwinding support on many more exotic platforms. ### Anti-goals This is not designed to replace `libunwind` on tier-one platforms or those where unwinding support already exists. There is already a well-established approach for unwinding there. Instead, this aims to enable unwinding on new platforms where C++ code may be difficult to compile.
2023-12-06std: xous: take eh_frame address from main argsSean Cross-1/+28
The main() function takes an argument that contains the eh_frame address. Implement `unwinding` support by looking for unwinding data at this address. Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-05Rollup merge of #117793 - wdunicornpro:patch-1, r=workingjubileeMichael Goulet-1/+1
Update variable name to fix `unused_variables` warning This PR fixes an `unused_variables` warning within `os.rs` when targeting `espidf`.
2023-12-03library: use c string literalsklensy-26/+25
2023-11-29Rollup merge of #116839 - joboet:xous_thread_parking, r=m-ou-seMatthias Krüger-1/+94
Implement thread parking for xous This follows the pattern set by [the Windows parker](https://github.com/rust-lang/rust/blob/ddef56d5dfa18f169af9db912dc8e8343797eebb/library/std/src/sys/windows/thread_parking.rs) when it uses keyed events. An atomic variable is used to track the state and optimize the fast path, while notifications are send via the ticktime server to block and unblock the thread. ping `@xobs` `@rustbot` label +T-libs +A-atomic r? libs
2023-11-26Making `User<T>` and `User<[T]>` `Send`Raoul Strackx-0/+6
2023-11-24Rollup merge of #118060 - ChrisDenton:abs-device-path, r=thomccMatthias Krüger-1/+1
Use an absolute path to the NUL device While a bare "NUL" *should* be redirected to the NUL device, especially in this simple case, let's be explicit that we aren't opening a file called "NUL" and instead open it directly. This will also set a good example for people copying std code. r? libs
2023-11-24Rollup merge of #117656 - ChrisDenton:invalid, r=thomccMatthias Krüger-7/+8
Update windows-bindgen and define `INVALID_HANDLE_VALUE` ourselves We generate bindings to the Windows API via the `windows-bindgen` crate, which is ultimately what's also used to generate the `windows-sys` and `windows` crates. However, there currently is some custom sauce just for std which makes it a bit different from the vanilla bindings. I would love for us to reduce and eventually remove the differences entirely so that std is using the exact same bindings as everyone else. Maybe in the future we can even just have a normal dependency on `windows-sys`. This PR removes one of those special things. Our definition of `INVALID_HANDLE_VALUE` relies on an experimental nightly feature for strict provenance, so lets bring that back in house. It also excludes it from the codegen step though that isn't strictly necessary as we override it in any case. This PR also updates windows-bingen to 0.52.0.
2023-11-23Auto merge of #115159 - solid-rs:patch/kmc-solid/io-safety, r=workingjubileebors-128/+73
kmc-solid: I/O safety Adds the I/O safety API (#87329) for socket file descriptors in [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets. All new public items are gated by the `solid_ext` library feature. This PR adds the following public types and traits: std::os::solid::io::AsFd std::os::solid::io::BorrowedFd std::os::solid::io::OwnedFd std::os::solid::prelude::AsFd (re-export) std::os::solid::prelude::BorrowedFd (re-export) std::os::solid::prelude::OwnedFd (re-export) And trait implementations: From<std::net::TcpListener> for std::os::solid::io::OwnedFd From<std::net::TcpStream> for std::os::solid::io::OwnedFd From<std::net::UdpSocket> for std::os::solid::io::OwnedFd From<std::os::solid::io::OwnedFd> for std::net::TcpListener From<std::os::solid::io::OwnedFd> for std::net::TcpStream From<std::os::solid::io::OwnedFd> for std::net::UdpSocket std::fmt::Debug for std::os::solid::io::BorrowedFd<'_> std::fmt::Debug for std::os::solid::io::OwnedFd std::io::IsTerminal for std::os::solid::io::BorrowedFd<'_> std::io::IsTerminal for std::os::solid::io::OwnedFd std::os::fd::AsRawFd for std::os::solid::io::BorrowedFd<'_> std::os::fd::AsRawFd for std::os::solid::io::OwnedFd std::os::fd::FromRawFd for std::os::solid::io::OwnedFd std::os::fd::IntoRawFd for std::os::solid::io::OwnedFd std::os::solid::io::AsFd for &impl std::os::solid::io::AsFd std::os::solid::io::AsFd for &mut impl std::os::solid::io::AsFd std::os::solid::io::AsFd for Arc<impl std::os::solid::io::AsFd> std::os::solid::io::AsFd for Box<impl std::os::solid::io::AsFd> std::os::solid::io::AsFd for Rc<impl std::os::solid::io::AsFd> std::os::solid::io::AsFd for std::net::TcpListener std::os::solid::io::AsFd for std::net::TcpStream std::os::solid::io::AsFd for std::net::UdpSocket std::os::solid::io::AsFd for std::os::solid::io::BorrowedFd<'_> std::os::solid::io::AsFd for std::os::solid::io::OwnedFd Taking advantage of the above change, this PR also refactors the internal details of `std::sys::solid::net` to match the design of other targets, e.g., by redefining `Socket` as a newtype of `OwnedFd`.