Skip to content

Commit 0cd21cc

Browse files
committed
std: move locks to sys on µITRON
1 parent 1be4688 commit 0cd21cc

File tree

11 files changed

+41
-41
lines changed

11 files changed

+41
-41
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! POSIX conditional variable implementation based on user-space wait queues.
2-
use super::{abi, error::expect_success_aborting, spin::SpinMutex, task, time::with_tmos_strong};
2+
use crate::sys::pal::itron::{
3+
abi, error::expect_success_aborting, spin::SpinMutex, task, time::with_tmos_strong,
4+
};
35
use crate::{mem::replace, ptr::NonNull, sys::locks::Mutex, time::Duration};
46

57
// The implementation is inspired by the queue-based implementation shown in
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cfg_if::cfg_if! {
2+
if #[cfg(target_os = "solid_asp3")] {
3+
mod itron;
4+
pub use itron::Condvar;
5+
}
6+
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
mod condvar;
2+
mod mutex;
3+
mod rwlock;
4+
5+
pub use condvar::Condvar;
6+
pub use mutex::Mutex;
7+
pub use rwlock::RwLock;

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

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Mutex implementation backed by μITRON mutexes. Assumes `acre_mtx` and
22
//! `TA_INHERIT` are available.
3-
use super::{
3+
use crate::sys::pal::itron::{
44
abi,
55
error::{expect_success, expect_success_aborting, fail, ItronError},
66
spin::SpinIdOnceCell,
@@ -66,20 +66,3 @@ impl Drop for Mutex {
6666
}
6767
}
6868
}
69-
70-
pub(super) struct MutexGuard<'a>(&'a Mutex);
71-
72-
impl<'a> MutexGuard<'a> {
73-
#[inline]
74-
pub(super) fn lock(x: &'a Mutex) -> Self {
75-
x.lock();
76-
Self(x)
77-
}
78-
}
79-
80-
impl Drop for MutexGuard<'_> {
81-
#[inline]
82-
fn drop(&mut self) {
83-
unsafe { self.0.unlock() };
84-
}
85-
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cfg_if::cfg_if! {
2+
if #[cfg(target_os = "solid_asp3")] {
3+
mod itron;
4+
pub use itron::Mutex;
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cfg_if::cfg_if! {
2+
if #[cfg(target_os = "solid_asp3")] {
3+
mod solid;
4+
pub use solid::RwLock;
5+
}
6+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! A readers-writer lock implementation backed by the SOLID kernel extension.
2-
use super::{
2+
use crate::sys::pal::{
33
abi,
44
itron::{
55
error::{expect_success, expect_success_aborting, fail, ItronError},

library/std/src/sys/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mod pal;
66
mod personality;
77

88
pub mod cmath;
9+
pub mod locks;
910
pub mod os_str;
1011
pub mod path;
1112

library/std/src/sys/pal/solid/abi/fs.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
//! `solid_fs.h`
22
use crate::os::raw::{c_char, c_int, c_uchar};
33
pub use libc::{
4-
blksize_t, dev_t, ino_t, off_t, stat, time_t, O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR,
5-
O_TRUNC, O_WRONLY, SEEK_CUR, SEEK_END, SEEK_SET, S_IEXEC, S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO,
6-
S_IFMT, S_IFREG, S_IREAD, S_IWRITE,
4+
ino_t, off_t, stat, time_t, O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY,
5+
SEEK_CUR, SEEK_END, SEEK_SET, S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFMT, S_IFREG, S_IWRITE,
76
};
87

98
pub const O_ACCMODE: c_int = 0x3;

library/std/src/sys/pal/solid/abi/sockets.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::os::raw::{c_char, c_uint, c_void};
2-
pub use libc::{c_int, c_long, size_t, ssize_t, suseconds_t, time_t, timeval};
2+
pub use libc::{c_int, c_long, size_t, ssize_t, timeval};
33

44
pub const SOLID_NET_ERR_BASE: c_int = -2000;
55
pub const EINPROGRESS: c_int = SOLID_NET_ERR_BASE - libc::EINPROGRESS;

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

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22
#![allow(missing_docs, nonstandard_style)]
33
#![deny(unsafe_op_in_unsafe_fn)]
44

5-
mod abi;
5+
pub mod abi;
66

77
#[path = "../itron"]
8-
mod itron {
9-
pub(super) mod abi;
10-
pub mod condvar;
11-
pub(super) mod error;
12-
pub mod mutex;
13-
pub(super) mod spin;
14-
pub(super) mod task;
8+
pub mod itron {
9+
pub mod abi;
10+
pub mod error;
11+
pub mod spin;
12+
pub mod task;
1513
pub mod thread;
1614
pub mod thread_parking;
17-
pub(super) mod time;
15+
pub mod time;
1816
use super::unsupported;
1917
}
2018

@@ -41,14 +39,6 @@ pub mod thread_local_key;
4139
pub use self::itron::thread_parking;
4240
pub mod time;
4341

44-
mod rwlock;
45-
46-
pub mod locks {
47-
pub use super::itron::condvar::*;
48-
pub use super::itron::mutex::*;
49-
pub use super::rwlock::*;
50-
}
51-
5242
// SAFETY: must be called only once during runtime initialization.
5343
// NOTE: this is not guaranteed to run, for example when Rust code is called externally.
5444
pub unsafe fn init(_argc: isize, _argv: *const *const u8, _sigpipe: u8) {}

0 commit comments

Comments
 (0)