open_coroutine_hooks/unix/
common.rs

1use libc::{c_int, fd_set, nfds_t, pollfd, timeval};
2use once_cell::sync::Lazy;
3
4static POLL: Lazy<extern "C" fn(*mut pollfd, nfds_t, c_int) -> c_int> = init_hook!("poll");
5
6#[no_mangle]
7pub extern "C" fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: c_int) -> c_int {
8    open_coroutine_core::syscall::poll(Some(Lazy::force(&POLL)), fds, nfds, timeout)
9}
10
11static SELECT: Lazy<
12    extern "C" fn(c_int, *mut fd_set, *mut fd_set, *mut fd_set, *mut timeval) -> c_int,
13> = init_hook!("select");
14
15#[no_mangle]
16pub extern "C" fn select(
17    nfds: c_int,
18    readfds: *mut fd_set,
19    writefds: *mut fd_set,
20    errorfds: *mut fd_set,
21    timeout: *mut timeval,
22) -> c_int {
23    open_coroutine_core::syscall::select(
24        Some(Lazy::force(&SELECT)),
25        nfds,
26        readfds,
27        writefds,
28        errorfds,
29        timeout,
30    )
31}