Auto merge of #994 - bkchr:android_fixes, r=alexcrichton
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.
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 82491bb..7dd248b 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -134,6 +134,7 @@
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");
}
diff --git a/src/unix/notbsd/android/b32/mod.rs b/src/unix/notbsd/android/b32/mod.rs
index 99af6d8..394abe8 100644
--- a/src/unix/notbsd/android/b32/mod.rs
+++ b/src/unix/notbsd/android/b32/mod.rs
@@ -198,22 +198,6 @@
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;
}
diff --git a/src/unix/notbsd/android/b64/mod.rs b/src/unix/notbsd/android/b64/mod.rs
index 4aa6997..fb94334 100644
--- a/src/unix/notbsd/android/b64/mod.rs
+++ b/src/unix/notbsd/android/b64/mod.rs
@@ -154,31 +154,6 @@
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;
diff --git a/src/unix/notbsd/emscripten.rs b/src/unix/notbsd/emscripten.rs
index 90c056c..0d314ec 100644
--- a/src/unix/notbsd/emscripten.rs
+++ b/src/unix/notbsd/emscripten.rs
@@ -72,16 +72,6 @@
__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],
@@ -1600,8 +1590,6 @@
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,
@@ -1635,21 +1623,6 @@
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,
diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs
index 7988072..2a455e6 100644
--- a/src/unix/notbsd/linux/mod.rs
+++ b/src/unix/notbsd/linux/mod.rs
@@ -71,16 +71,6 @@
__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",
@@ -1624,8 +1614,6 @@
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,
@@ -1660,21 +1648,6 @@
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;
diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs
index a7f6da5..f6fa04a 100644
--- a/src/unix/notbsd/mod.rs
+++ b/src/unix/notbsd/mod.rs
@@ -183,6 +183,17 @@
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
@@ -1003,6 +1014,23 @@
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! {