about summary refs log tree commit diff
path: root/library/std/src/sys/sgx
AgeCommit message (Collapse)AuthorLines
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-08-02Rollup merge of #86183 - inquisitivecrystal:env-nul, r=m-ou-seYuki Okushi-2/+2
Change environment variable getters to error recoverably This PR changes the standard library environment variable getter functions to error recoverably (i.e. not panic) when given an invalid value. On some platforms, it is invalid for environment variable names to contain `'\0'` or `'='`, or for their values to contain `'\0'`. Currently, the standard library panics when manipulating environment variables with names or values that violate these invariants. However, this behavior doesn't make a lot of sense, at least in the case of getters. If the environment variable is missing, the standard library just returns an error value, rather than panicking. It doesn't make sense to treat the case where the variable is invalid any differently from that. See the [internals thread](https://internals.rust-lang.org/t/why-should-std-var-panic/14847) for discussion. Thus, this PR changes the functions to error recoverably in this case as well. If desired, I could change the functions that manipulate environment variables in other ways as well. I didn't do that here because it wasn't entirely clear what to change them to. Should they error silently or do something else? If someone tells me how to change them, I'm happy to implement the changes. This fixes #86082, an ICE that arises from the current behavior. It also adds a regression test to make sure the ICE does not occur again in the future. `@rustbot` label +T-libs r? `@joshtriplett`
2021-07-27Add warning to SGX mutex implementationJethro Beekman-0/+2
2021-07-27Revert "SGX mutex is movable"Jethro Beekman-1/+1
This reverts commit 30b82e0f96579d9f897c4e2a780af82662d89772.
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-5/+5
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-22Rollup merge of #85182 - CDirkx:available_concurrency, r=JohnTitorYuki Okushi-0/+6
Move `available_concurrency` implementation to `sys` This splits out the platform-specific implementation of `available_concurrency` to the corresponding platforms under `sys`. No changes are made to the implementation. Tidy didn't lint against this code being originally added outside of `sys` because of a bug (see #84677), this PR also reverts the exclusion that was introduced in that bugfix. Tracking issue of `available_concurrency`: #74479
2021-06-22Rollup merge of #85054 - jethrogb:jb/sgx-inline-asm, r=AmanieuYuki Okushi-2/+2
Revert SGX inline asm syntax This was erroneously changed in #83387
2021-06-21Use `Unsupported` on platforms where `available_concurrency` is not implemented.Christiaan Dirkx-4/+2
2021-06-21Move `available_concurrency` implementation to `sys`Christiaan Dirkx-0/+8
2021-06-15Rename ErrorKind::Unknown to Uncategorized.Mara Bos-5/+5
2021-06-15Redefine `ErrorKind::Other` and stop using it in std.Mara Bos-5/+5
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-13Add support for const operands and options to global_asm!Amanieu d'Antras-1/+1
On x86, the default syntax is also switched to Intel to match asm!
2021-05-07Revert SGX inline asm syntaxJethro Beekman-2/+2
This was erroneously changed in #83387
2021-05-07Rollup merge of #85030 - jethrogb:jb/sgx-rearrange-files, r=nagisaDylan DPC-6/+7
Rearrange SGX split module files In #75979 several inlined modules were split out into multiple files. This PR keeps the multiple files but moves a few things around to organize things in a coherent way.
2021-05-07Rearrange SGX split module filesJethro Beekman-6/+7
In #75979 several inlined modules were split out into multiple files. This PR keeps the multiple files but moves a few things around to organize things in a coherent way.
2021-05-07SGX mutex is movableJethro Beekman-1/+1
2021-05-07Rollup merge of #84409 - mzohreva:mz/tls-dtors-before-join, r=jethrogbDylan DPC-10/+65
Ensure TLS destructors run before thread joins in SGX The excellent test is from ```@jethrogb``` For context see: https://github.com/rust-lang/rust/pull/83416#discussion_r617282907
2021-05-03Move `std::sys::sgx::ext` to `std::os::fortanix_sgx`Christiaan Dirkx-267/+0
2021-05-01Auto merge of #84658 - Amanieu:reserved_regs, r=petrochenkovbors-2/+8
Be stricter about rejecting LLVM reserved registers in asm! LLVM will silently produce incorrect code if these registers are used as operands. cc `@rust-lang/wg-inline-asm`
2021-05-01Reserve x18 on AArch64 and un-reserve x16Amanieu d'Antras-4/+4
2021-04-30Avoid using rbx in SGX inline assembly since it is reservedAmanieu d'Antras-2/+8
2021-04-30Auto merge of #84522 - CDirkx:cmath, r=yaahcbors-31/+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-28Reuse `unix::cmath`Christiaan Dirkx-31/+1
2021-04-25Rollup merge of #84541 - KaiJewson:inline-raw, r=m-ou-seDylan DPC-0/+6
Inline most raw socket, fd and handle conversions Now that file descriptor types on Unix have niches, it is advantageous for user libraries which provide file descriptor wrappers (e.g. `Socket` from socket2) to store a `File` internally instead of a `RawFd`, so that the niche can be taken advantage of. However, doing so will currently result in worse performance as `IntoRawFd`, `FromRawFd` and `AsRawFd` are not inlined. This change adds `#[inline]` to those methods on std types that wrap file descriptors, handles or sockets.
2021-04-25Inline most raw socket, fd and handle conversionsKaiJewson-0/+6
2021-04-25Auto merge of #84115 - CDirkx:rt, r=m-ou-sebors-9/+11
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/+4
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-4/+5
2021-04-22Remove `sys::args::Args::inner_debug` and use `Debug` insteadChristiaan Dirkx-3/+4
2021-04-22Move all cleanup to `sys::cleanup`Christiaan Dirkx-4/+0
2021-04-22Rework `at_exit` to `cleanup`Christiaan Dirkx-2/+5
2021-04-21Ensure TLS destructors run before thread joins in SGXMohsen Zohrevandi-10/+65
2021-04-20Change uses of never typeChristiaan Dirkx-35/+36
2021-04-20Replace `Void` with never typeChristiaan Dirkx-10/+5
2021-04-18Rename `NotSupported` to `Unsupported`Christiaan Dirkx-1/+1
2021-04-18Use `NotSupported` in more placesChristiaan Dirkx-1/+1
2021-03-25Auto merge of #83387 - cuviper:min-llvm-10, r=nagisabors-7/+4
Update the minimum external LLVM to 10 r? `@nikic`
2021-03-22Fix asm! from AT&T to Intel syntaxJosh Stone-1/+1
2021-03-22Update the minimum external LLVM to 10Josh Stone-6/+3
2021-03-21Use io::Error::new_const everywhere to avoid allocations.Mara Bos-9/+9
2021-03-03Auto merge of #76345 - okready:sgx-mem-range-overflow-checks, r=joshtriplettbors-8/+34
Add is_enclave_range/is_user_range overflow checks Fixes #76343. This adds overflow checking to `is_enclave_range` and `is_user_range` in `sgx::os::fortanix_sgx::mem` in order to mitigate possible security issues with enclave code. It also accounts for an edge case where the memory range provided ends exactly at the end of the address space, where calculating `p + len` would overflow back to zero despite the range potentially being valid.
2021-01-13deprecate atomic::spin_loop_hint in favour of hint::spin_loopAshley Mannix-2/+3
2020-12-22Migrate standard library away from compare_and_swapLinus Färnstrand-5/+5
2020-11-24Auto merge of #78953 - mzohreva:mz/from_raw_fd, r=Mark-Simulacrumbors-10/+35
Add Metadata in std::os::fortanix_sgx::io::FromRawFd Needed for https://github.com/fortanix/rust-sgx/pull/291 cc `@jethrogb`