Skip to content

Commit

Permalink
FD_ISSET: take a *const fd_set instead of *mut fd_set
Browse files Browse the repository at this point in the history
FD_ISSET does not modify its fd_set argument, so it may as well take a
const pointer.  AFAICT the only reason to take a *mut pointer is because
the Linux man page documents it that way (though since glibc implements
it as a macro, the constedness is undefined).  But since libc implements
it directly rather than calling a (nonexistent on most platforms) C
function, we're defining the API ourselves.
  • Loading branch information
asomers-ax authored and asomers committed Jul 13, 2021
1 parent 13c8ceb commit 3eafb3b
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/fuchsia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3158,7 +3158,7 @@ f! {
return
}

pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
pub fn FD_ISSET(fd: ::c_int, set: *const 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
Expand Down
2 changes: 1 addition & 1 deletion src/unix/bsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ f! {
return
}

pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
pub fn FD_ISSET(fd: ::c_int, set: *const fd_set) -> bool {
let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
let fd = fd as usize;
return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0
Expand Down
2 changes: 1 addition & 1 deletion src/unix/haiku/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ f! {
return
}

pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
pub fn FD_ISSET(fd: ::c_int, set: *const 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
Expand Down
2 changes: 1 addition & 1 deletion src/unix/linux_like/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,7 @@ f! {
return
}

pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
pub fn FD_ISSET(fd: ::c_int, set: *const 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
Expand Down
2 changes: 1 addition & 1 deletion src/unix/newlib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ f! {
return
}

pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
pub fn FD_ISSET(fd: ::c_int, set: *const fd_set) -> bool {
let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
let fd = fd as usize;
return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0
Expand Down
2 changes: 1 addition & 1 deletion src/unix/redox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ f! {
return
}

pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
pub fn FD_ISSET(fd: ::c_int, set: *const 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
Expand Down
2 changes: 1 addition & 1 deletion src/unix/solarish/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2171,7 +2171,7 @@ f! {
return
}

pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
pub fn FD_ISSET(fd: ::c_int, set: *const fd_set) -> bool {
let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
let fd = fd as usize;
return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0
Expand Down

0 comments on commit 3eafb3b

Please sign in to comment.