Skip to content

Commit da77926

Browse files
committed
Added epoll and eventfd for Android
1 parent 1c6bfbb commit da77926

File tree

7 files changed

+32
-4
lines changed

7 files changed

+32
-4
lines changed

ci/ci.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ case $HOST_TARGET in
154154
TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC $UNIX time hashmap random threadname pthread fs libc-pipe
155155
TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX time hashmap random thread sync available-parallelism tls libc-pipe
156156
TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX time hashmap random thread sync available-parallelism tls libc-pipe
157-
TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX time hashmap random sync threadname pthread
157+
TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX time hashmap random sync threadname pthread epoll eventfd
158158
TEST_TARGET=wasm32-wasip2 run_tests_minimal $BASIC wasm
159159
TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std empty_main wasm # this target doesn't really have std
160160
TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std

src/shims/unix/android/foreign_items.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use rustc_abi::ExternAbi;
22
use rustc_span::Symbol;
33

4+
use self::shims::unix::linux::epoll::EvalContextExt as _;
5+
use self::shims::unix::linux::eventfd::EvalContextExt as _;
46
use crate::shims::unix::android::thread::prctl;
57
use crate::shims::unix::linux::syscall::syscall;
68
use crate::*;
@@ -20,6 +22,31 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
2022
) -> InterpResult<'tcx, EmulateItemResult> {
2123
let this = self.eval_context_mut();
2224
match link_name.as_str() {
25+
// epoll, eventfd
26+
"epoll_create1" => {
27+
let [flag] =
28+
this.check_shim(abi, ExternAbi::C { unwind: false }, 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] =
34+
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
35+
let result = this.epoll_ctl(epfd, op, fd, event)?;
36+
this.write_scalar(result, dest)?;
37+
}
38+
"epoll_wait" => {
39+
let [epfd, events, maxevents, timeout] =
40+
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
41+
this.epoll_wait(epfd, events, maxevents, timeout, dest)?;
42+
}
43+
"eventfd" => {
44+
let [val, flag] =
45+
this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;
46+
let result = this.eventfd(val, flag)?;
47+
this.write_scalar(result, dest)?;
48+
}
49+
2350
// Miscellaneous
2451
"__errno" => {
2552
let [] = this.check_shim(abi, ExternAbi::C { unwind: false }, link_name, args)?;

src/shims/unix/linux/eventfd.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
144144
fn eventfd(&mut self, val: &OpTy<'tcx>, flags: &OpTy<'tcx>) -> InterpResult<'tcx, Scalar> {
145145
let this = self.eval_context_mut();
146146

147-
// eventfd is Linux specific.
148-
this.assert_target_os("linux", "eventfd");
149-
150147
let val = this.read_scalar(val)?.to_u32()?;
151148
let mut flags = this.read_scalar(flags)?.to_i32()?;
152149

tests/fail-dep/libc/libc-epoll-data-race.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//! and therefore still report a data race for things that need to see the second event
44
//! to be considered synchronized.
55
//@only-target: linux
6+
//@only-target: android
67
// ensure deterministic schedule
78
//@compile-flags: -Zmiri-preemption-rate=0
89

tests/pass-dep/libc/libc-epoll-blocking.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@only-target: linux
2+
//@only-target: android
23
// test_epoll_block_then_unblock and test_epoll_race depend on a deterministic schedule.
34
//@compile-flags: -Zmiri-preemption-rate=0
45

tests/pass-dep/libc/libc-epoll-no-blocking.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@only-target: linux
2+
//@only-target: android
23

34
use std::convert::TryInto;
45

tests/pass-dep/libc/libc-eventfd.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@only-target: linux
2+
//@only-target: android
23
// test_race, test_blocking_read and test_blocking_write depend on a deterministic schedule.
34
//@compile-flags: -Zmiri-preemption-rate=0
45

0 commit comments

Comments
 (0)