miri/shims/wasi/
foreign_items.rs1use rustc_abi::CanonAbi;
2use rustc_middle::ty::Ty;
3use rustc_span::Symbol;
4use rustc_target::callconv::FnAbi;
5
6use crate::shims::alloc::EvalContextExt as _;
7use crate::*;
8
9pub fn is_dyn_sym(_name: &str) -> bool {
10 false
11}
12
13impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
14pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
15 fn emulate_foreign_item_inner(
16 &mut self,
17 link_name: Symbol,
18 abi: &FnAbi<'tcx, Ty<'tcx>>,
19 args: &[OpTy<'tcx>],
20 dest: &MPlaceTy<'tcx>,
21 ) -> InterpResult<'tcx, EmulateItemResult> {
22 let this = self.eval_context_mut();
23 match link_name.as_str() {
24 "posix_memalign" => {
26 let [memptr, align, size] = this.check_shim(abi, CanonAbi::C, link_name, args)?;
27 let result = this.posix_memalign(memptr, align, size)?;
28 this.write_scalar(result, dest)?;
29 }
30 "aligned_alloc" => {
31 let [align, size] = this.check_shim(abi, CanonAbi::C, link_name, args)?;
32 let res = this.aligned_alloc(align, size)?;
33 this.write_pointer(res, dest)?;
34 }
35
36 _ => return interp_ok(EmulateItemResult::NotSupported),
37 }
38 interp_ok(EmulateItemResult::NeedsReturn)
39 }
40}