Make Condvar::new and RWLock::new min const fn for cloudabi

This commit is contained in:
Oliver Schneider 2018-08-30 10:45:05 +02:00
parent f3e1b968e3
commit b68bb636c7
2 changed files with 10 additions and 6 deletions

View file

@ -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) {}

View file

@ -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 {