(
nfds: libc::c_int,
readfds: &mut FdSet,
writefds: &mut FdSet,
errfds: &mut FdSet,
timeout: Option<&mut timeval>,
)
| 172 | } |
| 173 | |
| 174 | pub fn select( |
| 175 | nfds: libc::c_int, |
| 176 | readfds: &mut FdSet, |
| 177 | writefds: &mut FdSet, |
| 178 | errfds: &mut FdSet, |
| 179 | timeout: Option<&mut timeval>, |
| 180 | ) -> io::Result<i32> { |
| 181 | let timeout = match timeout { |
| 182 | Some(tv) => tv as *mut timeval, |
| 183 | None => core::ptr::null_mut(), |
| 184 | }; |
| 185 | let ret = unsafe { |
| 186 | platform::select( |
| 187 | nfds, |
| 188 | readfds.0.as_mut_ptr(), |
| 189 | writefds.0.as_mut_ptr(), |
| 190 | errfds.0.as_mut_ptr(), |
| 191 | timeout, |
| 192 | ) |
| 193 | }; |
| 194 | if platform::check_err(ret) { |
| 195 | Err(io::Error::last_os_error()) |
| 196 | } else { |
| 197 | Ok(ret) |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | fn sec_to_timeval(sec: f64) -> timeval { |
| 202 | timeval { |
no test coverage detected