about summary refs log tree commit diff
path: root/library/std/src/sys/unsupported
AgeCommit message (Collapse)AuthorLines
2022-02-13make Instant::{duration_since, elapsed, sub} saturating and remove workaroundsThe8472-8/+0
This removes all mutex/atomics based workarounds for non-monotonic clocks and makes the previously panicking methods saturating instead. Effectively this moves the monotonization from `Instant` construction to the comparisons. This has some observable effects, especially on platforms without monotonic clocks: * Incorrectly ordered Instant comparisons no longer panic. This may hide some programming errors until someone actually looks at the resulting `Duration` * `checked_duration_since` will now return `None` in more cases. Previously it only happened when one compared instants obtained in the wrong order or manually created ones. Now it also does on backslides. The upside is reduced complexity and lower overhead of `Instant::now`.
2022-02-09Rollup merge of #93445 - yaahc:exitcode-constructor, r=dtolnayYuki Okushi-0/+9
Add From<u8> for ExitCode This should cover a mostly cross-platform subset of supported exit codes. We decided to stick with `u8` initially since its the common subset between all platforms that we support (excluding wasm which I think only works with `true` or `false`). Posix is supposed to take i32s, but in practice many unix platforms mask out all but the low 8 bits or in some cases the 8-15th bits. Windows takes a u32 instead of an i32. Bourne-compatible shells also report signals as exitcode 128 + `signal_no`, so there's some ambiguity there when returning exit codes > 127, but it is possible to disambiguate them on the other side so we decided against restricting the possible codes further than to `u8`. ## Related - Detailed analysis of exit code support on various platforms: https://internals.rust-lang.org/t/mini-pre-rfc-redesigning-process-exitstatus/5426 - https://github.com/rust-lang/rust/issues/48711 - https://github.com/rust-lang/rust/issues/43301 - https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Termination.2FExit.20Status.20Stabilization
2022-02-07fix exclusive range errorJane Lusby-1/+1
2022-02-06Add From<u8> for ExitCodeJane Lusby-0/+9
This should cover a mostly cross-platform subset of supported exit codes.
2022-02-04Hide Repr details from io::Error, and rework `io::Error::new_const`.Thom Chiovoloni-4/+4
2021-11-02Update library/std/src/sys/unsupported/fs.rsDrMeepster-1/+1
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2021-11-02more efficent File::read_buf impl for windows and unixDrMeepster-1/+5
2021-09-28Rename `std::thread::available_onccurrency` to ↵Yoshua Wuyts-1/+1
`std::thread::available_parallelism`
2021-08-30add `TcpStream::set_linger` and `TcpStream::linger`ibraheemdev-0/+8
2021-08-02Rollup merge of #86509 - CDirkx:os_str, r=m-ou-seYuki Okushi-2/+2
Move `os_str_bytes` to `sys::unix` Followup to #84967, with `OsStrExt` and `OsStringExt` moved out of `sys_common`, there is no reason anymore for `os_str_bytes` to live in `sys_common` and not in sys. This pr moves it to the location `sys::unix::os_str` and reuses the code on other platforms via `#[path]` (as is common in `sys`) instead of importing.
2021-07-05Make `getenv` return an Option instead of a ResultAris Merchant-2/+2
2021-07-03Move `os_str_bytes` to `sys::unix` and reuse it on other platforms.Christiaan Dirkx-2/+2
2021-07-02Auto merge of #85746 - m-ou-se:io-error-other, r=joshtriplettbors-1/+1
Redefine `ErrorKind::Other` and stop using it in std. This implements the idea I shared yesterday in the libs meeting when we were discussing how to handle adding new `ErrorKind`s to the standard library: This redefines `Other` to be for *user defined errors only*, and changes all uses of `Other` in the standard library to a `#[doc(hidden)]` and permanently `#[unstable]` `ErrorKind` that users can not match on. This ensures that adding `ErrorKind`s at a later point in time is not a breaking change, since the user couldn't match on these errors anyway. This way, we use the `#[non_exhaustive]` property of the enum in a more effective way. Open questions: - How do we check this change doesn't cause too much breakage? Will a crate run help and be enough? - How do we ensure we don't accidentally start using `Other` again in the standard library? We don't have a `pub(not crate)` or `#[deprecated(in this crate only)]`. cc https://github.com/rust-lang/rust/pull/79965 cc `@rust-lang/libs` `@ijackson` r? `@dtolnay`
2021-06-21Use `Unsupported` on platforms where `available_concurrency` is not implemented.Christiaan Dirkx-4/+1
2021-06-21Move `available_concurrency` implementation to `sys`Christiaan Dirkx-0/+8
2021-06-15Rename ErrorKind::Unknown to Uncategorized.Mara Bos-1/+1
2021-06-15Redefine `ErrorKind::Other` and stop using it in std.Mara Bos-1/+1
2021-06-01Multiple improvements to RwLocksBenoît du Garreau-0/+2
- Split `sys_common::RWLock` between `StaticRWLock` and `MovableRWLock` - Unbox `RwLock` on some platforms (Windows, Wasm and unsupported) - Simplify `RwLock::into_inner`
2021-05-19Move the implementation of `Path::exists` to `sys_common::fs` so platforms ↵Chris Denton-0/+4
can specialize it Windows implementation of `fs::try_exists`
2021-05-12Provide ExitStatusErrorIan Jackson-1/+17
Closes #73125 This is in pursuance of Issue #73127 Consider adding #[must_use] to std::process::ExitStatus In MR #81452 Add #[must_use] to [...] process::ExitStatus we concluded that the existing arrangements in are too awkward so adding that #[must_use] is blocked on improving the ergonomics. I wrote a mini-RFC-style discusion of the approach in https://github.com/rust-lang/rust/issues/73125#issuecomment-771092741 Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-07Rollup merge of #84655 - CDirkx:wasm, r=m-ou-seDylan DPC-0/+1
Cleanup of `wasm` Some more cleanup of `sys`, this time `wasm` - Reuse `unsupported::args` (functionally equivalent implementation, just an empty iterator). - Split out `atomics` implementation of `wasm::thread`, the non-`atomics` implementation is reused from `unsupported`. - Move all of the `atomics` code to a separate directory `wasm/atomics`. ````@rustbot```` label: +T-libs-impl r? ````@m-ou-se````
2021-04-30Auto merge of #84522 - CDirkx:cmath, r=yaahcbors-29/+1
Reuse `sys::unix::cmath` on other platforms Reuse `sys::unix::cmath` on all non-`windows` platforms. `unix` is chosen as the canonical location instead of `unsupported` or `common` because `unsupported` doesn't make sense semantically and `common` is reserved for code that is supported on all platforms. Also `unix` is already the home of some non-`windows` code that is technically not exclusive to `unix` like `unix::path`.
2021-04-28Fix missing import in `unsupported::args`Christiaan Dirkx-0/+1
2021-04-28Reuse `unix::cmath`Christiaan Dirkx-29/+1
2021-04-25Auto merge of #84115 - CDirkx:rt, r=m-ou-sebors-9/+7
Rework `init` and `cleanup` This PR reworks the code in `std` that runs before and after `main` and centralizes this code respectively in the functions `init` and `cleanup` in both `sys_common` and `sys`. This makes is easy to see what code is executed during initialization and cleanup on each platform just by looking at e.g. `sys::windows::init`. Full list of changes: - new module `rt` in `sys_common` to contain `init` and `cleanup` and the runtime macros. - `at_exit` and the mechanism to register exit handlers has been completely removed. In practice this was only used for closing sockets on windows and flushing stdout, which have been moved to `cleanup`. - <s>On windows `alloc` and `net` initialization is now done in `init`, this saves a runtime check in every allocation and network use.</s>
2021-04-22Rollup merge of #84413 - CDirkx:args_inner_debug, r=m-ou-seDylan DPC-3/+3
Remove `sys::args::Args::inner_debug` and use `Debug` instead This removes the method `sys::args::Args::inner_debug` on all platforms and implements `Debug` for `Args` instead. I believe this creates a more natural API for the different platforms under `sys`: export a type `Args: Debug + Iterator + ...` vs. `Args: Iterator + ...` and with a method `inner_debug`.
2021-04-22Document that `init` and `cleanup` are not guaranteed to runChristiaan Dirkx-0/+2
2021-04-22Move most init to `sys::init`Christiaan Dirkx-5/+1
2021-04-22Remove `sys::args::Args::inner_debug` and use `Debug` insteadChristiaan Dirkx-3/+3
2021-04-22Move all cleanup to `sys::cleanup`Christiaan Dirkx-3/+0
2021-04-22Rework `at_exit` to `cleanup`Christiaan Dirkx-2/+5
2021-04-20Change uses of never typeChristiaan Dirkx-126/+127
2021-04-20Replace `Void` with never typeChristiaan Dirkx-27/+21
2021-04-18Rename `NotSupported` to `Unsupported`Christiaan Dirkx-3/+6
2021-04-18Add and insta-stabilize `std::io::ErrorKind::NotSupported`Christiaan Dirkx-3/+3
2021-03-21Use io::Error::new_const everywhere to avoid allocations.Mara Bos-3/+3
2020-11-14Disambiguate symlink argument namesDavid Tolnay-1/+1
2020-10-14Rollup merge of #77722 - fusion-engineering-forks:safe-unsupported-locks, ↵Yuki Okushi-37/+32
r=Mark-Simulacrum Remove unsafety from sys/unsupported and add deny(unsafe_op_in_unsafe_fn). Replacing `UnsafeCell`s by a `Cell`s simplifies things and makes the mutex and rwlock implementations safe. Other than that, only unsafety in strlen() contained unsafe code. @rustbot modify labels: +F-unsafe-block-in-unsafe-fn +C-cleanup
2020-10-13Add note about using cells in the locks on the 'unsupported' platform.Mara Bos-0/+2
2020-10-09Assert state in sys/unsupported's RwLock::write_unlock.Mara Bos-1/+1
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-10-08Apply deny(unsafe_op_in_unsafe_fn) to all of sys/unsupported.Mara Bos-9/+10
2020-10-08Remove unsafety from unsupported/rwlosck.rs by using a Cell.Mara Bos-18/+16
Replacing the UnsafeCell by a Cell makes it all safe.
2020-10-08Remove unsafety from unsupported/mutex.rs by using a Cell.Mara Bos-14/+8
Replacing the UnsafeCell by a Cell simplifies things and makes it all safe.
2020-10-08Remove unnecessary rustc_const_stable attributes.Mara Bos-1/+0
2020-10-04Auto merge of #77380 - fusion-engineering-forks:unbox-the-mutex, r=dtolnaybors-0/+4
Unbox mutexes and condvars on some platforms Both mutexes and condition variables contained a Box containing the actual os-specific object. This was done because moving these objects may cause undefined behaviour on some platforms. However, this is not needed on Windows[1], Wasm[2], cloudabi[2], and 'unsupported'[3], were the box was only needlessly making them less efficient. This change gets rid of the box on those platforms. On those platforms, `Condvar` can no longer verify it is only used with one `Mutex`, as mutexes no longer have a stable address. This was addressed and considered acceptable in #76932. [1]\: https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-initializesrwlock [2]\: These are just a single atomic integer together with futex wait/wake calls/instructions. [3]\: The `unsupported` platform doesn't support multiple threads at all.
2020-10-02No longer put condvars on the 'unsupported' platform in a box.Mara Bos-1/+1
These condvars are unsupported and implemented as a ZST, so can be moved without problems.
2020-10-02Make it possible to have unboxed condvars on specific platforms.Mara Bos-0/+2
This commit keeps all condvars boxed on all platforms, but makes it trivial to remove the box on some platforms later.
2020-10-02No longer put mutexes on the 'unsupported' platform in a box.Mara Bos-1/+1
These mutexes are just a bool (in a cell), so can be moved without problems.
2020-10-02Make it possible to have unboxed mutexes on specific platforms.Mara Bos-0/+2
This commit keeps all mutexes boxed on all platforms, but makes it trivial to remove the box on some platforms later.
2020-09-26Add accessors to Command.Eric Huss-1/+38