mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
add SyncUnsafeCell implementation
This commit is contained in:
parent
18572658cb
commit
56e3de3c62
|
@ -190,6 +190,7 @@ mod sync;
|
||||||
pub mod syscall;
|
pub mod syscall;
|
||||||
/// Interactions with the internal timers
|
/// Interactions with the internal timers
|
||||||
pub mod timer;
|
pub mod timer;
|
||||||
|
pub(crate) mod util;
|
||||||
|
|
||||||
mod no_game;
|
mod no_game;
|
||||||
|
|
||||||
|
|
16
agb/src/util.rs
Normal file
16
agb/src/util.rs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
use core::cell::UnsafeCell;
|
||||||
|
|
||||||
|
pub struct SyncUnsafeCell<T>(UnsafeCell<T>);
|
||||||
|
|
||||||
|
unsafe impl<T> Sync for SyncUnsafeCell<T> {}
|
||||||
|
unsafe impl<T> Send for SyncUnsafeCell<T> {}
|
||||||
|
|
||||||
|
impl<T> SyncUnsafeCell<T> {
|
||||||
|
pub const fn new(t: T) -> Self {
|
||||||
|
Self(UnsafeCell::new(t))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub unsafe fn get(&self) -> *mut T {
|
||||||
|
self.0.get()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue