Skip to content

Commit f41beca

Browse files
authored
Add eventfd rules (#200)
1 parent 893e68d commit f41beca

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

rules/eventfd/src.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#define _GNU_SOURCE
2+
3+
#ifdef __linux__
4+
#include <sys/eventfd.h>
5+
6+
int f1() {
7+
return EFD_CLOEXEC;
8+
}
9+
10+
int f2() {
11+
return EFD_NONBLOCK;
12+
}
13+
14+
int f3() {
15+
return EFD_SEMAPHORE;
16+
}
17+
18+
int f4(unsigned int initval, int flags) {
19+
return eventfd(initval, flags);
20+
}
21+
#endif

rules/eventfd/tgt_unsafe.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#[cfg(target_os = "linux")]
2+
unsafe fn f1() -> i32 {
3+
libc::EFD_CLOEXEC
4+
}
5+
6+
#[cfg(target_os = "linux")]
7+
unsafe fn f2() -> i32 {
8+
libc::EFD_NONBLOCK
9+
}
10+
11+
#[cfg(target_os = "linux")]
12+
unsafe fn f3() -> i32 {
13+
libc::EFD_SEMAPHORE
14+
}
15+
16+
#[cfg(target_os = "linux")]
17+
unsafe fn f4(a0: u32, a1: i32) -> i32 {
18+
libc::eventfd(a0, a1)
19+
}

rules/src/modules.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ pub mod deque_tgt_unsafe;
4040
pub mod dirent_tgt_unsafe;
4141
#[path = r#"../errno/tgt_unsafe.rs"#]
4242
pub mod errno_tgt_unsafe;
43+
#[path = r#"../eventfd/tgt_unsafe.rs"#]
44+
pub mod eventfd_tgt_unsafe;
4345
#[path = r#"../fnmatch/tgt_unsafe.rs"#]
4446
pub mod fnmatch_tgt_unsafe;
4547
#[path = r#"../fstream/tgt_refcount.rs"#]

0 commit comments

Comments
 (0)