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] =
27 this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?;
28 let result = this.posix_memalign(memptr, align, size)?;
29 this.write_scalar(result, dest)?;
30 }
31 "aligned_alloc" => {
32 let [align, size] =
33 this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?;
34 let res = this.aligned_alloc(align, size)?;
35 this.write_pointer(res, dest)?;
36 }
37
38 _ => return interp_ok(EmulateItemResult::NotSupported),
39 }
40 interp_ok(EmulateItemResult::NeedsReturn)
41 }
42}