diff options
| author | joboet <jonasboettiger@icloud.com> | 2024-02-15 17:09:51 +0100 |
|---|---|---|
| committer | joboet <jonasboettiger@icloud.com> | 2024-02-16 12:10:48 +0100 |
| commit | c2d0f8452ff7ec35fa798d783a15510fc5549c90 (patch) | |
| tree | cf03567b9579e3f567f53e39eda03a4b72eed657 | |
| parent | 0cd21cc549229c1cd6bb544eb53e7eb98190168f (diff) | |
| download | rust-c2d0f8452ff7ec35fa798d783a15510fc5549c90.tar.gz rust-c2d0f8452ff7ec35fa798d783a15510fc5549c90.zip | |
std: move locks to `sys` on SGX
| -rw-r--r-- | library/std/src/sys/locks/condvar/mod.rs | 5 | ||||
| -rw-r--r-- | library/std/src/sys/locks/condvar/sgx.rs (renamed from library/std/src/sys/pal/sgx/condvar.rs) | 3 | ||||
| -rw-r--r-- | library/std/src/sys/locks/mutex/mod.rs | 7 | ||||
| -rw-r--r-- | library/std/src/sys/locks/mutex/sgx.rs (renamed from library/std/src/sys/pal/sgx/mutex.rs) | 2 | ||||
| -rw-r--r-- | library/std/src/sys/locks/rwlock/mod.rs | 5 | ||||
| -rw-r--r-- | library/std/src/sys/locks/rwlock/sgx.rs (renamed from library/std/src/sys/pal/sgx/rwlock.rs) | 7 | ||||
| -rw-r--r-- | library/std/src/sys/pal/sgx/mod.rs | 13 |
7 files changed, 19 insertions, 23 deletions
diff --git a/library/std/src/sys/locks/condvar/mod.rs b/library/std/src/sys/locks/condvar/mod.rs index 0bb93d6482a..1825fc25ff3 100644 --- a/library/std/src/sys/locks/condvar/mod.rs +++ b/library/std/src/sys/locks/condvar/mod.rs @@ -1,5 +1,8 @@ cfg_if::cfg_if! { - if #[cfg(target_os = "solid_asp3")] { + if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] { + mod sgx; + pub use sgx::Condvar; + } else if #[cfg(target_os = "solid_asp3")] { mod itron; pub use itron::Condvar; } diff --git a/library/std/src/sys/pal/sgx/condvar.rs b/library/std/src/sys/locks/condvar/sgx.rs index aa1174664ae..cabd3250275 100644 --- a/library/std/src/sys/pal/sgx/condvar.rs +++ b/library/std/src/sys/locks/condvar/sgx.rs @@ -1,9 +1,8 @@ use crate::sys::locks::Mutex; +use crate::sys::pal::waitqueue::{SpinMutex, WaitQueue, WaitVariable}; use crate::sys_common::lazy_box::{LazyBox, LazyInit}; use crate::time::Duration; -use super::waitqueue::{SpinMutex, WaitQueue, WaitVariable}; - /// FIXME: `UnsafeList` is not movable. struct AllocatedCondvar(SpinMutex<WaitVariable<()>>); diff --git a/library/std/src/sys/locks/mutex/mod.rs b/library/std/src/sys/locks/mutex/mod.rs index f8a51c7c682..d61d3883bc9 100644 --- a/library/std/src/sys/locks/mutex/mod.rs +++ b/library/std/src/sys/locks/mutex/mod.rs @@ -1,6 +1,9 @@ cfg_if::cfg_if! { - if #[cfg(target_os = "solid_asp3")] { + if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] { + mod sgx; + pub use sgx::Mutex; + } else if #[cfg(target_os = "solid_asp3")] { mod itron; - pub use itron::Mutex; + pub use itron::Condvar; } } diff --git a/library/std/src/sys/pal/sgx/mutex.rs b/library/std/src/sys/locks/mutex/sgx.rs index 0dbf020ebe0..d37bd02adf8 100644 --- a/library/std/src/sys/pal/sgx/mutex.rs +++ b/library/std/src/sys/locks/mutex/sgx.rs @@ -1,4 +1,4 @@ -use super::waitqueue::{try_lock_or_false, SpinMutex, WaitQueue, WaitVariable}; +use crate::sys::pal::waitqueue::{try_lock_or_false, SpinMutex, WaitQueue, WaitVariable}; use crate::sys_common::lazy_box::{LazyBox, LazyInit}; /// FIXME: `UnsafeList` is not movable. diff --git a/library/std/src/sys/locks/rwlock/mod.rs b/library/std/src/sys/locks/rwlock/mod.rs index ad4dfdb80a7..5e2b0044090 100644 --- a/library/std/src/sys/locks/rwlock/mod.rs +++ b/library/std/src/sys/locks/rwlock/mod.rs @@ -1,5 +1,8 @@ cfg_if::cfg_if! { - if #[cfg(target_os = "solid_asp3")] { + if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] { + mod sgx; + pub use sgx::RwLock; + } else if #[cfg(target_os = "solid_asp3")] { mod solid; pub use solid::RwLock; } diff --git a/library/std/src/sys/pal/sgx/rwlock.rs b/library/std/src/sys/locks/rwlock/sgx.rs index ebae1cff0ee..136dea597bb 100644 --- a/library/std/src/sys/pal/sgx/rwlock.rs +++ b/library/std/src/sys/locks/rwlock/sgx.rs @@ -1,13 +1,12 @@ #[cfg(test)] mod tests; +use crate::alloc::Layout; use crate::num::NonZero; -use crate::sys_common::lazy_box::{LazyBox, LazyInit}; - -use super::waitqueue::{ +use crate::sys::pal::waitqueue::{ try_lock_or_false, NotifiedTcs, SpinMutex, SpinMutexGuard, WaitQueue, WaitVariable, }; -use crate::alloc::Layout; +use crate::sys_common::lazy_box::{LazyBox, LazyInit}; struct AllocatedRwLock { readers: SpinMutex<WaitVariable<Option<NonZero<usize>>>>, diff --git a/library/std/src/sys/pal/sgx/mod.rs b/library/std/src/sys/pal/sgx/mod.rs index 46f3e5b401d..8ef3495884f 100644 --- a/library/std/src/sys/pal/sgx/mod.rs +++ b/library/std/src/sys/pal/sgx/mod.rs @@ -9,8 +9,6 @@ use crate::io::ErrorKind; use crate::sync::atomic::{AtomicBool, Ordering}; pub mod abi; -mod waitqueue; - pub mod alloc; pub mod args; pub mod env; @@ -31,16 +29,7 @@ pub mod thread; pub mod thread_local_key; pub mod thread_parking; pub mod time; - -mod condvar; -mod mutex; -mod rwlock; - -pub mod locks { - pub use super::condvar::*; - pub use super::mutex::*; - pub use super::rwlock::*; -} +pub mod waitqueue; // SAFETY: must be called only once during runtime initialization. // NOTE: this is not guaranteed to run, for example when Rust code is called externally. |
