Merge pull request #52 from alexcrichton/bytes-bits

There are 8 bits in a byte
This commit is contained in:
Alex Crichton 2015-11-10 08:55:01 -08:00
commit a224b1770e

View File

@ -324,20 +324,20 @@ pub const FD_SETSIZE: usize = 1024;
f! {
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]);
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]);
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]);
let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
(*set).fds_bits[fd / size] |= 1 << (fd % size);
return
}