Make libc-tests compile for aarch64-linux-android
- some tests are failing - remove readlink, timegm and sig* functions in favor of the unix/mod.rs definitions - remove time64_t (it is not defined for aarch64) - move some definitions to android/b32.rs and create appropriated definitions in android/b64.rs
This commit is contained in:
parent
c53251867f
commit
92ce51823c
|
@ -6,6 +6,7 @@ use std::env;
|
|||
|
||||
fn main() {
|
||||
let target = env::var("TARGET").unwrap();
|
||||
let aarch64 = target.contains("aarch64");
|
||||
let x86_64 = target.contains("x86_64");
|
||||
let windows = target.contains("windows");
|
||||
let mingw = target.contains("windows-gnu");
|
||||
|
@ -105,8 +106,12 @@ fn main() {
|
|||
}
|
||||
|
||||
if android {
|
||||
if !aarch64 {
|
||||
// time64_t is not define for aarch64
|
||||
// If included it will generate the error 'Your time_t is already 64-bit'
|
||||
cfg.header("time64.h");
|
||||
}
|
||||
cfg.header("arpa/inet.h");
|
||||
cfg.header("time64.h");
|
||||
cfg.header("xlocale.h");
|
||||
cfg.header("utmp.h");
|
||||
} else if !windows {
|
||||
|
|
|
@ -274,10 +274,6 @@ extern {
|
|||
link_name = "connect$UNIX2003")]
|
||||
pub fn connect(socket: ::c_int, address: *const sockaddr,
|
||||
len: socklen_t) -> ::c_int;
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
|
||||
link_name = "bind$UNIX2003")]
|
||||
pub fn bind(socket: ::c_int, address: *const sockaddr,
|
||||
address_len: socklen_t) -> ::c_int;
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
|
||||
link_name = "listen$UNIX2003")]
|
||||
pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int;
|
||||
|
@ -680,16 +676,6 @@ extern {
|
|||
#[cfg_attr(target_os = "netbsd", link_name = "__mknod50")]
|
||||
pub fn mknod(pathname: *const ::c_char, mode: ::mode_t,
|
||||
dev: ::dev_t) -> ::c_int;
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
|
||||
link_name = "writev$UNIX2003")]
|
||||
pub fn writev(fd: ::c_int,
|
||||
iov: *const ::iovec,
|
||||
iovcnt: ::c_int) -> ::ssize_t;
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
|
||||
link_name = "readv$UNIX2003")]
|
||||
pub fn readv(fd: ::c_int,
|
||||
iov: *const ::iovec,
|
||||
iovcnt: ::c_int) -> ::ssize_t;
|
||||
pub fn uname(buf: *mut ::utsname) -> ::c_int;
|
||||
pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
|
||||
pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
|
||||
|
@ -709,14 +695,6 @@ extern {
|
|||
link_name = "putenv$UNIX2003")]
|
||||
#[cfg_attr(target_os = "netbsd", link_name = "__putenv50")]
|
||||
pub fn putenv(string: *mut c_char) -> ::c_int;
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
|
||||
link_name = "sendmsg$UNIX2003")]
|
||||
pub fn sendmsg(fd: ::c_int,
|
||||
msg: *const msghdr,
|
||||
flags: ::c_int) -> ::ssize_t;
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
|
||||
link_name = "recvmsg$UNIX2003")]
|
||||
pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::ssize_t;
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
|
||||
link_name = "poll$UNIX2003")]
|
||||
pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int;
|
||||
|
@ -750,6 +728,56 @@ extern {
|
|||
-> ::c_int;
|
||||
pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int;
|
||||
pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int;
|
||||
|
||||
pub fn readlink(path: *const c_char,
|
||||
buf: *mut c_char,
|
||||
bufsz: ::size_t)
|
||||
-> ::ssize_t;
|
||||
|
||||
#[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")]
|
||||
pub fn sigemptyset(set: *mut sigset_t) -> ::c_int;
|
||||
#[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")]
|
||||
pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
|
||||
#[cfg_attr(target_os = "netbsd", link_name = "__sigfillset14")]
|
||||
pub fn sigfillset(set: *mut sigset_t) -> ::c_int;
|
||||
#[cfg_attr(target_os = "netbsd", link_name = "__sigdelset14")]
|
||||
pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
|
||||
#[cfg_attr(target_os = "netbsd", link_name = "__sigismember14")]
|
||||
pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int;
|
||||
|
||||
#[cfg_attr(target_os = "netbsd", link_name = "__timegm50")]
|
||||
pub fn timegm(tm: *mut ::tm) -> time_t;
|
||||
}
|
||||
|
||||
// Android has some weirdness in this definition
|
||||
// See weirdness in src/unix/notbsd/android/mod.rs
|
||||
#[cfg(any(not(target_os = "android"), // " if " -- appease style checker
|
||||
not(target_arch = "aarch64")))]
|
||||
extern {
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
|
||||
link_name = "bind$UNIX2003")]
|
||||
pub fn bind(socket: ::c_int, address: *const sockaddr,
|
||||
address_len: socklen_t) -> ::c_int;
|
||||
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
|
||||
link_name = "writev$UNIX2003")]
|
||||
pub fn writev(fd: ::c_int,
|
||||
iov: *const ::iovec,
|
||||
iovcnt: ::c_int) -> ::ssize_t;
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
|
||||
link_name = "readv$UNIX2003")]
|
||||
pub fn readv(fd: ::c_int,
|
||||
iov: *const ::iovec,
|
||||
iovcnt: ::c_int) -> ::ssize_t;
|
||||
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
|
||||
link_name = "sendmsg$UNIX2003")]
|
||||
pub fn sendmsg(fd: ::c_int,
|
||||
msg: *const msghdr,
|
||||
flags: ::c_int) -> ::ssize_t;
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
|
||||
link_name = "recvmsg$UNIX2003")]
|
||||
pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::ssize_t;
|
||||
}
|
||||
|
||||
// TODO: get rid of this cfg(not(...))
|
||||
|
@ -785,10 +813,6 @@ extern {
|
|||
pub fn getsid(pid: pid_t) -> pid_t;
|
||||
pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
|
||||
-> ::c_int;
|
||||
pub fn readlink(path: *const c_char,
|
||||
buf: *mut c_char,
|
||||
bufsz: ::size_t)
|
||||
-> ::ssize_t;
|
||||
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
|
||||
link_name = "msync$UNIX2003")]
|
||||
|
@ -802,16 +826,6 @@ extern {
|
|||
addrlen: *mut socklen_t) -> ::ssize_t;
|
||||
pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int;
|
||||
|
||||
#[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")]
|
||||
pub fn sigemptyset(set: *mut sigset_t) -> ::c_int;
|
||||
#[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")]
|
||||
pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
|
||||
#[cfg_attr(target_os = "netbsd", link_name = "__sigfillset14")]
|
||||
pub fn sigfillset(set: *mut sigset_t) -> ::c_int;
|
||||
#[cfg_attr(target_os = "netbsd", link_name = "__sigdelset14")]
|
||||
pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
|
||||
#[cfg_attr(target_os = "netbsd", link_name = "__sigismember14")]
|
||||
pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int;
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
|
||||
link_name = "pselect$1050")]
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
|
||||
|
@ -827,8 +841,6 @@ extern {
|
|||
offset: ::off_t,
|
||||
whence: ::c_int) -> ::c_int;
|
||||
pub fn ftello(stream: *mut ::FILE) -> ::off_t;
|
||||
#[cfg_attr(target_os = "netbsd", link_name = "__timegm50")]
|
||||
pub fn timegm(tm: *mut ::tm) -> time_t;
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
|
||||
link_name = "tcdrain$UNIX2003")]
|
||||
pub fn tcdrain(fd: ::c_int) -> ::c_int;
|
||||
|
|
|
@ -2,6 +2,8 @@ pub type c_long = i32;
|
|||
pub type c_ulong = u32;
|
||||
pub type mode_t = u16;
|
||||
pub type off64_t = ::c_longlong;
|
||||
pub type sigset_t = ::c_ulong;
|
||||
pub type time64_t = i64;
|
||||
|
||||
s! {
|
||||
pub struct sigaction {
|
||||
|
@ -11,6 +13,11 @@ s! {
|
|||
pub sa_restorer: ::dox::Option<extern fn()>,
|
||||
}
|
||||
|
||||
pub struct rlimit64 {
|
||||
pub rlim_cur: u64,
|
||||
pub rlim_max: u64,
|
||||
}
|
||||
|
||||
pub struct stat {
|
||||
pub st_dev: ::c_ulonglong,
|
||||
__pad0: [::c_uchar; 4],
|
||||
|
|
|
@ -6,6 +6,10 @@ pub type mode_t = u32;
|
|||
pub type off64_t = i64;
|
||||
|
||||
s! {
|
||||
pub struct sigset_t {
|
||||
__val: [::c_ulong; 1],
|
||||
}
|
||||
|
||||
pub struct sigaction {
|
||||
pub sa_flags: ::c_uint,
|
||||
pub sa_sigaction: ::sighandler_t,
|
||||
|
@ -13,6 +17,11 @@ s! {
|
|||
_restorer: *mut ::c_void,
|
||||
}
|
||||
|
||||
pub struct rlimit64 {
|
||||
pub rlim_cur: ::c_ulonglong,
|
||||
pub rlim_max: ::c_ulonglong,
|
||||
}
|
||||
|
||||
pub struct stat {
|
||||
pub st_dev: ::dev_t,
|
||||
pub st_ino: ::ino_t,
|
||||
|
@ -155,7 +164,3 @@ pub const __CPU_BITS: ::size_t = 64;
|
|||
pub const UT_LINESIZE: usize = 32;
|
||||
pub const UT_NAMESIZE: usize = 32;
|
||||
pub const UT_HOSTSIZE: usize = 256;
|
||||
|
||||
extern {
|
||||
pub fn timegm(tm: *const ::tm) -> ::time64_t;
|
||||
}
|
||||
|
|
|
@ -24,8 +24,6 @@ pub type socklen_t = i32;
|
|||
pub type pthread_t = ::c_long;
|
||||
pub type pthread_mutexattr_t = ::c_long;
|
||||
pub type pthread_condattr_t = ::c_long;
|
||||
pub type sigset_t = ::c_ulong;
|
||||
pub type time64_t = i64; // N/A on android
|
||||
pub type fsfilcnt_t = ::c_ulong;
|
||||
pub type fsblkcnt_t = ::c_ulong;
|
||||
pub type nfds_t = ::c_uint;
|
||||
|
@ -52,11 +50,6 @@ s! {
|
|||
pub d_name: [::c_char; 256],
|
||||
}
|
||||
|
||||
pub struct rlimit64 {
|
||||
pub rlim_cur: u64,
|
||||
pub rlim_max: u64,
|
||||
}
|
||||
|
||||
pub struct stack_t {
|
||||
pub ss_sp: *mut ::c_void,
|
||||
pub ss_flags: ::c_int,
|
||||
|
@ -76,7 +69,7 @@ s! {
|
|||
|
||||
pub struct msghdr {
|
||||
pub msg_name: *mut ::c_void,
|
||||
pub msg_namelen: ::c_int,
|
||||
pub msg_namelen: ::socklen_t,
|
||||
pub msg_iov: *mut ::iovec,
|
||||
pub msg_iovlen: ::size_t,
|
||||
pub msg_control: *mut ::c_void,
|
||||
|
@ -534,10 +527,15 @@ pub const PTRACE_SETOPTIONS: ::c_int = 0x4200;
|
|||
pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201;
|
||||
pub const PTRACE_GETSIGINFO: ::c_int = 0x4202;
|
||||
pub const PTRACE_SETSIGINFO: ::c_int = 0x4203;
|
||||
pub const PTRACE_GETFPREGS: ::c_int = 14;
|
||||
pub const PTRACE_SETFPREGS: ::c_int = 15;
|
||||
pub const PTRACE_GETREGS: ::c_int = 12;
|
||||
pub const PTRACE_SETREGS: ::c_int = 13;
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(not(target_arch = "aarch64"))] {
|
||||
pub const PTRACE_GETFPREGS: ::c_int = 14;
|
||||
pub const PTRACE_SETFPREGS: ::c_int = 15;
|
||||
pub const PTRACE_GETREGS: ::c_int = 12;
|
||||
pub const PTRACE_SETREGS: ::c_int = 13;
|
||||
} else {}
|
||||
}
|
||||
|
||||
pub const EFD_NONBLOCK: ::c_int = 0x800;
|
||||
|
||||
|
@ -710,25 +708,6 @@ pub const NLA_TYPE_MASK: ::c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER);
|
|||
pub const SIGEV_THREAD_ID: ::c_int = 4;
|
||||
|
||||
f! {
|
||||
pub fn sigemptyset(set: *mut sigset_t) -> ::c_int {
|
||||
*set = 0;
|
||||
return 0
|
||||
}
|
||||
pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int {
|
||||
*set |= signum as sigset_t;
|
||||
return 0
|
||||
}
|
||||
pub fn sigfillset(set: *mut sigset_t) -> ::c_int {
|
||||
*set = !0;
|
||||
return 0
|
||||
}
|
||||
pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int {
|
||||
*set &= !(signum as sigset_t);
|
||||
return 0
|
||||
}
|
||||
pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int {
|
||||
(*set & (signum as sigset_t)) as ::c_int
|
||||
}
|
||||
pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t {
|
||||
(*termios).c_cflag & ::CBAUD
|
||||
}
|
||||
|
@ -798,14 +777,36 @@ extern {
|
|||
static mut __progname: *mut ::c_char;
|
||||
}
|
||||
|
||||
// Some weirdness in Android
|
||||
#[cfg(target_arch = "aarch64")] // " if " -- appease style checker
|
||||
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;
|
||||
}
|
||||
|
||||
extern {
|
||||
pub fn madvise(addr: *const ::c_void, len: ::size_t, advice: ::c_int)
|
||||
-> ::c_int;
|
||||
pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
|
||||
pub fn readlink(path: *const ::c_char,
|
||||
buf: *mut ::c_char,
|
||||
bufsz: ::size_t)
|
||||
-> ::c_int;
|
||||
pub fn msync(addr: *const ::c_void, len: ::size_t,
|
||||
flags: ::c_int) -> ::c_int;
|
||||
pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int)
|
||||
|
|
Loading…
Reference in a new issue