std: move locks to sys on SGX

This commit is contained in:
joboet 2024-02-15 17:09:51 +01:00
parent 0cd21cc549
commit c2d0f8452f
No known key found for this signature in database
GPG Key ID: 704E0149B0194B3C
7 changed files with 19 additions and 23 deletions

View File

@ -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;
}

View File

@ -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<()>>);

View File

@ -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;
}
}

View File

@ -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.

View File

@ -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;
}

View File

@ -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>>>>,

View File

@ -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.