summaryrefslogtreecommitdiff
path: root/src/unix/redox/mod.rs
diff options
context:
space:
mode:
authorcoolreader18 <33094578+coolreader18@users.noreply.github.com>2019-12-07 22:31:45 -0600
committercoolreader18 <33094578+coolreader18@users.noreply.github.com>2019-12-08 22:10:06 -0600
commitaa6f5e2b38dc1d70b8b79543f4b84bb97856c92f (patch)
treef4e0b714429fae9f8e1b141361f53480adb3dbc7 /src/unix/redox/mod.rs
parent6eca76726bae6ebe4e30350cd8c760a42109b241 (diff)
downloadrust-libc-aa6f5e2b38dc1d70b8b79543f4b84bb97856c92f.tar.gz
Add FD_* functions/macros for redox; implementations copied from linux_like
Diffstat (limited to 'src/unix/redox/mod.rs')
-rw-r--r--src/unix/redox/mod.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs
index b00a191c9b..4ea52e3798 100644
--- a/src/unix/redox/mod.rs
+++ b/src/unix/redox/mod.rs
@@ -839,6 +839,32 @@ f! {
pub fn WCOREDUMP(status: ::c_int) -> bool {
(status & 0x80) != 0
}
+
+ pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
+ let fd = fd as usize;
+ let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
+ (*set).fds_bits[fd / size] &= !(1 << (fd % size));
+ return
+ }
+
+ pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
+ let fd = fd as usize;
+ let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
+ return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0
+ }
+
+ pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
+ let fd = fd as usize;
+ let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
+ (*set).fds_bits[fd / size] |= 1 << (fd % size);
+ return
+ }
+
+ pub fn FD_ZERO(set: *mut fd_set) -> () {
+ for slot in (*set).fds_bits.iter_mut() {
+ *slot = 0;
+ }
+ }
}
extern "C" {