diff --git a/src/shims/unix/solarish/foreign_items.rs b/src/shims/unix/solarish/foreign_items.rs index 98909d86c8..f94783a390 100644 --- a/src/shims/unix/solarish/foreign_items.rs +++ b/src/shims/unix/solarish/foreign_items.rs @@ -3,6 +3,8 @@ use rustc_span::Symbol; use rustc_target::callconv::{Conv, FnAbi}; use crate::shims::unix::foreign_items::EvalContextExt as _; +use crate::shims::unix::linux_like::epoll::EvalContextExt as _; +use crate::shims::unix::linux_like::eventfd::EvalContextExt as _; use crate::shims::unix::*; use crate::*; @@ -21,6 +23,32 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { ) -> InterpResult<'tcx, EmulateItemResult> { let this = self.eval_context_mut(); match link_name.as_str() { + // epoll, eventfd (NOT available on Solaris!) + "epoll_create1" => { + this.assert_target_os("illumos", "epoll_create1"); + let [flag] = this.check_shim(abi, Conv::C, link_name, args)?; + let result = this.epoll_create1(flag)?; + this.write_scalar(result, dest)?; + } + "epoll_ctl" => { + this.assert_target_os("illumos", "epoll_ctl"); + let [epfd, op, fd, event] = this.check_shim(abi, Conv::C, link_name, args)?; + let result = this.epoll_ctl(epfd, op, fd, event)?; + this.write_scalar(result, dest)?; + } + "epoll_wait" => { + this.assert_target_os("illumos", "epoll_wait"); + let [epfd, events, maxevents, timeout] = + this.check_shim(abi, Conv::C, link_name, args)?; + this.epoll_wait(epfd, events, maxevents, timeout, dest)?; + } + "eventfd" => { + this.assert_target_os("illumos", "eventfd"); + let [val, flag] = this.check_shim(abi, Conv::C, link_name, args)?; + let result = this.eventfd(val, flag)?; + this.write_scalar(result, dest)?; + } + // Threading "pthread_setname_np" => { let [thread, name] = this.check_shim(abi, Conv::C, link_name, args)?; diff --git a/tests/fail-dep/libc/eventfd_block_read_twice.rs b/tests/fail-dep/libc/eventfd_block_read_twice.rs index 5b0e106e03..0d893663fd 100644 --- a/tests/fail-dep/libc/eventfd_block_read_twice.rs +++ b/tests/fail-dep/libc/eventfd_block_read_twice.rs @@ -1,4 +1,4 @@ -//@only-target: linux android +//@only-target: linux android illumos //~^ERROR: deadlocked //~^^ERROR: deadlocked //@compile-flags: -Zmiri-preemption-rate=0 diff --git a/tests/fail-dep/libc/eventfd_block_write_twice.rs b/tests/fail-dep/libc/eventfd_block_write_twice.rs index bae1ec700b..9fed47c17d 100644 --- a/tests/fail-dep/libc/eventfd_block_write_twice.rs +++ b/tests/fail-dep/libc/eventfd_block_write_twice.rs @@ -1,4 +1,4 @@ -//@only-target: linux android +//@only-target: linux android illumos //~^ERROR: deadlocked //~^^ERROR: deadlocked //@compile-flags: -Zmiri-preemption-rate=0 diff --git a/tests/fail-dep/libc/libc-epoll-data-race.rs b/tests/fail-dep/libc/libc-epoll-data-race.rs index 7bef687e33..45f6bf6da0 100644 --- a/tests/fail-dep/libc/libc-epoll-data-race.rs +++ b/tests/fail-dep/libc/libc-epoll-data-race.rs @@ -2,7 +2,7 @@ //! and we only read one of them, we do not synchronize with the other events //! and therefore still report a data race for things that need to see the second event //! to be considered synchronized. -//@only-target: linux android +//@only-target: linux android illumos // ensure deterministic schedule //@compile-flags: -Zmiri-preemption-rate=0 diff --git a/tests/fail-dep/libc/libc_epoll_block_two_thread.rs b/tests/fail-dep/libc/libc_epoll_block_two_thread.rs index 1c6c2f70c1..059b24cb8c 100644 --- a/tests/fail-dep/libc/libc_epoll_block_two_thread.rs +++ b/tests/fail-dep/libc/libc_epoll_block_two_thread.rs @@ -1,7 +1,7 @@ //@compile-flags: -Zmiri-preemption-rate=0 //~^ERROR: deadlocked //~^^ERROR: deadlocked -//@only-target: linux +//@only-target: linux android illumos //@error-in-other-file: deadlock use std::convert::TryInto; diff --git a/tests/fail-dep/libc/libc_epoll_unsupported_fd.rs b/tests/fail-dep/libc/libc_epoll_unsupported_fd.rs index 22f3708ee0..59cf0fc2ba 100644 --- a/tests/fail-dep/libc/libc_epoll_unsupported_fd.rs +++ b/tests/fail-dep/libc/libc_epoll_unsupported_fd.rs @@ -1,4 +1,4 @@ -//@only-target: linux android +//@only-target: linux android illumos // This is a test for registering unsupported fd with epoll. // Register epoll fd with epoll is allowed in real system, but we do not support this. diff --git a/tests/pass-dep/libc/libc-epoll-blocking.rs b/tests/pass-dep/libc/libc-epoll-blocking.rs index e3c42b2701..825e135584 100644 --- a/tests/pass-dep/libc/libc-epoll-blocking.rs +++ b/tests/pass-dep/libc/libc-epoll-blocking.rs @@ -1,4 +1,4 @@ -//@only-target: linux android +//@only-target: linux android illumos // test_epoll_block_then_unblock and test_epoll_race depend on a deterministic schedule. //@compile-flags: -Zmiri-preemption-rate=0 diff --git a/tests/pass-dep/libc/libc-epoll-no-blocking.rs b/tests/pass-dep/libc/libc-epoll-no-blocking.rs index 111e639c86..23e2122ee5 100644 --- a/tests/pass-dep/libc/libc-epoll-no-blocking.rs +++ b/tests/pass-dep/libc/libc-epoll-no-blocking.rs @@ -1,4 +1,4 @@ -//@only-target: linux android +//@only-target: linux android illumos use std::convert::TryInto; diff --git a/tests/pass-dep/libc/libc-eventfd.rs b/tests/pass-dep/libc/libc-eventfd.rs index 2e453215ec..30e1bbb8fa 100644 --- a/tests/pass-dep/libc/libc-eventfd.rs +++ b/tests/pass-dep/libc/libc-eventfd.rs @@ -1,4 +1,4 @@ -//@only-target: linux android +//@only-target: linux android illumos // test_race, test_blocking_read and test_blocking_write depend on a deterministic schedule. //@compile-flags: -Zmiri-preemption-rate=0 @@ -10,7 +10,10 @@ use std::thread; fn main() { test_read_write(); test_race(); + + #[cfg(not(target_os = "illumos"))] test_syscall(); + test_blocking_read(); test_blocking_write(); test_two_threads_blocked_on_eventfd(); @@ -115,6 +118,8 @@ fn test_race() { } // This is a test for calling eventfd2 through a syscall. +// Illumos supports eventfd, but it has no entry to call it through syscall. +#[cfg(not(target_os = "illumos"))] fn test_syscall() { let initval = 0 as libc::c_uint; let flags = (libc::EFD_CLOEXEC | libc::EFD_NONBLOCK) as libc::c_int;