Illumos: Added epoll and eventfd
This commit is contained in:
parent
f764a581b7
commit
498ea324e3
9 changed files with 41 additions and 8 deletions
|
|
@ -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)?;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
//@only-target: linux android
|
||||
//@only-target: linux android illumos
|
||||
//~^ERROR: deadlocked
|
||||
//~^^ERROR: deadlocked
|
||||
//@compile-flags: -Zmiri-preemption-rate=0
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
//@only-target: linux android
|
||||
//@only-target: linux android illumos
|
||||
//~^ERROR: deadlocked
|
||||
//~^^ERROR: deadlocked
|
||||
//@compile-flags: -Zmiri-preemption-rate=0
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//@compile-flags: -Zmiri-preemption-rate=0
|
||||
//~^ERROR: deadlocked
|
||||
//~^^ERROR: deadlocked
|
||||
//@only-target: linux
|
||||
//@only-target: linux illumos
|
||||
//@error-in-other-file: deadlock
|
||||
|
||||
use std::convert::TryInto;
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
//@only-target: linux android
|
||||
//@only-target: linux android illumos
|
||||
|
||||
use std::convert::TryInto;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue