Skip to content

Commit d56d994

Browse files
committed
std: move locks to sys on SGX
1 parent da6e052 commit d56d994

File tree

7 files changed

+19
-23
lines changed

7 files changed

+19
-23
lines changed

library/std/src/sys/locks/condvar/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
cfg_if::cfg_if! {
2-
if #[cfg(target_os = "solid_asp3")] {
2+
if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] {
3+
mod sgx;
4+
pub use sgx::Condvar;
5+
} else if #[cfg(target_os = "solid_asp3")] {
36
mod itron;
47
pub use itron::Condvar;
58
}

library/std/src/sys/pal/sgx/condvar.rs renamed to library/std/src/sys/locks/condvar/sgx.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use crate::sys::locks::Mutex;
2+
use crate::sys::pal::waitqueue::{SpinMutex, WaitQueue, WaitVariable};
23
use crate::sys_common::lazy_box::{LazyBox, LazyInit};
34
use crate::time::Duration;
45

5-
use super::waitqueue::{SpinMutex, WaitQueue, WaitVariable};
6-
76
/// FIXME: `UnsafeList` is not movable.
87
struct AllocatedCondvar(SpinMutex<WaitVariable<()>>);
98

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
cfg_if::cfg_if! {
2-
if #[cfg(target_os = "solid_asp3")] {
2+
if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] {
3+
mod sgx;
4+
pub use sgx::Mutex;
5+
} else if #[cfg(target_os = "solid_asp3")] {
36
mod itron;
4-
pub use itron::Mutex;
7+
pub use itron::Condvar;
58
}
69
}

library/std/src/sys/pal/sgx/mutex.rs renamed to library/std/src/sys/locks/mutex/sgx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::waitqueue::{try_lock_or_false, SpinMutex, WaitQueue, WaitVariable};
1+
use crate::sys::pal::waitqueue::{try_lock_or_false, SpinMutex, WaitQueue, WaitVariable};
22
use crate::sys_common::lazy_box::{LazyBox, LazyInit};
33

44
/// FIXME: `UnsafeList` is not movable.

library/std/src/sys/locks/rwlock/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
cfg_if::cfg_if! {
2-
if #[cfg(target_os = "solid_asp3")] {
2+
if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] {
3+
mod sgx;
4+
pub use sgx::RwLock;
5+
} else if #[cfg(target_os = "solid_asp3")] {
36
mod solid;
47
pub use solid::RwLock;
58
}

library/std/src/sys/pal/sgx/rwlock.rs renamed to library/std/src/sys/locks/rwlock/sgx.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#[cfg(test)]
22
mod tests;
33

4+
use crate::alloc::Layout;
45
use crate::num::NonZeroUsize;
5-
use crate::sys_common::lazy_box::{LazyBox, LazyInit};
6-
7-
use super::waitqueue::{
6+
use crate::sys::pal::waitqueue::{
87
try_lock_or_false, NotifiedTcs, SpinMutex, SpinMutexGuard, WaitQueue, WaitVariable,
98
};
10-
use crate::alloc::Layout;
9+
use crate::sys_common::lazy_box::{LazyBox, LazyInit};
1110

1211
struct AllocatedRwLock {
1312
readers: SpinMutex<WaitVariable<Option<NonZeroUsize>>>,

library/std/src/sys/pal/sgx/mod.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ use crate::io::ErrorKind;
99
use crate::sync::atomic::{AtomicBool, Ordering};
1010

1111
pub mod abi;
12-
mod waitqueue;
13-
1412
pub mod alloc;
1513
pub mod args;
1614
pub mod env;
@@ -31,16 +29,7 @@ pub mod thread;
3129
pub mod thread_local_key;
3230
pub mod thread_parking;
3331
pub mod time;
34-
35-
mod condvar;
36-
mod mutex;
37-
mod rwlock;
38-
39-
pub mod locks {
40-
pub use super::condvar::*;
41-
pub use super::mutex::*;
42-
pub use super::rwlock::*;
43-
}
32+
pub mod waitqueue;
4433

4534
// SAFETY: must be called only once during runtime initialization.
4635
// NOTE: this is not guaranteed to run, for example when Rust code is called externally.

0 commit comments

Comments
 (0)