Skip to content

Commit

Permalink
Merge #906
Browse files Browse the repository at this point in the history
906: Fix bind() on Android 64-bit r=Susurrus a=Susurrus

libc fixed `bind()` for Android 64-bit targets, so change our
code to match.

PRs are failing (like #901) so let's get this merged.

CC @asomers @morrowa 

Co-authored-by: Bryant Mairs <bryantmairs@google.com>
  • Loading branch information
bors[bot] and Bryant Mairs committed May 29, 2018
2 parents d52227f + a5b01af commit b87d45b
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions src/sys/socket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,6 @@ pub fn listen(sockfd: RawFd, backlog: usize) -> Result<()> {
/// Bind a name to a socket
///
/// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html)
#[cfg(not(all(target_os="android", target_pointer_width="64")))]
pub fn bind(fd: RawFd, addr: &SockAddr) -> Result<()> {
let res = unsafe {
let (ptr, len) = addr.as_ffi_pair();
Expand All @@ -798,21 +797,6 @@ pub fn bind(fd: RawFd, addr: &SockAddr) -> Result<()> {
Errno::result(res).map(drop)
}

/// Bind a name to a socket
///
/// [Further reading](http://man7.org/linux/man-pages/man2/bind.2.html)
// Android has some weirdness. Its 64-bit bind takes a c_int instead of a
// socklen_t
#[cfg(all(target_os="android", target_pointer_width="64"))]
pub fn bind(fd: RawFd, addr: &SockAddr) -> Result<()> {
let res = unsafe {
let (ptr, len) = addr.as_ffi_pair();
libc::bind(fd, ptr, len as c_int)
};

Errno::result(res).map(drop)
}

/// Accept a connection on a socket
///
/// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/accept.html)
Expand Down

0 comments on commit b87d45b

Please sign in to comment.