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