forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#123811 - joboet:queue_em_up, r=ChrisDenton
Use queue-based `RwLock` on more platforms This switches over Windows 7, SGX and Xous to the queue-based `RwLock` implementation added in rust-lang#110211, thereby fixing rust-lang#121949 for Windows 7 and partially resolving rust-lang#114581 on SGX. TEEOS can't currently be switched because it doesn't have a good thread parking implementation. CC `@roblabla` `@raoulstrackx` `@xobs` Could you help me test this, please? r? `@ChrisDenton` the Windows stuff should be familiar to you
- Loading branch information
Showing
8 changed files
with
58 additions
and
387 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//! The functions in this module are needed by libunwind. These symbols are named | ||
//! in pre-link args for the target specification, so keep that in sync. | ||
#![cfg(not(test))] | ||
|
||
use crate::sys::sync::RwLock; | ||
|
||
// Verify that the byte pattern libunwind uses to initialize an RwLock is | ||
// equivalent to the value of RwLock::new(). If the value changes, | ||
// `src/UnwindRustSgx.h` in libunwind needs to be changed too. | ||
const _: () = unsafe { | ||
let bits_rust: usize = crate::mem::transmute(RwLock::new()); | ||
assert!(bits_rust == 0); | ||
}; | ||
|
||
const EINVAL: i32 = 22; | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn __rust_rwlock_rdlock(p: *mut RwLock) -> i32 { | ||
if p.is_null() { | ||
return EINVAL; | ||
} | ||
|
||
// We cannot differentiate between reads an writes in unlock and therefore | ||
// always use a write-lock. Unwinding isn't really in the hot path anyway. | ||
unsafe { (*p).write() }; | ||
return 0; | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn __rust_rwlock_wrlock(p: *mut RwLock) -> i32 { | ||
if p.is_null() { | ||
return EINVAL; | ||
} | ||
unsafe { (*p).write() }; | ||
return 0; | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn __rust_rwlock_unlock(p: *mut RwLock) -> i32 { | ||
if p.is_null() { | ||
return EINVAL; | ||
} | ||
unsafe { (*p).write_unlock() }; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.