Skip to content

Commit d001bd1

Browse files
authored
Merge pull request rust-lang#4136 from YohDeadfall/illumos-epoll-eventfd
Illumos: Added epoll and eventfd
2 parents f764a58 + 2bf8311 commit d001bd1

9 files changed

+41
-8
lines changed

Diff for: src/tools/miri/src/shims/unix/solarish/foreign_items.rs

+28
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use rustc_span::Symbol;
33
use rustc_target::callconv::{Conv, FnAbi};
44

55
use crate::shims::unix::foreign_items::EvalContextExt as _;
6+
use crate::shims::unix::linux_like::epoll::EvalContextExt as _;
7+
use crate::shims::unix::linux_like::eventfd::EvalContextExt as _;
68
use crate::shims::unix::*;
79
use crate::*;
810

@@ -21,6 +23,32 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
2123
) -> InterpResult<'tcx, EmulateItemResult> {
2224
let this = self.eval_context_mut();
2325
match link_name.as_str() {
26+
// epoll, eventfd (NOT available on Solaris!)
27+
"epoll_create1" => {
28+
this.assert_target_os("illumos", "epoll_create1");
29+
let [flag] = this.check_shim(abi, Conv::C, link_name, args)?;
30+
let result = this.epoll_create1(flag)?;
31+
this.write_scalar(result, dest)?;
32+
}
33+
"epoll_ctl" => {
34+
this.assert_target_os("illumos", "epoll_ctl");
35+
let [epfd, op, fd, event] = this.check_shim(abi, Conv::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+
this.assert_target_os("illumos", "epoll_wait");
41+
let [epfd, events, maxevents, timeout] =
42+
this.check_shim(abi, Conv::C, link_name, args)?;
43+
this.epoll_wait(epfd, events, maxevents, timeout, dest)?;
44+
}
45+
"eventfd" => {
46+
this.assert_target_os("illumos", "eventfd");
47+
let [val, flag] = this.check_shim(abi, Conv::C, link_name, args)?;
48+
let result = this.eventfd(val, flag)?;
49+
this.write_scalar(result, dest)?;
50+
}
51+
2452
// Threading
2553
"pthread_setname_np" => {
2654
let [thread, name] = this.check_shim(abi, Conv::C, link_name, args)?;

Diff for: src/tools/miri/tests/fail-dep/libc/eventfd_block_read_twice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@only-target: linux android
1+
//@only-target: linux android illumos
22
//~^ERROR: deadlocked
33
//~^^ERROR: deadlocked
44
//@compile-flags: -Zmiri-preemption-rate=0

Diff for: src/tools/miri/tests/fail-dep/libc/eventfd_block_write_twice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@only-target: linux android
1+
//@only-target: linux android illumos
22
//~^ERROR: deadlocked
33
//~^^ERROR: deadlocked
44
//@compile-flags: -Zmiri-preemption-rate=0

Diff for: src/tools/miri/tests/fail-dep/libc/libc-epoll-data-race.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! and we only read one of them, we do not synchronize with the other events
33
//! and therefore still report a data race for things that need to see the second event
44
//! to be considered synchronized.
5-
//@only-target: linux android
5+
//@only-target: linux android illumos
66
// ensure deterministic schedule
77
//@compile-flags: -Zmiri-preemption-rate=0
88

Diff for: src/tools/miri/tests/fail-dep/libc/libc_epoll_block_two_thread.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@compile-flags: -Zmiri-preemption-rate=0
22
//~^ERROR: deadlocked
33
//~^^ERROR: deadlocked
4-
//@only-target: linux
4+
//@only-target: linux android illumos
55
//@error-in-other-file: deadlock
66

77
use std::convert::TryInto;

Diff for: src/tools/miri/tests/fail-dep/libc/libc_epoll_unsupported_fd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@only-target: linux android
1+
//@only-target: linux android illumos
22

33
// This is a test for registering unsupported fd with epoll.
44
// Register epoll fd with epoll is allowed in real system, but we do not support this.

Diff for: src/tools/miri/tests/pass-dep/libc/libc-epoll-blocking.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@only-target: linux android
1+
//@only-target: linux android illumos
22
// test_epoll_block_then_unblock and test_epoll_race depend on a deterministic schedule.
33
//@compile-flags: -Zmiri-preemption-rate=0
44

Diff for: src/tools/miri/tests/pass-dep/libc/libc-epoll-no-blocking.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@only-target: linux android
1+
//@only-target: linux android illumos
22

33
use std::convert::TryInto;
44

Diff for: src/tools/miri/tests/pass-dep/libc/libc-eventfd.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@only-target: linux android
1+
//@only-target: linux android illumos
22
// test_race, test_blocking_read and test_blocking_write depend on a deterministic schedule.
33
//@compile-flags: -Zmiri-preemption-rate=0
44

@@ -10,7 +10,10 @@ use std::thread;
1010
fn main() {
1111
test_read_write();
1212
test_race();
13+
14+
#[cfg(not(target_os = "illumos"))]
1315
test_syscall();
16+
1417
test_blocking_read();
1518
test_blocking_write();
1619
test_two_threads_blocked_on_eventfd();
@@ -115,6 +118,8 @@ fn test_race() {
115118
}
116119

117120
// This is a test for calling eventfd2 through a syscall.
121+
// Illumos supports eventfd, but it has no entry to call it through syscall.
122+
#[cfg(not(target_os = "illumos"))]
118123
fn test_syscall() {
119124
let initval = 0 as libc::c_uint;
120125
let flags = (libc::EFD_CLOEXEC | libc::EFD_NONBLOCK) as libc::c_int;

0 commit comments

Comments
 (0)