std: move locks to sys on µITRON

This commit is contained in:
joboet 2024-02-15 17:03:59 +01:00
parent 1be468815c
commit 0cd21cc549
No known key found for this signature in database
GPG key ID: 704E0149B0194B3C
11 changed files with 41 additions and 41 deletions

View file

@ -1,5 +1,7 @@
//! POSIX conditional variable implementation based on user-space wait queues. //! POSIX conditional variable implementation based on user-space wait queues.
use super::{abi, error::expect_success_aborting, spin::SpinMutex, task, time::with_tmos_strong}; use crate::sys::pal::itron::{
abi, error::expect_success_aborting, spin::SpinMutex, task, time::with_tmos_strong,
};
use crate::{mem::replace, ptr::NonNull, sys::locks::Mutex, time::Duration}; use crate::{mem::replace, ptr::NonNull, sys::locks::Mutex, time::Duration};
// The implementation is inspired by the queue-based implementation shown in // The implementation is inspired by the queue-based implementation shown in

View file

@ -0,0 +1,6 @@
cfg_if::cfg_if! {
if #[cfg(target_os = "solid_asp3")] {
mod itron;
pub use itron::Condvar;
}
}

View file

@ -0,0 +1,7 @@
mod condvar;
mod mutex;
mod rwlock;
pub use condvar::Condvar;
pub use mutex::Mutex;
pub use rwlock::RwLock;

View file

@ -1,6 +1,6 @@
//! Mutex implementation backed by μITRON mutexes. Assumes `acre_mtx` and //! Mutex implementation backed by μITRON mutexes. Assumes `acre_mtx` and
//! `TA_INHERIT` are available. //! `TA_INHERIT` are available.
use super::{ use crate::sys::pal::itron::{
abi, abi,
error::{expect_success, expect_success_aborting, fail, ItronError}, error::{expect_success, expect_success_aborting, fail, ItronError},
spin::SpinIdOnceCell, spin::SpinIdOnceCell,
@ -66,20 +66,3 @@ impl Drop for Mutex {
} }
} }
} }
pub(super) struct MutexGuard<'a>(&'a Mutex);
impl<'a> MutexGuard<'a> {
#[inline]
pub(super) fn lock(x: &'a Mutex) -> Self {
x.lock();
Self(x)
}
}
impl Drop for MutexGuard<'_> {
#[inline]
fn drop(&mut self) {
unsafe { self.0.unlock() };
}
}

View file

@ -0,0 +1,6 @@
cfg_if::cfg_if! {
if #[cfg(target_os = "solid_asp3")] {
mod itron;
pub use itron::Mutex;
}
}

View file

@ -0,0 +1,6 @@
cfg_if::cfg_if! {
if #[cfg(target_os = "solid_asp3")] {
mod solid;
pub use solid::RwLock;
}
}

View file

@ -1,5 +1,5 @@
//! A readers-writer lock implementation backed by the SOLID kernel extension. //! A readers-writer lock implementation backed by the SOLID kernel extension.
use super::{ use crate::sys::pal::{
abi, abi,
itron::{ itron::{
error::{expect_success, expect_success_aborting, fail, ItronError}, error::{expect_success, expect_success_aborting, fail, ItronError},

View file

@ -6,6 +6,7 @@ mod pal;
mod personality; mod personality;
pub mod cmath; pub mod cmath;
pub mod locks;
pub mod os_str; pub mod os_str;
pub mod path; pub mod path;

View file

@ -1,9 +1,8 @@
//! `solid_fs.h` //! `solid_fs.h`
use crate::os::raw::{c_char, c_int, c_uchar}; use crate::os::raw::{c_char, c_int, c_uchar};
pub use libc::{ pub use libc::{
blksize_t, dev_t, ino_t, off_t, stat, time_t, O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, ino_t, off_t, stat, time_t, O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY,
O_TRUNC, O_WRONLY, SEEK_CUR, SEEK_END, SEEK_SET, S_IEXEC, S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, SEEK_CUR, SEEK_END, SEEK_SET, S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFMT, S_IFREG, S_IWRITE,
S_IFMT, S_IFREG, S_IREAD, S_IWRITE,
}; };
pub const O_ACCMODE: c_int = 0x3; pub const O_ACCMODE: c_int = 0x3;

View file

@ -1,5 +1,5 @@
use crate::os::raw::{c_char, c_uint, c_void}; use crate::os::raw::{c_char, c_uint, c_void};
pub use libc::{c_int, c_long, size_t, ssize_t, suseconds_t, time_t, timeval}; pub use libc::{c_int, c_long, size_t, ssize_t, timeval};
pub const SOLID_NET_ERR_BASE: c_int = -2000; pub const SOLID_NET_ERR_BASE: c_int = -2000;
pub const EINPROGRESS: c_int = SOLID_NET_ERR_BASE - libc::EINPROGRESS; pub const EINPROGRESS: c_int = SOLID_NET_ERR_BASE - libc::EINPROGRESS;

View file

@ -2,19 +2,17 @@
#![allow(missing_docs, nonstandard_style)] #![allow(missing_docs, nonstandard_style)]
#![deny(unsafe_op_in_unsafe_fn)] #![deny(unsafe_op_in_unsafe_fn)]
mod abi; pub mod abi;
#[path = "../itron"] #[path = "../itron"]
mod itron { pub mod itron {
pub(super) mod abi; pub mod abi;
pub mod condvar; pub mod error;
pub(super) mod error; pub mod spin;
pub mod mutex; pub mod task;
pub(super) mod spin;
pub(super) mod task;
pub mod thread; pub mod thread;
pub mod thread_parking; pub mod thread_parking;
pub(super) mod time; pub mod time;
use super::unsupported; use super::unsupported;
} }
@ -41,14 +39,6 @@ pub mod thread_local_key;
pub use self::itron::thread_parking; pub use self::itron::thread_parking;
pub mod time; pub mod time;
mod rwlock;
pub mod locks {
pub use super::itron::condvar::*;
pub use super::itron::mutex::*;
pub use super::rwlock::*;
}
// SAFETY: must be called only once during runtime initialization. // SAFETY: must be called only once during runtime initialization.
// NOTE: this is not guaranteed to run, for example when Rust code is called externally. // NOTE: this is not guaranteed to run, for example when Rust code is called externally.
pub unsafe fn init(_argc: isize, _argv: *const *const u8, _sigpipe: u8) {} pub unsafe fn init(_argc: isize, _argv: *const *const u8, _sigpipe: u8) {}