Skip to content

Commit 572aded

Browse files
committed
add simple downgrade implementations
1 parent 48bcf09 commit 572aded

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

std/src/sys/sync/rwlock/no_threads.rs

+5
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,9 @@ impl RwLock {
6262
pub unsafe fn write_unlock(&self) {
6363
assert_eq!(self.mode.replace(0), -1);
6464
}
65+
66+
#[inline]
67+
pub unsafe fn downgrade(&self) {
68+
assert_eq!(self.mode.replace(1), -1);
69+
}
6570
}

std/src/sys/sync/rwlock/solid.rs

+6
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ impl RwLock {
7979
let rwl = self.raw();
8080
expect_success_aborting(unsafe { abi::rwl_unl_rwl(rwl) }, &"rwl_unl_rwl");
8181
}
82+
83+
#[inline]
84+
pub unsafe fn downgrade(&self) {
85+
// The SOLID platform does not support the `downgrade` operation for reader writer locks, so
86+
// this function is simply a no-op as only 1 reader can read: the original writer.
87+
}
8288
}
8389

8490
impl Drop for RwLock {

std/src/sys/sync/rwlock/teeos.rs

+6
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,10 @@ impl RwLock {
4141
pub unsafe fn write_unlock(&self) {
4242
unsafe { self.inner.unlock() };
4343
}
44+
45+
#[inline]
46+
pub unsafe fn downgrade(&self) {
47+
// Since there is no difference between read-locked and write-locked on this platform, this
48+
// function is simply a no-op as only 1 reader can read: the original writer.
49+
}
4450
}

0 commit comments

Comments
 (0)