Make Condvar::new and RWLock::new min const fn for cloudabi
This commit is contained in:
parent
f3e1b968e3
commit
b68bb636c7
2 changed files with 10 additions and 6 deletions
|
|
@ -28,11 +28,13 @@ pub struct Condvar {
|
|||
unsafe impl Send for Condvar {}
|
||||
unsafe impl Sync for Condvar {}
|
||||
|
||||
const NEW: Condvar = Condvar {
|
||||
condvar: UnsafeCell::new(AtomicU32::new(abi::CONDVAR_HAS_NO_WAITERS.0)),
|
||||
};
|
||||
|
||||
impl Condvar {
|
||||
pub const fn new() -> Condvar {
|
||||
Condvar {
|
||||
condvar: UnsafeCell::new(AtomicU32::new(abi::CONDVAR_HAS_NO_WAITERS.0)),
|
||||
}
|
||||
NEW
|
||||
}
|
||||
|
||||
pub unsafe fn init(&mut self) {}
|
||||
|
|
|
|||
|
|
@ -32,11 +32,13 @@ pub unsafe fn raw(r: &RWLock) -> *mut AtomicU32 {
|
|||
unsafe impl Send for RWLock {}
|
||||
unsafe impl Sync for RWLock {}
|
||||
|
||||
const NEW: RWLock = RWLock {
|
||||
lock: UnsafeCell::new(AtomicU32::new(abi::LOCK_UNLOCKED.0)),
|
||||
};
|
||||
|
||||
impl RWLock {
|
||||
pub const fn new() -> RWLock {
|
||||
RWLock {
|
||||
lock: UnsafeCell::new(AtomicU32::new(abi::LOCK_UNLOCKED.0)),
|
||||
}
|
||||
NEW
|
||||
}
|
||||
|
||||
pub unsafe fn try_read(&self) -> bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue