Skip to content

Commit b68bb63

Browse files
committed
Make Condvar::new and RWLock::new min const fn for cloudabi
1 parent f3e1b96 commit b68bb63

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/libstd/sys/cloudabi/condvar.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ pub struct Condvar {
2828
unsafe impl Send for Condvar {}
2929
unsafe impl Sync for Condvar {}
3030

31+
const NEW: Condvar = Condvar {
32+
condvar: UnsafeCell::new(AtomicU32::new(abi::CONDVAR_HAS_NO_WAITERS.0)),
33+
};
34+
3135
impl Condvar {
3236
pub const fn new() -> Condvar {
33-
Condvar {
34-
condvar: UnsafeCell::new(AtomicU32::new(abi::CONDVAR_HAS_NO_WAITERS.0)),
35-
}
37+
NEW
3638
}
3739

3840
pub unsafe fn init(&mut self) {}

src/libstd/sys/cloudabi/rwlock.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ pub unsafe fn raw(r: &RWLock) -> *mut AtomicU32 {
3232
unsafe impl Send for RWLock {}
3333
unsafe impl Sync for RWLock {}
3434

35+
const NEW: RWLock = RWLock {
36+
lock: UnsafeCell::new(AtomicU32::new(abi::LOCK_UNLOCKED.0)),
37+
};
38+
3539
impl RWLock {
3640
pub const fn new() -> RWLock {
37-
RWLock {
38-
lock: UnsafeCell::new(AtomicU32::new(abi::LOCK_UNLOCKED.0)),
39-
}
41+
NEW
4042
}
4143

4244
pub unsafe fn try_read(&self) -> bool {

0 commit comments

Comments
 (0)