panic if target platform is incorrect instead
This commit is contained in:
parent
c2bcab55b0
commit
208665836e
2 changed files with 15 additions and 16 deletions
|
|
@ -368,18 +368,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
/// Helper function used inside the shims of foreign functions to check that the target
|
||||
/// platform is `platform`. It returns an error using the `name` of the foreign function if
|
||||
/// this is not the case.
|
||||
fn check_platform(&mut self, platform: &str, name: &str) -> InterpResult<'tcx> {
|
||||
if self.eval_context_mut().tcx.sess.target.target.target_os.to_lowercase() != platform {
|
||||
throw_unsup_format!(
|
||||
"`{}` is only available on the `{}` platform",
|
||||
name,
|
||||
platform,
|
||||
)
|
||||
}
|
||||
Ok(())
|
||||
/// Helper function used inside the shims of foreign functions to assert that the target
|
||||
/// platform is `platform`. It panics showing a message with the `name` of the foreign function
|
||||
/// if this is not the case.
|
||||
fn assert_platform(&mut self, platform: &str, name: &str) {
|
||||
assert_eq!(
|
||||
self.eval_context_mut().tcx.sess.target.target.target_os.to_lowercase(),
|
||||
platform,
|
||||
"`{}` is only available on the `{}` platform",
|
||||
name,
|
||||
platform
|
||||
)
|
||||
}
|
||||
|
||||
/// Sets the last error variable.
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||
) -> InterpResult<'tcx, i32> {
|
||||
let this = self.eval_context_mut();
|
||||
this.check_no_isolation("stat")?;
|
||||
this.check_platform("macos", "stat")?;
|
||||
this.assert_platform("macos", "stat");
|
||||
// `stat` always follows symlinks.
|
||||
this.macos_stat_or_lstat(true, path_op, buf_op)
|
||||
}
|
||||
|
|
@ -360,7 +360,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||
) -> InterpResult<'tcx, i32> {
|
||||
let this = self.eval_context_mut();
|
||||
this.check_no_isolation("lstat")?;
|
||||
this.check_platform("macos", "lstat")?;
|
||||
this.assert_platform("macos", "lstat");
|
||||
this.macos_stat_or_lstat(false, path_op, buf_op)
|
||||
}
|
||||
|
||||
|
|
@ -372,7 +372,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||
let this = self.eval_context_mut();
|
||||
|
||||
this.check_no_isolation("fstat")?;
|
||||
this.check_platform("macos", "fstat")?;
|
||||
this.assert_platform("macos", "fstat");
|
||||
|
||||
let fd = this.read_scalar(fd_op)?.to_i32()?;
|
||||
|
||||
|
|
@ -416,7 +416,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||
let this = self.eval_context_mut();
|
||||
|
||||
this.check_no_isolation("statx")?;
|
||||
this.check_platform("linux", "statx")?;
|
||||
this.assert_platform("linux", "statx");
|
||||
|
||||
let statxbuf_scalar = this.read_scalar(statxbuf_op)?.not_undef()?;
|
||||
let pathname_scalar = this.read_scalar(pathname_op)?.not_undef()?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue