-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shim Apple's futex primitives #4142
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -156,14 +156,24 @@ pub fn futex<'tcx>( | |||||
.futex | ||||||
.clone(); | ||||||
|
||||||
let dest = dest.clone(); | ||||||
ecx.futex_wait( | ||||||
futex_ref, | ||||||
bitset, | ||||||
timeout, | ||||||
Scalar::from_target_isize(0, ecx), // retval_succ | ||||||
Scalar::from_target_isize(-1, ecx), // retval_timeout | ||||||
dest.clone(), | ||||||
LibcError("ETIMEDOUT"), // errno_timeout | ||||||
callback!( | ||||||
@capture<'tcx> { | ||||||
dest: MPlaceTy<'tcx>, | ||||||
} | ||||||
|ecx, unblock: UnblockKind| match unblock { | ||||||
UnblockKind::Ready => { | ||||||
ecx.write_scalar(Scalar::from_target_isize(0, ecx), &dest) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
UnblockKind::TimedOut => { | ||||||
ecx.set_last_error_and_return(LibcError("ETIMEDOUT"), &dest) | ||||||
} | ||||||
} | ||||||
), | ||||||
); | ||||||
} else { | ||||||
// The futex value doesn't match the expected value, so we return failure | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -2,13 +2,21 @@ use rustc_middle::ty::Ty; | |||||||
use rustc_span::Symbol; | ||||||||
use rustc_target::callconv::{Conv, FnAbi}; | ||||||||
|
||||||||
use super::sync::EvalContextExt as _; | ||||||||
use super::sync::{EvalContextExt as _, MacOsFutexTimeout}; | ||||||||
use crate::helpers::check_min_arg_count; | ||||||||
use crate::shims::unix::*; | ||||||||
use crate::*; | ||||||||
|
||||||||
pub fn is_dyn_sym(_name: &str) -> bool { | ||||||||
false | ||||||||
pub fn is_dyn_sym(name: &str) -> bool { | ||||||||
match name { | ||||||||
// These only became available with macOS 11.0, so std looks them up dynamically. | ||||||||
"os_sync_wait_on_address" | ||||||||
| "os_sync_wait_on_address_with_deadline" | ||||||||
| "os_sync_wait_on_address_with_timeout" | ||||||||
| "os_sync_wake_by_address_any" | ||||||||
| "os_sync_wake_by_address_all" => true, | ||||||||
_ => false, | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {} | ||||||||
|
@@ -216,6 +224,53 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | |||||||
this.write_scalar(res, dest)?; | ||||||||
} | ||||||||
|
||||||||
"os_sync_wait_on_address" => { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
let [addr_op, value_op, size_op, flags_op] = | ||||||||
this.check_shim(abi, Conv::C, link_name, args)?; | ||||||||
this.os_sync_wait_on_address( | ||||||||
addr_op, | ||||||||
value_op, | ||||||||
size_op, | ||||||||
flags_op, | ||||||||
MacOsFutexTimeout::None, | ||||||||
dest, | ||||||||
)?; | ||||||||
} | ||||||||
"os_sync_wait_on_address_with_deadline" => { | ||||||||
let [addr_op, value_op, size_op, flags_op, clock_op, timeout_op] = | ||||||||
this.check_shim(abi, Conv::C, link_name, args)?; | ||||||||
this.os_sync_wait_on_address( | ||||||||
addr_op, | ||||||||
value_op, | ||||||||
size_op, | ||||||||
flags_op, | ||||||||
MacOsFutexTimeout::Absolute { clock_op, timeout_op }, | ||||||||
dest, | ||||||||
)?; | ||||||||
} | ||||||||
"os_sync_wait_on_address_with_timeout" => { | ||||||||
let [addr_op, value_op, size_op, flags_op, clock_op, timeout_op] = | ||||||||
this.check_shim(abi, Conv::C, link_name, args)?; | ||||||||
this.os_sync_wait_on_address( | ||||||||
addr_op, | ||||||||
value_op, | ||||||||
size_op, | ||||||||
flags_op, | ||||||||
MacOsFutexTimeout::Relative { clock_op, timeout_op }, | ||||||||
dest, | ||||||||
)?; | ||||||||
} | ||||||||
"os_sync_wake_by_address_any" => { | ||||||||
let [addr_op, size_op, flags_op] = | ||||||||
this.check_shim(abi, Conv::C, link_name, args)?; | ||||||||
this.os_sync_wake_by_address(addr_op, size_op, flags_op, false, dest)?; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
same thing a few lines below |
||||||||
} | ||||||||
"os_sync_wake_by_address_all" => { | ||||||||
let [addr_op, size_op, flags_op] = | ||||||||
this.check_shim(abi, Conv::C, link_name, args)?; | ||||||||
this.os_sync_wake_by_address(addr_op, size_op, flags_op, true, dest)?; | ||||||||
} | ||||||||
|
||||||||
"os_unfair_lock_lock" => { | ||||||||
let [lock_op] = this.check_shim(abi, Conv::C, link_name, args)?; | ||||||||
this.os_unfair_lock_lock(lock_op)?; | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the variables referenced here do not exist any more.