Skip to content

Commit

Permalink
Auto merge of #994 - bkchr:android_fixes, r=alexcrichton
Browse files Browse the repository at this point in the history
Moves `ifaddrs` and some functions to common Linux module

The `ifaddrs` interface is available since api version 24 in android.
The function signatures are now equal to the standard Linux function
signatures.
  • Loading branch information
bors committed May 26, 2018
2 parents a0edf29 + 6a6dc86 commit 4083c89
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 95 deletions.
1 change: 1 addition & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ fn main() {
cfg.header("arpa/inet.h");
cfg.header("xlocale.h");
cfg.header("utmp.h");
cfg.header("ifaddrs.h");
if i686 || x86_64 {
cfg.header("sys/reg.h");
}
Expand Down
16 changes: 0 additions & 16 deletions src/unix/notbsd/android/b32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,22 +198,6 @@ pub const SIGSTKSZ: ::size_t = 8192;
pub const MINSIGSTKSZ: ::size_t = 2048;

extern {
pub fn bind(socket: ::c_int, address: *const ::sockaddr,
address_len: socklen_t) -> ::c_int;

pub fn writev(fd: ::c_int,
iov: *const ::iovec,
iovcnt: ::c_int) -> ::ssize_t;
pub fn readv(fd: ::c_int,
iov: *const ::iovec,
iovcnt: ::c_int) -> ::ssize_t;

pub fn sendmsg(fd: ::c_int,
msg: *const ::msghdr,
flags: ::c_int) -> ::ssize_t;
pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int)
-> ::ssize_t;

pub fn timegm64(tm: *const ::tm) -> ::time64_t;
}

Expand Down
25 changes: 0 additions & 25 deletions src/unix/notbsd/android/b64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,31 +154,6 @@ pub const UT_LINESIZE: usize = 32;
pub const UT_NAMESIZE: usize = 32;
pub const UT_HOSTSIZE: usize = 256;

// Some weirdness in Android
extern {
// address_len should be socklen_t, but it is c_int!
pub fn bind(socket: ::c_int, address: *const ::sockaddr,
address_len: ::c_int) -> ::c_int;

// the return type should be ::ssize_t, but it is c_int!
pub fn writev(fd: ::c_int,
iov: *const ::iovec,
iovcnt: ::c_int) -> ::c_int;

// the return type should be ::ssize_t, but it is c_int!
pub fn readv(fd: ::c_int,
iov: *const ::iovec,
iovcnt: ::c_int) -> ::c_int;

// the return type should be ::ssize_t, but it is c_int!
pub fn sendmsg(fd: ::c_int,
msg: *const ::msghdr,
flags: ::c_int) -> ::c_int;

// the return type should be ::ssize_t, but it is c_int!
pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::c_int;
}

cfg_if! {
if #[cfg(target_arch = "x86_64")] {
mod x86_64;
Expand Down
27 changes: 0 additions & 27 deletions src/unix/notbsd/emscripten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,6 @@ s! {
__unused5: *mut ::c_void,
}

pub struct ifaddrs {
pub ifa_next: *mut ifaddrs,
pub ifa_name: *mut c_char,
pub ifa_flags: ::c_uint,
pub ifa_addr: *mut ::sockaddr,
pub ifa_netmask: *mut ::sockaddr,
pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union
pub ifa_data: *mut ::c_void
}

pub struct pthread_mutex_t {
__align: [::c_long; 0],
size: [u8; __SIZEOF_PTHREAD_MUTEX_T],
Expand Down Expand Up @@ -1600,8 +1590,6 @@ extern {
mode: ::mode_t) -> ::c_int;
pub fn if_nameindex() -> *mut if_nameindex;
pub fn if_freenameindex(ptr: *mut if_nameindex);
pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int;
pub fn freeifaddrs(ifa: *mut ::ifaddrs);

pub fn mremap(addr: *mut ::c_void,
len: ::size_t,
Expand Down Expand Up @@ -1635,21 +1623,6 @@ extern {
pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;

pub fn bind(socket: ::c_int, address: *const ::sockaddr,
address_len: ::socklen_t) -> ::c_int;

pub fn writev(fd: ::c_int,
iov: *const ::iovec,
iovcnt: ::c_int) -> ::ssize_t;
pub fn readv(fd: ::c_int,
iov: *const ::iovec,
iovcnt: ::c_int) -> ::ssize_t;

pub fn sendmsg(fd: ::c_int,
msg: *const ::msghdr,
flags: ::c_int) -> ::ssize_t;
pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int)
-> ::ssize_t;
pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int;
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
Expand Down
27 changes: 0 additions & 27 deletions src/unix/notbsd/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,6 @@ s! {
__unused5: *mut ::c_void,
}

pub struct ifaddrs {
pub ifa_next: *mut ifaddrs,
pub ifa_name: *mut c_char,
pub ifa_flags: ::c_uint,
pub ifa_addr: *mut ::sockaddr,
pub ifa_netmask: *mut ::sockaddr,
pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union
pub ifa_data: *mut ::c_void
}

pub struct pthread_mutex_t {
#[cfg(any(target_arch = "mips",
target_arch = "arm",
Expand Down Expand Up @@ -1624,8 +1614,6 @@ extern {
pub fn if_freenameindex(ptr: *mut if_nameindex);
pub fn sync_file_range(fd: ::c_int, offset: ::off64_t,
nbytes: ::off64_t, flags: ::c_uint) -> ::c_int;
pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int;
pub fn freeifaddrs(ifa: *mut ::ifaddrs);
pub fn mremap(addr: *mut ::c_void,
len: ::size_t,
new_len: ::size_t,
Expand Down Expand Up @@ -1660,21 +1648,6 @@ extern {
pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int;
pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;

pub fn bind(socket: ::c_int, address: *const ::sockaddr,
address_len: ::socklen_t) -> ::c_int;

pub fn writev(fd: ::c_int,
iov: *const ::iovec,
iovcnt: ::c_int) -> ::ssize_t;
pub fn readv(fd: ::c_int,
iov: *const ::iovec,
iovcnt: ::c_int) -> ::ssize_t;

pub fn sendmsg(fd: ::c_int,
msg: *const ::msghdr,
flags: ::c_int) -> ::ssize_t;
pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int)
-> ::ssize_t;
pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int;
pub fn vhangup() -> ::c_int;
Expand Down
28 changes: 28 additions & 0 deletions src/unix/notbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,17 @@ s! {
pub ipi_spec_dst: ::in_addr,
pub ipi_addr: ::in_addr,
}

pub struct ifaddrs {
pub ifa_next: *mut ifaddrs,
pub ifa_name: *mut c_char,
pub ifa_flags: ::c_uint,
pub ifa_addr: *mut ::sockaddr,
pub ifa_netmask: *mut ::sockaddr,
pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union
pub ifa_data: *mut ::c_void
}

}

// intentionally not public, only used for fd_set
Expand Down Expand Up @@ -1003,6 +1014,23 @@ extern {
pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char,
envp: *const *const ::c_char)
-> ::c_int;
pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int;
pub fn freeifaddrs(ifa: *mut ::ifaddrs);
pub fn bind(socket: ::c_int, address: *const ::sockaddr,
address_len: ::socklen_t) -> ::c_int;

pub fn writev(fd: ::c_int,
iov: *const ::iovec,
iovcnt: ::c_int) -> ::ssize_t;
pub fn readv(fd: ::c_int,
iov: *const ::iovec,
iovcnt: ::c_int) -> ::ssize_t;

pub fn sendmsg(fd: ::c_int,
msg: *const ::msghdr,
flags: ::c_int) -> ::ssize_t;
pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int)
-> ::ssize_t;
}

cfg_if! {
Expand Down

0 comments on commit 4083c89

Please sign in to comment.