Next Generation WASM Microkernel Operating System
1// Copyright 2025 Jonas Kruckenberg
2//
3// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
4// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5// http://opensource.org/licenses/MIT>, at your option. This file may not be
6// copied, modified, or distributed except according to those terms.
7
8//! Synchronization primitives for use in k23.
9
10#![cfg_attr(not(test), no_std)]
11#![cfg_attr(feature = "thread-local", feature(thread_local))]
12#![feature(dropck_eyepatch)]
13#![feature(negative_impls)]
14
15mod backoff;
16mod barrier;
17mod lazy_lock;
18mod loom;
19mod mutex;
20mod once;
21mod once_lock;
22mod rw_lock;
23
24#[cfg(feature = "thread-local")]
25mod remutex;
26
27pub use backoff::Backoff;
28pub use barrier::{Barrier, BarrierWaitResult};
29pub use lazy_lock::LazyLock;
30pub use mutex::{Mutex, MutexGuard};
31pub use once::{ExclusiveState, Once};
32pub use once_lock::OnceLock;
33#[cfg(feature = "thread-local")]
34pub use remutex::{ReentrantMutex, ReentrantMutexGuard};
35pub use rw_lock::{RwLock, RwLockReadGuard, RwLockUpgradableReadGuard, RwLockWriteGuard};
36
37/// Marker type which indicates that the Guard type for a lock is not `Send`.
38#[expect(dead_code, reason = "inner pointer is unused")]
39pub(crate) struct GuardNoSend(*mut ());
40#[expect(clippy::undocumented_unsafe_blocks, reason = "")]
41unsafe impl Sync for GuardNoSend {}