From 26670c77b7a9919d19df16f58883174c5d2d2c9b Mon Sep 17 00:00:00 2001 From: Kelvin Ly Date: Fri, 21 Apr 2017 18:20:02 -0400 Subject: [PATCH] Fix build errors for mips-unknown-linux-uclibc --- libc-test/build.rs | 51 ++++++++++---------------- src/unix/notbsd/linux/mips/mips32.rs | 18 +++++++++ src/unix/notbsd/linux/mips/mod.rs | 1 + src/unix/notbsd/linux/mod.rs | 32 +++++++++++----- src/unix/notbsd/linux/notuclibc/mod.rs | 10 +++++ 5 files changed, 71 insertions(+), 41 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 6ba4fa86..91292502 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -126,6 +126,8 @@ fn main() { if !musl { cfg.header("sys/sysctl.h"); + } + if !musl && !uclibc { if !netbsd && !openbsd && !uclibc { cfg.header("execinfo.h"); @@ -164,7 +166,10 @@ fn main() { cfg.header("mqueue.h"); cfg.header("ucontext.h"); cfg.header("sys/signalfd.h"); - cfg.header("sys/xattr.h"); + if !uclibc { + // optionally included in uclibc + cfg.header("sys/xattr.h"); + } cfg.header("sys/ipc.h"); cfg.header("sys/msg.h"); cfg.header("sys/shm.h"); @@ -295,7 +300,8 @@ fn main() { // sighandler_t is crazy across platforms "sighandler_t" => true, - "locale_t" if uclibc => true, + // locale_t is compiled in optionally + // "locale_t" if uclibc => true, _ => false } @@ -316,8 +322,6 @@ fn main() { // This is actually a union, not a struct "sigval" => true, - // These structs have changed since uClibc was developed - "stat" | "stat64" | "dqblk" if uclibc => true, // These structs didn't exist when uClibc was developed "aiocb" if uclibc => true, @@ -400,28 +404,14 @@ fn main() { "KERN_KDDISABLE_BG_TRACE" if apple => true, // uClibc doesn't support a LOT of constants, because its latest release - // was before any of them existed - "F_GETPIPE_SZ" | "F_SETPIPE_SZ" | - "CLOCK_MONOTONIC_RAW" | "CLOCK_REALTIME_COARSE" | "CLOCK_MONOTONIC_COARSE" | "CLOCK_BOOTTIME" | "CLOCK_REALTIME_ALARM" | "CLOCK_BOOTTIME_ALARM" | - "SOL_NETBEUI" | "SOL_LLC" | "SOL_DCCP" | "SOL_NETLINK" | "SOL_TICP" | "AF_RDS" | "PF_RDS" | - "MSG_FASTOPEN" | "AT_NO_AUTOMOUNT" | "AT_EMPTY_PATH" | "AF_IB" | "AF_MPLS" | "AF_NFC" | "AF_VSOCK" | - "PF_IB" | "PF_MPLS" | "PF_NFC" | "PF_VSOCK" | - "MSG_COPY" | "EPOLLEXCLUSIVE" | - "AIO_CANCELED" | "AIO_NOTCANCELED" | "AIO_ALLDONE" | - "LIO_READ" | "LIO_WRITE" | "LIO_NOP" | "LIO_WAIT" | "LIO_NOWAIT" | - "PR_MPX_ENABLE_MANAGEMENT" | "PR_MPX_DISABLE_MANAGEMENT" | "PR_SET_FP_MODE" | "PR_GET_FP_MODE" | - "PR_FP_MODE_FR" | "PR_FP_MODE_FRE" | "PR_CAP_AMBIENT" | "PR_CAP_AMBIENT_IS_SET" | "PR_CAP_AMBIENT_RAISE" | "PR_CAP_AMBIENT_LOWER" | "PR_CAP_AMBIENT_CLEAR_ALL" | "O_TMPFILE" | "SOL_TIPC" | "CLONE_NEWCGROUP" | "SO_INCOMING_CPU" | "SO_ATTACH_BPF" | "SO_DETACH_BPF" | - // or they weren't implemented yet + // was before they coud be implemented yet "LC_PAPER" | "LC_NAME" | "LC_ADDRESS" | "LC_TELEPHONE" | "LC_MEASUREMENT" | "LC_IDENTIFICATION" | "LC_PAPER_MASK" | "LC_NAME_MASK" | "LC_ADDRESS_MASK" | "LC_TELEPHONE_MASK" | "LC_MEASUREMENT_MASK" | "LC_IDENTIFICATION_MASK" | "LC_ALL_MASK" | - "MS_DIRSYNC" | "MS_MOVE" | "MS_REC" | "MS_SILENT" | "MS_POSIXACL" | "MS_UNBINDABLE" | "MS_PRIVATE" | "MS_SLAVE" | "MS_SHARED" | "MS_RELATIME" | "MS_KERNMOUNT" | "MS_I_VERSION" | "MS_STRICTATIME" | "MS_ACTIVE" | - "QIF_BLIMITS" | "QIF_SPACE" | "QIF_ILIMITS" | "QIF_INODES" | "QIF_BTIME" | "QIF_ITIME" | "QIF_LIMITS" | "QIF_USAGE" | "QIF_TIMES" | "QIF_ALL" | "IP_TRANSPARENT" | - "Q_GETFMT" | "Q_GETINFO" | "Q_SETINFO" | "SHM_EXEC" | "RB_SW_SUSPEND" | "RB_KEXEC" | "RUSAGE_THREAD" | // not entirely sure why these don't work... "LC_CTYPE_MASK" | "LC_NUMERIC_MASK" | "LC_TIME_MASK" | "LC_COLLATE_MASK" | "LC_MONETARY_MASK" | "LC_MESSAGES_MASK" | "MADV_MERGEABLE" | "MADV_UNMERGEABLE" | "MADV_HWPOISON" | "IPV6_ADD_MEMBERSHIP" | "IPV6_DROP_MEMBERSHIP" | "IPV6_MULTICAST_LOOP" | "IPV6_V6ONLY" | - "MAP_STACK" | "MAP_HUGETLB" | "RTLD_DEEPBIND" | - "SOL_IPV6" | "SOL_ICMPV6" | "SOL_TIPC" if uclibc => true, + "MAP_STACK" | "RTLD_DEEPBIND" | "MAP_HUGETLB" | + "SOL_IPV6" | "SOL_ICMPV6" if uclibc => true, _ => false, } }); @@ -505,11 +495,13 @@ fn main() { // These are either unimplemented or optionally built into uClibc // or "sysinfo", where it's defined but the structs in linux/sysinfo.h and sys/sysinfo.h - // clash so it can't be tested, or they're tainted with an old struct definition, as in g"getnameinfo" - "mkostemp" | "mkostemps" | "mkstemps" | "futimes" | "setns" | "sysinfo" | "fallocate" | "posix_fallocate" | "preadv" | "pwritev" | "dup3" | "openpty" | "forkpty" | - "getloadavg" | "process_vm_readv" | "process_vm_writev" | "backtrace" | "posix_madvise" | - "aio_read" | "aio_write" | "aio_fsync" | "aio_error" | "aio_return" | "aio_suspend" | "aio_cancel" | "lio_listio" | - "newlocale" | "duplocale" | "freelocale" | "uselocale" | "nl_langinfo_l" | "wcslen" | "getnameinfo" | "wcstombs" if uclibc && linux => true, + // clash so it can't be tested + "getxattr" | "lgetxattr" | "fgetxattr" | "setxattr" | "lsetxattr" | "fsetxattr" | + "listxattr" | "llistxattr" | "flistxattr" | "removexattr" | "lremovexattr" | + "fremovexattr" | + "backtrace" | + "sysinfo" | "newlocale" | "duplocale" | "freelocale" | "uselocale" | + "nl_langinfo_l" | "wcslen" | "wcstombs" if uclibc && linux => true, _ => false, } @@ -548,12 +540,7 @@ fn main() { // musl seems to define this as an *anonymous* bitfield (musl && struct_ == "statvfs" && field == "__f_unused") || // sigev_notify_thread_id is actually part of a sigev_un union - (struct_ == "sigevent" && field == "sigev_notify_thread_id") || - - // uClibc differs in signedness - (uclibc && struct_ == "sigaction" && field == "sa_flags") || - // same here - (uclibc && struct_ == "msghdr" && field == "msg_iovlen") + (struct_ == "sigevent" && field == "sigev_notify_thread_id") }); cfg.fn_cname(move |name, cname| { diff --git a/src/unix/notbsd/linux/mips/mips32.rs b/src/unix/notbsd/linux/mips/mips32.rs index 6ab93e59..dc868478 100644 --- a/src/unix/notbsd/linux/mips/mips32.rs +++ b/src/unix/notbsd/linux/mips/mips32.rs @@ -33,15 +33,24 @@ s! { } pub struct stat { + #[cfg(not(target_env = "uclibc"))] pub st_dev: ::c_ulong, + #[cfg(target_env = "uclibc")] + pub st_dev: ::dev_t, st_pad1: [::c_long; 3], pub st_ino: ::ino_t, pub st_mode: ::mode_t, pub st_nlink: ::nlink_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, + #[cfg(not(target_env = "uclibc"))] pub st_rdev: ::c_ulong, + #[cfg(target_env = "uclibc")] + pub st_rdev: ::dev_t, + #[cfg(not(target_env = "uclibc"))] pub st_pad2: [::c_long; 2], + #[cfg(target_env = "uclibc")] + pub st_pad2: [::c_long; 1], pub st_size: ::off_t, st_pad3: ::c_long, pub st_atime: ::time_t, @@ -56,14 +65,20 @@ s! { } pub struct stat64 { + #[cfg(not(target_env = "uclibc"))] pub st_dev: ::c_ulong, + #[cfg(target_env = "uclibc")] + pub st_dev: ::dev_t, st_pad1: [::c_long; 3], pub st_ino: ::ino64_t, pub st_mode: ::mode_t, pub st_nlink: ::nlink_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, + #[cfg(not(target_env = "uclibc"))] pub st_rdev: ::c_ulong, + #[cfg(target_env = "uclibc")] + pub st_rdev: ::dev_t, st_pad2: [::c_long; 2], pub st_size: ::off64_t, pub st_atime: ::time_t, @@ -198,7 +213,10 @@ s! { pub msg_name: *mut ::c_void, pub msg_namelen: ::socklen_t, pub msg_iov: *mut ::iovec, + #[cfg(target_env = "uclib")] pub msg_iovlen: ::size_t, + #[cfg(target_env = "uclib")] + pub msg_iovlen: ::c_int, pub msg_control: *mut ::c_void, pub msg_controllen: ::size_t, pub msg_flags: ::c_int, diff --git a/src/unix/notbsd/linux/mips/mod.rs b/src/unix/notbsd/linux/mips/mod.rs index a577d257..e42d9506 100644 --- a/src/unix/notbsd/linux/mips/mod.rs +++ b/src/unix/notbsd/linux/mips/mod.rs @@ -1,3 +1,4 @@ +#[cfg(not(target_env = "uclibc"))] pub const CLONE_NEWCGROUP: ::c_int = 0x02000000; pub const SFD_CLOEXEC: ::c_int = 0x080000; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 5a776e6b..1d43acb7 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -154,14 +154,37 @@ s! { } pub struct dqblk { + #[cfg(not(target_env = "uclibc"))] pub dqb_bhardlimit: ::uint64_t, + #[cfg(target_env = "uclibc")] + pub dqb_bhardlimit: ::uint32_t, + #[cfg(not(target_env = "uclibc"))] pub dqb_bsoftlimit: ::uint64_t, + #[cfg(target_env = "uclibc")] + pub dqb_bsoftlimit: ::uint32_t, + #[cfg(not(target_env = "uclibc"))] pub dqb_curspace: ::uint64_t, + #[cfg(not(target_env = "uclibc"))] pub dqb_ihardlimit: ::uint64_t, + #[cfg(target_env = "uclibc")] + pub dqb_ihardlimit: ::uint32_t, + #[cfg(not(target_env = "uclibc"))] pub dqb_isoftlimit: ::uint64_t, + #[cfg(target_env = "uclibc")] + pub dqb_isoftlimit: ::uint32_t, + #[cfg(not(target_env = "uclibc"))] pub dqb_curinodes: ::uint64_t, + #[cfg(target_env = "uclibc")] + pub dqb_curinodes: ::uint32_t, + #[cfg(not(target_env = "uclibc"))] pub dqb_btime: ::uint64_t, + #[cfg(target_env = "uclibc")] + pub dqb_btime: ::time_t, + #[cfg(not(target_env = "uclibc"))] pub dqb_itime: ::uint64_t, + #[cfg(target_env = "uclibc")] + pub dqb_itime: ::time_t, + #[cfg(not(target_env = "uclibc"))] pub dqb_valid: ::uint32_t, } @@ -589,8 +612,6 @@ pub const PR_GET_TID_ADDRESS: ::c_int = 40; pub const PR_SET_THP_DISABLE: ::c_int = 41; pub const PR_GET_THP_DISABLE: ::c_int = 42; -pub const PR_SET_FP_MODE: ::c_int = 45; -pub const PR_GET_FP_MODE: ::c_int = 46; f! { pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { @@ -729,13 +750,6 @@ extern { pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> ::c_int; pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char; - pub fn getnameinfo(sa: *const ::sockaddr, - salen: ::socklen_t, - host: *mut ::c_char, - hostlen: ::socklen_t, - serv: *mut ::c_char, - sevlen: ::socklen_t, - flags: ::c_int) -> ::c_int; pub fn prlimit(pid: ::pid_t, resource: ::c_int, new_limit: *const ::rlimit, old_limit: *mut ::rlimit) -> ::c_int; pub fn prlimit64(pid: ::pid_t, diff --git a/src/unix/notbsd/linux/notuclibc/mod.rs b/src/unix/notbsd/linux/notuclibc/mod.rs index b59d651f..098bee14 100644 --- a/src/unix/notbsd/linux/notuclibc/mod.rs +++ b/src/unix/notbsd/linux/notuclibc/mod.rs @@ -111,6 +111,9 @@ pub const SHM_EXEC: ::c_int = 0o100000; pub const RB_SW_SUSPEND: ::c_int = 0xd000fce2u32 as i32; pub const RB_KEXEC: ::c_int = 0x45584543u32 as i32; +pub const PR_SET_FP_MODE: ::c_int = 45; +pub const PR_GET_FP_MODE: ::c_int = 46; + use super::aiocb; use super::termios; extern { @@ -125,6 +128,13 @@ extern { pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb, nitems: ::c_int, sevp: *mut ::sigevent) -> ::c_int; + pub fn getnameinfo(sa: *const ::sockaddr, + salen: ::socklen_t, + host: *mut ::c_char, + hostlen: ::socklen_t, + serv: *mut ::c_char, + sevlen: ::socklen_t, + flags: ::c_int) -> ::c_int; pub fn fallocate(fd: ::c_int, mode: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int; pub fn posix_fallocate(fd: ::c_int, offset: ::off_t,