miri/shims/unix/android/
foreign_items.rs1use rustc_abi::CanonAbi;
2use rustc_middle::ty::Ty;
3use rustc_span::Symbol;
4use rustc_target::callconv::FnAbi;
5
6use crate::shims::unix::android::thread::prctl;
7use crate::shims::unix::linux_like::epoll::EvalContextExt as _;
8use crate::shims::unix::linux_like::eventfd::EvalContextExt as _;
9use crate::shims::unix::linux_like::syscall::syscall;
10use crate::*;
11
12pub fn is_dyn_sym(_name: &str) -> bool {
13 false
14}
15
16impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
17pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
18 fn emulate_foreign_item_inner(
19 &mut self,
20 link_name: Symbol,
21 abi: &FnAbi<'tcx, Ty<'tcx>>,
22 args: &[OpTy<'tcx>],
23 dest: &MPlaceTy<'tcx>,
24 ) -> InterpResult<'tcx, EmulateItemResult> {
25 let this = self.eval_context_mut();
26 match link_name.as_str() {
27 "epoll_create1" => {
29 let [flag] = this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?;
30 let result = this.epoll_create1(flag)?;
31 this.write_scalar(result, dest)?;
32 }
33 "epoll_ctl" => {
34 let [epfd, op, fd, event] =
35 this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?;
36 let result = this.epoll_ctl(epfd, op, fd, event)?;
37 this.write_scalar(result, dest)?;
38 }
39 "epoll_wait" => {
40 let [epfd, events, maxevents, timeout] =
41 this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?;
42 this.epoll_wait(epfd, events, maxevents, timeout, dest)?;
43 }
44 "eventfd" => {
45 let [val, flag] = this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?;
46 let result = this.eventfd(val, flag)?;
47 this.write_scalar(result, dest)?;
48 }
49
50 "__errno" => {
52 let [] = this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?;
53 let errno_place = this.last_error_place()?;
54 this.write_scalar(errno_place.to_ref(this).to_scalar(), dest)?;
55 }
56
57 "syscall" => syscall(this, link_name, abi, args, dest)?,
59
60 "prctl" => prctl(this, link_name, abi, args, dest)?,
62
63 _ => return interp_ok(EmulateItemResult::NotSupported),
64 }
65 interp_ok(EmulateItemResult::NeedsReturn)
66 }
67}