Merge pull request #4000 from noahmbright/futex

Change futex_wait errno from Scalar to IoError
This commit is contained in:
Ralf Jung 2024-10-30 18:50:54 +00:00 committed by GitHub
commit 4ca9c07ef2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 18 additions and 4 deletions

View File

@ -696,7 +696,7 @@ fn futex_wait(
retval_succ: Scalar, retval_succ: Scalar,
retval_timeout: Scalar, retval_timeout: Scalar,
dest: MPlaceTy<'tcx>, dest: MPlaceTy<'tcx>,
errno_timeout: Scalar, errno_timeout: IoError,
) { ) {
let this = self.eval_context_mut(); let this = self.eval_context_mut();
let thread = this.active_thread(); let thread = this.active_thread();
@ -713,7 +713,7 @@ fn futex_wait(
retval_succ: Scalar, retval_succ: Scalar,
retval_timeout: Scalar, retval_timeout: Scalar,
dest: MPlaceTy<'tcx>, dest: MPlaceTy<'tcx>,
errno_timeout: Scalar, errno_timeout: IoError,
} }
@unblock = |this| { @unblock = |this| {
let futex = this.machine.sync.futexes.get(&addr).unwrap(); let futex = this.machine.sync.futexes.get(&addr).unwrap();

View File

@ -89,6 +89,18 @@ fn visit_provenance(&self, visit: &mut VisitWith<'_>) {
} }
} }
impl VisitProvenance for IoError {
fn visit_provenance(&self, visit: &mut VisitWith<'_>) {
use crate::shims::io_error::IoError::*;
match self {
LibcError(_name) => (),
WindowsError(_name) => (),
HostError(_io_error) => (),
Raw(scalar) => scalar.visit_provenance(visit),
}
}
}
impl VisitProvenance for Immediate<Provenance> { impl VisitProvenance for Immediate<Provenance> {
fn visit_provenance(&self, visit: &mut VisitWith<'_>) { fn visit_provenance(&self, visit: &mut VisitWith<'_>) {
match self { match self {

View File

@ -7,6 +7,7 @@
#[derive(Debug)] #[derive(Debug)]
pub enum IoError { pub enum IoError {
LibcError(&'static str), LibcError(&'static str),
WindowsError(&'static str),
HostError(io::Error), HostError(io::Error),
Raw(Scalar), Raw(Scalar),
} }
@ -113,6 +114,7 @@ fn set_last_error(&mut self, err: impl Into<IoError>) -> InterpResult<'tcx> {
let errno = match err.into() { let errno = match err.into() {
HostError(err) => this.io_error_to_errnum(err)?, HostError(err) => this.io_error_to_errnum(err)?,
LibcError(name) => this.eval_libc(name), LibcError(name) => this.eval_libc(name),
WindowsError(name) => this.eval_windows("c", name),
Raw(val) => val, Raw(val) => val,
}; };
let errno_place = this.last_error_place()?; let errno_place = this.last_error_place()?;

View File

@ -150,7 +150,7 @@ pub fn futex<'tcx>(
Scalar::from_target_isize(0, this), // retval_succ Scalar::from_target_isize(0, this), // retval_succ
Scalar::from_target_isize(-1, this), // retval_timeout Scalar::from_target_isize(-1, this), // retval_timeout
dest.clone(), dest.clone(),
this.eval_libc("ETIMEDOUT"), // errno_timeout LibcError("ETIMEDOUT"), // errno_timeout
); );
} else { } else {
// The futex value doesn't match the expected value, so we return failure // The futex value doesn't match the expected value, so we return failure

View File

@ -202,7 +202,7 @@ fn WaitOnAddress(
Scalar::from_i32(1), // retval_succ Scalar::from_i32(1), // retval_succ
Scalar::from_i32(0), // retval_timeout Scalar::from_i32(0), // retval_timeout
dest.clone(), dest.clone(),
this.eval_windows("c", "ERROR_TIMEOUT"), // errno_timeout IoError::WindowsError("ERROR_TIMEOUT"), // errno_timeout
); );
} }