File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ use libc:: { c_int, c_uint} ;
2
+ use fcntl:: Fd ;
3
+ use errno:: { SysResult , SysError , from_ffi} ;
4
+
5
+ mod ffi {
6
+ use libc:: { c_int, c_uint} ;
7
+
8
+ extern {
9
+ pub fn eventfd ( initval : c_uint , flags : c_int ) -> c_int ;
10
+ }
11
+ }
12
+
13
+ bitflags ! (
14
+ flags EventFdFlag : c_int {
15
+ static EFD_CLOEXEC = 0o2000000 , // Since Linux 2.6.27
16
+ static EFD_NONBLOCK = 0o0004000 , // Since Linux 2.6.27
17
+ static EFD_SEMAPHORE = 0o0000001 , // Since Linux 2.6.30
18
+ }
19
+ )
20
+
21
+ pub fn eventfd ( initval : uint , flags : EventFdFlag ) -> SysResult < Fd > {
22
+ let res = unsafe { ffi:: eventfd ( initval as c_uint , flags. bits ( ) ) } ;
23
+
24
+ if res < 0 {
25
+ return Err ( SysError :: last ( ) ) ;
26
+ }
27
+
28
+ Ok ( res)
29
+ }
Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ pub mod epoll;
6
6
#[ cfg( target_os = "ios" ) ]
7
7
pub mod event;
8
8
9
+ #[ cfg( target_os = "linux" ) ]
10
+ pub mod eventfd;
11
+
9
12
#[ cfg( target_os = "linux" ) ]
10
13
#[ cfg( target_os = "macos" ) ]
11
14
#[ cfg( target_os = "ios" ) ]
You can’t perform that action at this time.
0 commit comments