1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
use crate::ocall::util::*;
use libc::{self, c_int, c_uint, epoll_event, nfds_t, pollfd};
use std::io::Error;
#[no_mangle]
pub unsafe extern "C" fn u_poll_ocall(
error: *mut c_int,
fds: *mut pollfd,
nfds: nfds_t,
timeout: c_int,
) -> c_int {
let mut errno = 0;
let ret = libc::poll(fds, nfds, timeout);
if ret < 0 {
errno = Error::last_os_error().raw_os_error().unwrap_or(0);
}
set_error(error, errno);
ret
}
#[no_mangle]
pub unsafe extern "C" fn u_epoll_create1_ocall(error: *mut c_int, flags: c_int) -> c_int {
let mut errno = 0;
let ret = libc::epoll_create1(flags);
if ret < 0 {
errno = Error::last_os_error().raw_os_error().unwrap_or(0);
}
set_error(error, errno);
ret
}
#[no_mangle]
pub unsafe extern "C" fn u_epoll_ctl_ocall(
error: *mut c_int,
epfd: c_int,
op: c_int,
fd: c_int,
event: *mut epoll_event,
) -> c_int {
let mut errno = 0;
let ret = libc::epoll_ctl(epfd, op, fd, event);
if ret < 0 {
errno = Error::last_os_error().raw_os_error().unwrap_or(0);
}
set_error(error, errno);
ret
}
#[no_mangle]
pub unsafe extern "C" fn u_epoll_wait_ocall(
error: *mut c_int,
epfd: c_int,
events: *mut epoll_event,
maxevents: c_uint,
timeout: c_int,
) -> c_int {
let mut errno = 0;
let ret = libc::epoll_wait(epfd, events, maxevents as c_int, timeout);
if ret < 0 {
errno = Error::last_os_error().raw_os_error().unwrap_or(0);
}
set_error(error, errno);
ret
}