File tree 2 files changed +21
-0
lines changed
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
122
122
123
123
let sys_getrandom = this. eval_libc ( "SYS_getrandom" ) . to_target_usize ( this) ?;
124
124
let sys_futex = this. eval_libc ( "SYS_futex" ) . to_target_usize ( this) ?;
125
+ let sys_eventfd2 = this. eval_libc ( "SYS_eventfd2" ) . to_target_usize ( this) ?;
125
126
126
127
if args. is_empty ( ) {
127
128
throw_ub_format ! (
@@ -155,6 +156,17 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
155
156
id if id == sys_futex => {
156
157
futex ( this, & args[ 1 ..] , dest) ?;
157
158
}
159
+ id if id == sys_eventfd2 => {
160
+ let [ _, initval, flags, ..] = args else {
161
+ throw_ub_format ! (
162
+ "incorrect number of arguments for `eventfd2` syscall: got {}, expected at least 3" ,
163
+ args. len( )
164
+ ) ;
165
+ } ;
166
+
167
+ let result = this. eventfd ( initval, flags) ?;
168
+ this. write_int ( result. to_i32 ( ) ?, dest) ?;
169
+ }
158
170
id => {
159
171
this. handle_unsupported_foreign_item ( format ! (
160
172
"can't execute syscall with ID {id}"
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ use std::thread;
10
10
fn main ( ) {
11
11
test_read_write ( ) ;
12
12
test_race ( ) ;
13
+ test_syscall ( ) ;
13
14
}
14
15
15
16
fn read_bytes < const N : usize > ( fd : i32 , buf : & mut [ u8 ; N ] ) -> i32 {
@@ -109,3 +110,11 @@ fn test_race() {
109
110
thread:: yield_now ( ) ;
110
111
thread1. join ( ) . unwrap ( ) ;
111
112
}
113
+
114
+ // This is a test for calling eventfd2 through a syscall.
115
+ fn test_syscall ( ) {
116
+ let initval = 0 as libc:: c_uint ;
117
+ let flags = ( libc:: EFD_CLOEXEC | libc:: EFD_NONBLOCK ) as libc:: c_int ;
118
+ let fd = unsafe { libc:: syscall ( libc:: SYS_eventfd2 , initval, flags) } ;
119
+ assert_ne ! ( fd, -1 ) ;
120
+ }
You can’t perform that action at this time.
0 commit comments