};
// Next: functions that return.
- match link_name {
- "__rust_maybe_catch_panic" => {
- this.handle_catch_panic(args, dest, ret)?;
- return Ok(None);
- }
-
- _ => this.emulate_foreign_item_by_name(link_name, args, dest)?,
- };
-
- this.dump_place(*dest);
- this.go_to_block(ret);
+ if this.emulate_foreign_item_by_name(link_name, args, dest, ret)? {
+ this.dump_place(*dest);
+ this.go_to_block(ret);
+ }
Ok(None)
}
link_name: &str,
args: &[OpTy<'tcx, Tag>],
dest: PlaceTy<'tcx, Tag>,
- ) -> InterpResult<'tcx> {
+ ret: mir::BasicBlock,
+ ) -> InterpResult<'tcx, bool> {
let this = self.eval_context_mut();
// Here we dispatch all the shims for foreign functions. If you have a platform specific
this.write_scalar(new_ptr, dest)?;
}
+ "__rust_maybe_catch_panic" => {
+ this.handle_catch_panic(args, dest, ret)?;
+ return Ok(false);
+ }
+
"memcmp" => {
let left = this.read_scalar(args[0])?.not_undef()?;
let right = this.read_scalar(args[1])?.not_undef()?;
}
}
-
- "rename" => {
- let result = this.rename(args[0], args[1])?;
- this.write_scalar(Scalar::from_int(result, dest.layout.size), dest)?;
- }
-
"strlen" => {
let ptr = this.read_scalar(args[0])?.not_undef()?;
let n = this.memory.read_c_str(ptr)?.len();
}
_ => match this.tcx.sess.target.target.target_os.to_lowercase().as_str() {
- "linux" | "macos" => posix::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest)?,
- "windows" => windows::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest)?,
+ "linux" | "macos" => return posix::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret),
+ "windows" => return windows::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret),
target => throw_unsup_format!("The {} target platform is not supported", target),
}
};
- Ok(())
+ Ok(true)
}
/// Evaluates the scalar at the specified path. Returns Some(val)
mod macos;
use crate::*;
+use rustc::mir;
use rustc::ty::layout::{Align, LayoutOf, Size};
impl<'mir, 'tcx> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {}
link_name: &str,
args: &[OpTy<'tcx, Tag>],
dest: PlaceTy<'tcx, Tag>,
- ) -> InterpResult<'tcx> {
+ ret: mir::BasicBlock,
+ ) -> InterpResult<'tcx, bool> {
let this = self.eval_context_mut();
let tcx = &{ this.tcx.tcx };
this.write_scalar(Scalar::from_int(result, dest.layout.size), dest)?;
}
+ "rename" => {
+ let result = this.rename(args[0], args[1])?;
+ this.write_scalar(Scalar::from_int(result, dest.layout.size), dest)?;
+ }
+
"posix_memalign" => {
let ret = this.deref_operand(args[0])?;
let align = this.read_scalar(args[1])?.to_machine_usize(this)?;
_ => {
match this.tcx.sess.target.target.target_os.to_lowercase().as_str() {
- "linux" => linux::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest)?,
- "macos" => macos::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest)?,
+ "linux" => return linux::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret),
+ "macos" => return macos::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret),
_ => unreachable!(),
}
}
};
- Ok(())
+ Ok(true)
}
}
use crate::*;
+use rustc::mir;
impl<'mir, 'tcx> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {}
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx> {
link_name: &str,
args: &[OpTy<'tcx, Tag>],
dest: PlaceTy<'tcx, Tag>,
- ) -> InterpResult<'tcx> {
+ _ret: mir::BasicBlock,
+ ) -> InterpResult<'tcx, bool> {
let this = self.eval_context_mut();
match link_name {
_ => throw_unsup_format!("can't call foreign function: {}", link_name),
};
- Ok(())
+ Ok(true)
}
}
use crate::*;
+use rustc::mir;
impl<'mir, 'tcx> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {}
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx> {
link_name: &str,
args: &[OpTy<'tcx, Tag>],
dest: PlaceTy<'tcx, Tag>,
- ) -> InterpResult<'tcx> {
+ _ret: mir::BasicBlock,
+ ) -> InterpResult<'tcx, bool> {
let this = self.eval_context_mut();
match link_name {
_ => throw_unsup_format!("can't call foreign function: {}", link_name),
};
- Ok(())
+ Ok(true)
}
}
use crate::*;
+use rustc::mir;
use rustc::ty::layout::Size;
use std::iter;
link_name: &str,
args: &[OpTy<'tcx, Tag>],
dest: PlaceTy<'tcx, Tag>,
- ) -> InterpResult<'tcx> {
+ _ret: mir::BasicBlock,
+ ) -> InterpResult<'tcx, bool> {
let this = self.eval_context_mut();
let tcx = &{ this.tcx.tcx };
_ => throw_unsup_format!("can't call foreign function: {}", link_name),
}
- Ok(())
+ Ok(true)
}
}