From 0af80cae5344dea04f841029f2aa3b2213cf3316 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 14 May 2019 10:06:23 +0200 Subject: [PATCH 01/50] Refactor Android target --- libc-test/build.rs | 474 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 386 insertions(+), 88 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index aba2a3056852c..bb0252397b46e 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -14,12 +14,10 @@ fn do_cc() { fn do_ctest() { let target = env::var("TARGET").unwrap(); - let aarch64 = target.contains("aarch64"); let i686 = target.contains("i686"); let x86_64 = target.contains("x86_64"); let x32 = target.ends_with("gnux32"); let linux = target.contains("unknown-linux"); - let android = target.contains("android"); let emscripten = target.contains("asm"); let musl = target.contains("musl") || emscripten; let uclibc = target.contains("uclibc"); @@ -39,22 +37,17 @@ fn do_ctest() { t if t.contains("netbsd") => return test_netbsd(t), t if t.contains("dragonfly") => return test_dragonflybsd(t), t if t.contains("wasi") => return test_wasi(t), + t if t.contains("android") => return test_android(t), _ => (), } // Pull in extra goodies - if linux || android || emscripten { + if linux || emscripten { cfg.define("_GNU_SOURCE", None); } else if freebsd { cfg.define("_WITH_GETLINE", None); } - // Android doesn't actually have in_port_t but it's much easier if we - // provide one for us to test against - if android { - cfg.define("in_port_t", Some("uint16_t")); - } - cfg.header("errno.h") .header("fcntl.h") .header("limits.h") @@ -75,7 +68,7 @@ fn do_ctest() { cfg.header("net/if.h"); cfg.header("net/route.h"); cfg.header("net/if_arp.h"); - if linux || android { + if linux { cfg.header("linux/if_alg.h"); } cfg.header("netdb.h"); @@ -116,41 +109,27 @@ fn do_ctest() { cfg.header("sys/statvfs.h"); cfg.header("sys/times.h"); - if android { - if !aarch64 && !x86_64 { - // time64_t is not define for aarch64 and x86_64 - // 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("xlocale.h"); - cfg.header("ifaddrs.h"); - if i686 || x86_64 { - cfg.header("sys/reg.h"); - } - } else { - cfg.header("glob.h"); - cfg.header("ifaddrs.h"); - cfg.header("langinfo.h"); + cfg.header("glob.h"); + cfg.header("ifaddrs.h"); + cfg.header("langinfo.h"); - if !openbsd && !freebsd { - cfg.header("sys/quota.h"); - } + if !openbsd && !freebsd { + cfg.header("sys/quota.h"); + } - if !musl && !x32 { - cfg.header("sys/sysctl.h"); - } + if !musl && !x32 { + cfg.header("sys/sysctl.h"); + } - if !musl && !uclibc { - if !openbsd && !uclibc { - cfg.header("execinfo.h"); - } + if !musl && !uclibc { + if !openbsd && !uclibc { + cfg.header("execinfo.h"); + } - if openbsd { - cfg.header("utmp.h"); - } else { - cfg.header("utmpx.h"); - } + if openbsd { + cfg.header("utmp.h"); + } else { + cfg.header("utmpx.h"); } } @@ -192,7 +171,7 @@ fn do_ctest() { } } - if linux || android || emscripten { + if linux || emscripten { cfg.header("malloc.h"); cfg.header("net/ethernet.h"); cfg.header("netpacket/packet.h"); @@ -232,7 +211,7 @@ fn do_ctest() { } } - if linux || android { + if linux { cfg.header("sys/fsuid.h"); cfg.header("linux/module.h"); cfg.header("linux/seccomp.h"); @@ -307,7 +286,6 @@ fn do_ctest() { } }); - let target2 = target.clone(); cfg.field_name(move |struct_, field| { match field { "st_birthtime" if openbsd && struct_ == "stat" => { @@ -319,11 +297,7 @@ fn do_ctest() { // Our stat *_nsec fields normally don't actually exist but are part // of a timeval struct s if s.ends_with("_nsec") && struct_.starts_with("stat") => { - if target2.contains("android") { - s.to_string() - } else { - s.replace("e_nsec", ".tv_nsec") - } + s.replace("e_nsec", ".tv_nsec") } "u64" if struct_ == "epoll_event" => "data.u64".to_string(), "type_" @@ -364,11 +338,6 @@ fn do_ctest() { // definition. Because it's tested on other Linux targets, skip it. "input_mask" if musl => true, - // These structs have changed since unified headers in NDK r14b. - // `st_atime` and `st_atime_nsec` have changed sign. - // FIXME: unskip it for next major release - "stat" | "stat64" if android => true, - // These are tested as part of the linux_fcntl tests since there are // header conflicts when including them with all the other structs. "termios2" => true, @@ -483,13 +452,13 @@ fn do_ctest() { true } - // Both android and musl use old kernel headers + // musl uses old kernel headers // These are constants used in getrandom syscall - "GRND_NONBLOCK" | "GRND_RANDOM" if musl || android => true, + "GRND_NONBLOCK" | "GRND_RANDOM" if musl => true, // Defined by libattr not libc on linux (hard to test). // See constant definition for more details. - "ENOATTR" if android || linux => true, + "ENOATTR" if linux => true, // On mips*-unknown-linux-gnu* CMSPAR cannot be included with the set of headers we // want to use here for testing. It's originally defined in asm/termbits.h, which is @@ -520,7 +489,7 @@ fn do_ctest() { // x86_64 and i686 builders it seems to be available for all targets, so at least test // it there. "MFD_HUGETLB" - if !(x86_64 || i686) || musl || (x86_64 && android) => + if !(x86_64 || i686) || musl => { true } @@ -584,13 +553,9 @@ fn do_ctest() { // send*/recv* syscalls "sendmmsg" | "recvmmsg" if musl => true, - // typed 2nd arg on linux and android - "gettimeofday" if linux || android || freebsd || openbsd => true, - - // not declared in newer android toolchains - "getdtablesize" if android => true, + // typed 2nd arg on linux + "gettimeofday" if linux || freebsd || openbsd => true, - "dlerror" if android => true, // const-ness is added "dladdr" if musl => true, // const-ness only added recently // There seems to be a small error in EGLIBC's eventfd.h header. The @@ -625,10 +590,6 @@ fn do_ctest() { "lio_listio" if freebsd => true, "lio_listio" if musl => true, - // Apparently the NDK doesn't have this defined on android, but - // it's in a header file? - "endpwent" if android => true, - // 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 @@ -639,20 +600,11 @@ fn do_ctest() { "sysinfo" | "newlocale" | "duplocale" | "freelocale" | "uselocale" | "nl_langinfo_l" | "wcslen" | "wcstombs" if uclibc => true, - // Apparently res_init exists on Android, but isn't defined in a header: - // https://mail.gnome.org/archives/commits-list/2013-May/msg01329.html - "res_init" if android => true, - // Definition of those functions as changed since unified headers from NDK r14b // These changes imply some API breaking changes but are still ABI compatible. // We can wait for the next major release to be compliant with the new API. // FIXME: unskip these for next major release "strerror_r" | "madvise" | "msync" | "mprotect" | "recvfrom" | "getpriority" | - "setpriority" | "personality" if android => true, - // In Android 64 bits, these functions have been fixed since unified headers. - // Ignore these until next major version. - "bind" | "writev" | "readv" | "sendmsg" | "recvmsg" if android && (aarch64 || x86_64) => true, - // Removed in OpenBSD 6.5 // https://marc.info/?l=openbsd-cvs&m=154723400730318 "mincore" if openbsd => true, @@ -661,14 +613,6 @@ fn do_ctest() { } }); - cfg.skip_static(move |name| { - match name { - // Internal constant, not declared in any headers. - "__progname" if android => true, - _ => false, - } - }); - cfg.skip_field_type(move |struct_, field| { // This is a weird union, don't check the type. (struct_ == "ifaddrs" && field == "ifa_ifu") || @@ -711,14 +655,14 @@ fn do_ctest() { cfg.generate("../src/lib.rs", "main.rs"); - // On Linux or Android also generate another script for testing linux/fcntl declarations. + // On Linux also generate another script for testing linux/fcntl declarations. // These cannot be tested normally because including both `linux/fcntl.h` and `fcntl.h` // fails on a lot of platforms. let mut cfg = ctest::TestGenerator::new(); cfg.skip_type(|_| true) .skip_fn(|_| true) .skip_static(|_| true); - if android || linux { + if linux { // musl defines these directly in `fcntl.h` if musl { cfg.header("fcntl.h"); @@ -1839,7 +1783,7 @@ fn test_dragonflybsd(target: &str) { "getrlimit" | "getrlimit64" | // non-int in 1st arg "setrlimit" | "setrlimit64" | // non-int in 1st arg "prlimit" | "prlimit64" | // non-int in 2nd arg - // typed 2nd arg on linux and android + // typed 2nd arg on linux "gettimeofday" => true, _ => false, @@ -1937,3 +1881,357 @@ fn test_wasi(target: &str) { cfg.generate("../src/lib.rs", "main.rs"); } + +fn test_android(target: &str) { + assert!(target.contains("android")); + let target_pointer_width = match target { + t if t.contains("aarch64") || t.contains("x86_64") => 64, + t if t.contains("i686") || t.contains("arm") => 32, + t => panic!("unsupported target: {}", t), + }; + let x86 = target.contains("i686") || target.contains("x86_64"); + + let mut cfg = ctest::TestGenerator::new(); + cfg.define("_GNU_SOURCE", None); + + // FIXME: still necessary? + cfg.flag("-Wno-deprecated-declarations"); + + // Android doesn't actually have in_port_t but it's much easier if we + // provide one for us to test against + // FIXME: still necessary? + cfg.define("in_port_t", Some("uint16_t")); + + headers! { cfg: + "arpa/inet.h", + "asm/mman.h", + "ctype.h", + "dirent.h", + "dlfcn.h", + "errno.h", + "fcntl.h", + "grp.h", + "ifaddrs.h", + "limits.h", + "linux/dccp.h", + "linux/fs.h", + "linux/genetlink.h", + "linux/if_alg.h", + "linux/if_ether.h", + "linux/if_tun.h", + "linux/magic.h", + "linux/memfd.h", + "linux/module.h", + "linux/net_tstamp.h", + "linux/netfilter/nf_tables.h", + "linux/netfilter_ipv4.h", + "linux/netfilter_ipv6.h", + "linux/netlink.h", + "linux/quota.h", + "linux/reboot.h", + "linux/seccomp.h", + "linux/sockios.h", + "locale.h", + "malloc.h", + "net/ethernet.h", + "net/if.h", + "net/if_arp.h", + "net/route.h", + "netdb.h", + "netinet/in.h", + "netinet/ip.h", + "netinet/tcp.h", + "netinet/udp.h", + "netpacket/packet.h", + "poll.h", + "pthread.h", + "pty.h", + "pwd.h", + "resolv.h", + "sched.h", + "semaphore.h", + "signal.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/epoll.h", + "sys/eventfd.h", + "sys/file.h", + "sys/fsuid.h", + "sys/inotify.h", + "sys/ioctl.h", + "sys/mman.h", + "sys/mount.h", + "sys/personality.h", + "sys/prctl.h", + "sys/ptrace.h", + "sys/reboot.h", + "sys/resource.h", + "sys/sendfile.h", + "sys/signalfd.h", + "sys/socket.h", + "sys/stat.h", + "sys/statvfs.h", + "sys/swap.h", + "sys/syscall.h", + "sys/sysinfo.h", + "sys/time.h", + "sys/times.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/utsname.h", + "sys/vfs.h", + "sys/wait.h", + "syslog.h", + "termios.h", + "time.h", + "unistd.h", + "utime.h", + "utmp.h", + "wchar.h", + "xlocale.h", + } + + if target_pointer_width == 32 { + // time64_t is not defined for 64-bit targets If included it will + // generate the error 'Your time_t is already 64-bit' + cfg.header("time64.h"); + } + if x86 { + cfg.header("sys/reg.h"); + } + + cfg.type_name(move |ty, is_struct, is_union| { + match ty { + // Just pass all these through, no need for a "struct" prefix + // FIXME: still required ? + "FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" + | "Elf64_Phdr" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym" + | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr" + | "Elf64_Chdr" => ty.to_string(), + + t if is_union => format!("union {}", t), + + t if t.ends_with("_t") => t.to_string(), + + // put `struct` in front of all structs:. + t if is_struct => format!("struct {}", t), + + t => t.to_string(), + } + }); + + cfg.field_name(move |struct_, field| { + match field { + // Our stat *_nsec fields normally don't actually exist but are part + // of a timeval struct + s if s.ends_with("_nsec") && struct_.starts_with("stat") => { + s.to_string() + } + // FIXME: still necessary? + "u64" if struct_ == "epoll_event" => "data.u64".to_string(), + s => s.to_string(), + } + }); + + cfg.skip_type(move |ty| { + match ty { + // sighandler_t is crazy across platforms + // FIXME: still necessary? + "sighandler_t" => true, + _ => false, + } + }); + + cfg.skip_struct(move |ty| { + match ty { + // This is actually a union, not a struct + // FIXME: still necessary + "sigval" => true, + + // These structs have changed since unified headers in NDK r14b. + // `st_atime` and `st_atime_nsec` have changed sign. + // FIXME: unskip it for next major release + "stat" | "stat64" => true, + + // These are tested as part of the linux_fcntl tests since there are + // header conflicts when including them with all the other structs. + // FIXME: still necessary + "termios2" => true, + + _ => false, + } + }); + + cfg.skip_signededness(move |c| { + match c { + // FIXME: still necessary? + "LARGE_INTEGER" | "float" | "double" => true, + // FIXME: still necessary? + n if n.starts_with("pthread") => true, + _ => false, + } + }); + + cfg.skip_const(move |name| { + match name { + // FIXME: still necessary? + "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness + // FIXME: still necessary? + "SIGUNUSED" => true, // removed in glibc 2.26 + + // weird signed extension or something like that? + // FIXME: still necessary? + "MS_NOUSER" => true, + // FIXME: still necessary? + "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13 + + // Android uses old kernel headers + // These are constants used in getrandom syscall + // FIXME: still necessary? + "GRND_NONBLOCK" | "GRND_RANDOM" => true, + + // Defined by libattr not libc on linux (hard to test). + // See constant definition for more details. + // FIXME: still necessary? + "ENOATTR" => true, + + // FIXME: still necessary? + "BOTHER" => true, + + // MFD_HUGETLB is not available in some older libc versions on the CI builders. On the + // x86_64 and i686 builders it seems to be available for all targets, so at least test + // it there. + // FIXME: still necessary? + "MFD_HUGETLB" => true, + + // These change all the time from release to release of linux + // distros, let's just not bother trying to verify them. They + // shouldn't be used in code anyway... + // FIXME: still necessary? + "AF_MAX" | "PF_MAX" => true, + + _ => false, + } + }); + + cfg.skip_fn(move |name| { + // skip those that are manually verified + match name { + // FIXME: still necessary? + "execv" | // crazy stuff with const/mut + "execve" | + "execvp" | + "execvpe" | + "fexecve" => true, + + // typed 2nd arg on android + // FIXME: still necessary? + "gettimeofday" => true, + + // not declared in newer android toolchains + // FIXME: still necessary? + "getdtablesize" => true, + + // FIXME: still necessary? + "dlerror" => true, // const-ness is added + + // Apparently the NDK doesn't have this defined on android, but + // it's in a header file? + // FIXME: still necessary? + "endpwent" => true, + + // Apparently res_init exists on Android, but isn't defined in a header: + // https://mail.gnome.org/archives/commits-list/2013-May/msg01329.html + // FIXME: still necessary? + "res_init" => true, + + // Definition of those functions as changed since unified headers from NDK r14b + // These changes imply some API breaking changes but are still ABI compatible. + // We can wait for the next major release to be compliant with the new API. + // FIXME: unskip these for next major release + "strerror_r" | "madvise" | "msync" | "mprotect" | "recvfrom" | "getpriority" | + "setpriority" | "personality" => true, + // In Android 64 bits, these functions have been fixed since unified headers. + // Ignore these until next major version. + "bind" | "writev" | "readv" | "sendmsg" | "recvmsg" + if target_pointer_width == 64 => true, + + _ => false, + } + }); + + cfg.skip_static(move |name| { + match name { + // Internal constant, not declared in any headers. + // FIXME: still necessary + "__progname" => true, + _ => false, + } + }); + + // FIXME: still necessary? + cfg.skip_field_type(move |struct_, field| { + // This is a weird union, don't check the type. + (struct_ == "ifaddrs" && field == "ifa_ifu") || + // sighandler_t type is super weird + (struct_ == "sigaction" && field == "sa_sigaction") || + // sigval is actually a union, but we pretend it's a struct + (struct_ == "sigevent" && field == "sigev_value") || + // aio_buf is "volatile void*" and Rust doesn't understand volatile + (struct_ == "aiocb" && field == "aio_buf") + }); + + // FIXME: still necessary? + cfg.skip_field(move |struct_, field| { + // this is actually a union on linux, so we can't represent it well and + // just insert some padding. + (struct_ == "siginfo_t" && field == "_pad") || + // sigev_notify_thread_id is actually part of a sigev_un union + (struct_ == "sigevent" && field == "sigev_notify_thread_id") || + // signalfd had SIGSYS fields added in Linux 4.18, but no libc release has them yet. + (struct_ == "signalfd_siginfo" && (field == "ssi_addr_lsb" || + field == "_pad2" || + field == "ssi_syscall" || + field == "ssi_call_addr" || + field == "ssi_arch")) + }); + + // FIXME: remove + cfg.fn_cname(move |name, _cname| name.to_string()); + + cfg.generate("../src/lib.rs", "main.rs"); + + // On Android also generate another script for testing linux/fcntl + // declarations. These cannot be tested normally because including both + // `linux/fcntl.h` and `fcntl.h` fails. + // + // FIXME: is still necessary? + let mut cfg = ctest::TestGenerator::new(); + cfg.skip_type(|_| true) + .skip_fn(|_| true) + .skip_static(|_| true); + cfg.header("linux/fcntl.h"); + cfg.header("net/if.h"); + cfg.header("linux/if.h"); + cfg.header("linux/quota.h"); + cfg.header("asm/termbits.h"); + cfg.skip_const(move |name| match name { + "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => false, + "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => { + false + } + "BOTHER" => false, + _ => true, + }); + cfg.skip_struct(|s| s != "termios2"); + cfg.type_name(move |ty, is_struct, is_union| match ty { + t if is_struct => format!("struct {}", t), + t if is_union => format!("union {}", t), + t => t.to_string(), + }); + cfg.generate("../src/lib.rs", "linux_fcntl.rs"); +} From 89a3d03aa73fecc9be8900e8ba126f3cdde9ee66 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 14 May 2019 10:06:45 +0200 Subject: [PATCH 02/50] Update Android Docker images Ubuntu version --- ci/docker/aarch64-linux-android/Dockerfile | 2 +- ci/docker/arm-linux-androideabi/Dockerfile | 2 +- ci/docker/i686-linux-android/Dockerfile | 2 +- ci/docker/x86_64-linux-android/Dockerfile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ci/docker/aarch64-linux-android/Dockerfile b/ci/docker/aarch64-linux-android/Dockerfile index 5fc83aadb333d..d8e9ae638e13a 100644 --- a/ci/docker/aarch64-linux-android/Dockerfile +++ b/ci/docker/aarch64-linux-android/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:16.04 +FROM ubuntu:18.04 RUN dpkg --add-architecture i386 && \ apt-get update && \ diff --git a/ci/docker/arm-linux-androideabi/Dockerfile b/ci/docker/arm-linux-androideabi/Dockerfile index a3fc64bfd52f3..2d9f4dbaa8d2b 100644 --- a/ci/docker/arm-linux-androideabi/Dockerfile +++ b/ci/docker/arm-linux-androideabi/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:16.04 +FROM ubuntu:18.04 RUN dpkg --add-architecture i386 && \ apt-get update && \ diff --git a/ci/docker/i686-linux-android/Dockerfile b/ci/docker/i686-linux-android/Dockerfile index f0836c38538e0..e67e6e3e3cdaf 100644 --- a/ci/docker/i686-linux-android/Dockerfile +++ b/ci/docker/i686-linux-android/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:16.04 +FROM ubuntu:18.04 RUN dpkg --add-architecture i386 && \ apt-get update && \ diff --git a/ci/docker/x86_64-linux-android/Dockerfile b/ci/docker/x86_64-linux-android/Dockerfile index 0cfbc4820903a..62e61b1e31eba 100644 --- a/ci/docker/x86_64-linux-android/Dockerfile +++ b/ci/docker/x86_64-linux-android/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:16.04 +FROM ubuntu:18.04 RUN apt-get update && \ apt-get install -y --no-install-recommends \ From 3c2284c43512ee7b621aa5828663559bfb5dc581 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 14 May 2019 10:15:19 +0200 Subject: [PATCH 03/50] Remove OpenBSD-related dead-code --- libc-test/build.rs | 38 ++++++-------------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index bb0252397b46e..4025027a35e9b 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -23,8 +23,7 @@ fn do_ctest() { let uclibc = target.contains("uclibc"); let freebsd = target.contains("freebsd"); let mips = target.contains("mips"); - let openbsd = target.contains("openbsd"); - let bsdlike = freebsd || openbsd; + let bsdlike = freebsd; let mut cfg = ctest::TestGenerator::new(); match &target { @@ -113,7 +112,7 @@ fn do_ctest() { cfg.header("ifaddrs.h"); cfg.header("langinfo.h"); - if !openbsd && !freebsd { + if !freebsd { cfg.header("sys/quota.h"); } @@ -122,15 +121,11 @@ fn do_ctest() { } if !musl && !uclibc { - if !openbsd && !uclibc { + if !uclibc { cfg.header("execinfo.h"); } - if openbsd { - cfg.header("utmp.h"); - } else { - cfg.header("utmpx.h"); - } + cfg.header("utmpx.h"); } if bsdlike { @@ -252,12 +247,6 @@ fn do_ctest() { cfg.header("spawn.h"); } - if openbsd { - cfg.header("ufs/ufs/quota.h"); - cfg.header("pthread_np.h"); - cfg.header("sys/syscall.h"); - } - if linux || freebsd || emscripten { if !uclibc { cfg.header("aio.h"); @@ -288,12 +277,6 @@ fn do_ctest() { cfg.field_name(move |struct_, field| { match field { - "st_birthtime" if openbsd && struct_ == "stat" => { - "__st_birthtime".to_string() - } - "st_birthtime_nsec" if openbsd && struct_ == "stat" => { - "__st_birthtimensec".to_string() - } // Our stat *_nsec fields normally don't actually exist but are part // of a timeval struct s if s.ends_with("_nsec") && struct_.starts_with("stat") => { @@ -351,7 +334,7 @@ fn do_ctest() { "LARGE_INTEGER" | "float" | "double" => true, n if n.starts_with("pthread") => true, // sem_t is a struct or pointer - "sem_t" if openbsd || freebsd => true, + "sem_t" if freebsd => true, // mqd_t is a pointer on FreeBSD "mqd_t" if freebsd => true, @@ -409,10 +392,6 @@ fn do_ctest() { // These constants were added in FreeBSD 12 "SF_USER_READAHEAD" | "SO_REUSEPORT_LB" if freebsd => true, - // These constants were removed in OpenBSD 6 (https://git.io/v7gBO - // https://git.io/v7gBq) - "KERN_USERMOUNT" | "KERN_ARND" if openbsd => true, - // These are either unimplemented or optionally built into uClibc "LC_CTYPE_MASK" | "LC_NUMERIC_MASK" @@ -554,7 +533,7 @@ fn do_ctest() { "sendmmsg" | "recvmmsg" if musl => true, // typed 2nd arg on linux - "gettimeofday" if linux || freebsd || openbsd => true, + "gettimeofday" if linux || freebsd => true, "dladdr" if musl => true, // const-ness only added recently @@ -605,9 +584,6 @@ fn do_ctest() { // We can wait for the next major release to be compliant with the new API. // FIXME: unskip these for next major release "strerror_r" | "madvise" | "msync" | "mprotect" | "recvfrom" | "getpriority" | - // Removed in OpenBSD 6.5 - // https://marc.info/?l=openbsd-cvs&m=154723400730318 - "mincore" if openbsd => true, _ => false, } @@ -626,8 +602,6 @@ fn do_ctest() { (struct_ == "aiocb" && field == "aio_buf") || // stack_t.ss_sp's type changed from FreeBSD 10 to 11 in svn r294930 (freebsd && struct_ == "stack_t" && field == "ss_sp") || - // type siginfo_t.si_addr changed from OpenBSD 6.0 to 6.1 - (openbsd && struct_ == "siginfo_t" && field == "si_addr") || // this one is an anonymous union (linux && struct_ == "ff_effect" && field == "u") }); From b976dc2055fa00f492cca6613db35ce0a7eb76ba Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 14 May 2019 10:39:26 +0200 Subject: [PATCH 04/50] Refactor FreeBSD target --- libc-test/build.rs | 431 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 327 insertions(+), 104 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 4025027a35e9b..45e0b0836804c 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -21,9 +21,7 @@ fn do_ctest() { let emscripten = target.contains("asm"); let musl = target.contains("musl") || emscripten; let uclibc = target.contains("uclibc"); - let freebsd = target.contains("freebsd"); let mips = target.contains("mips"); - let bsdlike = freebsd; let mut cfg = ctest::TestGenerator::new(); match &target { @@ -37,15 +35,12 @@ fn do_ctest() { t if t.contains("dragonfly") => return test_dragonflybsd(t), t if t.contains("wasi") => return test_wasi(t), t if t.contains("android") => return test_android(t), + t if t.contains("freebsd") => return test_freebsd(t), _ => (), } // Pull in extra goodies - if linux || emscripten { - cfg.define("_GNU_SOURCE", None); - } else if freebsd { - cfg.define("_WITH_GETLINE", None); - } + cfg.define("_GNU_SOURCE", None); cfg.header("errno.h") .header("fcntl.h") @@ -112,9 +107,7 @@ fn do_ctest() { cfg.header("ifaddrs.h"); cfg.header("langinfo.h"); - if !freebsd { - cfg.header("sys/quota.h"); - } + cfg.header("sys/quota.h"); if !musl && !x32 { cfg.header("sys/sysctl.h"); @@ -128,17 +121,6 @@ fn do_ctest() { cfg.header("utmpx.h"); } - if bsdlike { - cfg.header("sys/event.h"); - cfg.header("net/if_dl.h"); - if freebsd { - cfg.header("net/bpf.h"); - cfg.header("libutil.h"); - } else { - cfg.header("util.h"); - } - } - if linux || emscripten { cfg.header("mntent.h"); cfg.header("mqueue.h"); @@ -232,22 +214,7 @@ fn do_ctest() { cfg.header("spawn.h"); } - if freebsd { - cfg.header("mqueue.h"); - cfg.header("pthread_np.h"); - cfg.header("sched.h"); - cfg.header("ufs/ufs/quota.h"); - cfg.header("sys/extattr.h"); - cfg.header("sys/jail.h"); - cfg.header("sys/ipc.h"); - cfg.header("sys/msg.h"); - cfg.header("sys/shm.h"); - cfg.header("sys/procdesc.h"); - cfg.header("sys/rtprio.h"); - cfg.header("spawn.h"); - } - - if linux || freebsd || emscripten { + if linux || emscripten { if !uclibc { cfg.header("aio.h"); } @@ -261,9 +228,6 @@ fn do_ctest() { | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr" | "Elf64_Chdr" => ty.to_string(), - // OSX calls this something else - "sighandler_t" if bsdlike => "sig_t".to_string(), - t if is_union => format!("union {}", t), t if t.ends_with("_t") => t.to_string(), @@ -284,7 +248,7 @@ fn do_ctest() { } "u64" if struct_ == "epoll_event" => "data.u64".to_string(), "type_" - if (linux || freebsd) + if linux && (struct_ == "input_event" || struct_ == "input_mask" || struct_ == "ff_effect" @@ -329,17 +293,10 @@ fn do_ctest() { } }); - cfg.skip_signededness(move |c| { - match c { - "LARGE_INTEGER" | "float" | "double" => true, - n if n.starts_with("pthread") => true, - // sem_t is a struct or pointer - "sem_t" if freebsd => true, - // mqd_t is a pointer on FreeBSD - "mqd_t" if freebsd => true, - - _ => false, - } + cfg.skip_signededness(move |c| match c { + "LARGE_INTEGER" | "float" | "double" => true, + n if n.starts_with("pthread") => true, + _ => false, }); cfg.skip_const(move |name| { @@ -367,31 +324,6 @@ fn do_ctest() { "MS_NOUSER" => true, "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13 - // These constants were removed in FreeBSD 11 (svn r273250) but will - // still be accepted and ignored at runtime. - "MAP_RENAME" | "MAP_NORESERVE" if freebsd => true, - - // These constants were removed in FreeBSD 11 (svn r262489), - // and they've never had any legitimate use outside of the - // base system anyway. - "CTL_MAXID" | "KERN_MAXID" | "HW_MAXID" | "NET_MAXID" - | "USER_MAXID" - if freebsd => - { - true - } - - // These constants were added in FreeBSD 11 - "EVFILT_PROCDESC" | "EVFILT_SENDFILE" | "EVFILT_EMPTY" - | "PD_CLOEXEC" | "PD_ALLOWED_AT_FORK" - if freebsd => - { - true - } - - // These constants were added in FreeBSD 12 - "SF_USER_READAHEAD" | "SO_REUSEPORT_LB" if freebsd => true, - // These are either unimplemented or optionally built into uClibc "LC_CTYPE_MASK" | "LC_NUMERIC_MASK" @@ -499,16 +431,6 @@ fn do_ctest() { true } - | "IP_ORIGDSTADDR" - | "IP_RECVORIGDSTADDR" - | "IPV6_ORIGDSTADDR" - | "IPV6_RECVORIGDSTADDR" - if freebsd => - { - // FreeBSD 12 required, but CI has FreeBSD 11. - true - } - _ => false, } }); @@ -533,7 +455,7 @@ fn do_ctest() { "sendmmsg" | "recvmmsg" if musl => true, // typed 2nd arg on linux - "gettimeofday" if linux || freebsd => true, + "gettimeofday" if linux => true, "dladdr" if musl => true, // const-ness only added recently @@ -553,20 +475,6 @@ fn do_ctest() { // [3]: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/sys/eventfd.h;h=6295f32e937e779e74318eb9d3bdbe76aef8a8f3;hb=4e42b5b8f89f0e288e68be7ad70f9525aebc2cff#l34 "eventfd" if linux => true, - // The `uname` function in freebsd is now an inline wrapper that - // delegates to another, but the symbol still exists, so don't check - // the symbol. - "uname" if freebsd => true, - - // FIXME: need to upgrade FreeBSD version; see https://github.com/rust-lang/libc/issues/938 - "setgrent" if freebsd => true, - - // aio_waitcomplete's return type changed between FreeBSD 10 and 11. - "aio_waitcomplete" if freebsd => true, - - // lio_listio confuses the checker, probably because one of its - // arguments is an array - "lio_listio" if freebsd => true, "lio_listio" if musl => true, // These are either unimplemented or optionally built into uClibc @@ -600,8 +508,6 @@ fn do_ctest() { (struct_ == "sigevent" && field == "sigev_value") || // aio_buf is "volatile void*" and Rust doesn't understand volatile (struct_ == "aiocb" && field == "aio_buf") || - // stack_t.ss_sp's type changed from FreeBSD 10 to 11 in svn r294930 - (freebsd && struct_ == "stack_t" && field == "ss_sp") || // this one is an anonymous union (linux && struct_ == "ff_effect" && field == "u") }); @@ -2209,3 +2115,320 @@ fn test_android(target: &str) { }); cfg.generate("../src/lib.rs", "linux_fcntl.rs"); } + +fn test_freebsd(target: &str) { + assert!(target.contains("freebsd")); + let x86 = target.contains("i686") || target.contains("x86_64"); + + let mut cfg = ctest::TestGenerator::new(); + // FIXME: still necessary? + cfg.define("_WITH_GETLINE", None); + + // FIXME: still necessary? + cfg.flag("-Wno-deprecated-declarations"); + + headers! { cfg: + "aio.h", + "arpa/inet.h", + "ctype.h", + "dirent.h", + "dlfcn.h", + "errno.h", + "fcntl.h", + "glob.h", + "grp.h", + "ifaddrs.h", + "langinfo.h", + "libutil.h", + "limits.h", + "locale.h", + "mqueue.h", + "net/bpf.h", + "net/if.h", + "net/if_arp.h", + "net/if_dl.h", + "net/route.h", + "netdb.h", + "netinet/in.h", + "netinet/tcp.h", + "netinet/udp.h", + "poll.h", + "pthread.h", + "pthread_np.h", + "pwd.h", + "resolv.h", + "sched.h", + "semaphore.h", + "signal.h", + "spawn.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/event.h", + "sys/extattr.h", + "sys/file.h", + "sys/ioctl.h", + "sys/ipc.h", + "sys/jail.h", + "sys/mman.h", + "sys/mount.h", + "sys/msg.h", + "sys/procdesc.h", + "sys/ptrace.h", + "sys/resource.h", + "sys/rtprio.h", + "sys/shm.h", + "sys/socket.h", + "sys/stat.h", + "sys/statvfs.h", + "sys/time.h", + "sys/times.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/utsname.h", + "sys/wait.h", + "syslog.h", + "termios.h", + "time.h", + "ufs/ufs/quota.h", + "unistd.h", + "utime.h", + "wchar.h", + } + + cfg.type_name(move |ty, is_struct, is_union| { + match ty { + // Just pass all these through, no need for a "struct" prefix + // FIXME: still required? + "FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" + | "Elf64_Phdr" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym" + | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr" + | "Elf64_Chdr" => ty.to_string(), + + // FIXME: still required? + "sighandler_t" => "sig_t".to_string(), + + t if is_union => format!("union {}", t), + + t if t.ends_with("_t") => t.to_string(), + + // put `struct` in front of all structs:. + t if is_struct => format!("struct {}", t), + + t => t.to_string(), + } + }); + + cfg.field_name(move |struct_, field| { + match field { + // Our stat *_nsec fields normally don't actually exist but are part + // of a timeval struct + s if s.ends_with("_nsec") && struct_.starts_with("stat") => { + s.replace("e_nsec", ".tv_nsec") + } + // FIXME: still required? + "u64" if struct_ == "epoll_event" => "data.u64".to_string(), + // FIXME: still required? + "type_" + if struct_ == "input_event" + || struct_ == "input_mask" + || struct_ == "ff_effect" + || struct_ == "rtprio" => + { + "type".to_string() + } + s => s.to_string(), + } + }); + + cfg.skip_type(move |ty| { + match ty { + // sighandler_t is crazy across platforms + // FIXME: still required? + "sighandler_t" => true, + + _ => false, + } + }); + + cfg.skip_struct(move |ty| { + match ty { + // This is actually a union, not a struct + // FIXME: still required? + "sigval" => true, + + // These are tested as part of the linux_fcntl tests since there are + // header conflicts when including them with all the other structs. + // FIXME: still required? + "termios2" => true, + + _ => false, + } + }); + + cfg.skip_signededness(move |c| { + match c { + // FIXME: still required? + "LARGE_INTEGER" | "float" | "double" => true, + // FIXME: still required? + n if n.starts_with("pthread") => true, + // sem_t is a struct or pointer + // FIXME: still required? + "sem_t" => true, + // mqd_t is a pointer on FreeBSD + // FIXME: still required? + "mqd_t" => true, + + _ => false, + } + }); + + cfg.skip_const(move |name| { + match name { + // FIXME: still required? + "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness + // FIXME: still required? + "SIGUNUSED" => true, // removed in glibc 2.26 + + // weird signed extension or something like that? + // FIXME: still required? + "MS_NOUSER" => true, + // FIXME: still required? + "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13 + + // These constants were removed in FreeBSD 11 (svn r273250) but will + // still be accepted and ignored at runtime. + "MAP_RENAME" | "MAP_NORESERVE" => true, + + // These constants were removed in FreeBSD 11 (svn r262489), + // and they've never had any legitimate use outside of the + // base system anyway. + "CTL_MAXID" | "KERN_MAXID" | "HW_MAXID" | "NET_MAXID" + | "USER_MAXID" => true, + + // These constants were added in FreeBSD 11 + // FIXME: still required? + "EVFILT_PROCDESC" | "EVFILT_SENDFILE" | "EVFILT_EMPTY" + | "PD_CLOEXEC" | "PD_ALLOWED_AT_FORK" => true, + + // These constants were added in FreeBSD 12 + // FIXME: still required? + "SF_USER_READAHEAD" | "SO_REUSEPORT_LB" => true, + + // These constants are tested in a separate test program generated + // below because there are header conflicts if we try to include the + // headers that define them here. + // FIXME: still required? + "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => true, + // FIXME: still required? + "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" + | "F_SEAL_WRITE" => true, + // FIXME: still required? + "BOTHER" => true, + + // MFD_HUGETLB is not available in some older libc versions on the + // CI builders. On the x86_64 and i686 builders it seems to be + // available for all targets, so at least test it there. + // FIXME: still required? + "MFD_HUGETLB" if !x86 => true, + + // These change all the time from release to release of linux + // distros, let's just not bother trying to verify them. They + // shouldn't be used in code anyway... + // FIXME: still required? + "AF_MAX" | "PF_MAX" => true, + + // FreeBSD 12 required, but CI has FreeBSD 11. + // FIXME: still required? + "IP_ORIGDSTADDR" + | "IP_RECVORIGDSTADDR" + | "IPV6_ORIGDSTADDR" + | "IPV6_RECVORIGDSTADDR" => true, + + _ => false, + } + }); + + cfg.skip_fn(move |name| { + // skip those that are manually verified + match name { + // FIXME: still required? + "execv" | // crazy stuff with const/mut + "execve" | + "execvp" | + "execvpe" | + "fexecve" => true, + + // The `uname` function in freebsd is now an inline wrapper that + // delegates to another, but the symbol still exists, so don't check + // the symbol. + // FIXME: still required? + "uname" => true, + + // FIXME: need to upgrade FreeBSD version; see https://github.com/rust-lang/libc/issues/938 + // FIXME: still required? + "setgrent" => true, + + // aio_waitcomplete's return type changed between FreeBSD 10 and 11. + // FIXME: still required? + "aio_waitcomplete" => true, + + // lio_listio confuses the checker, probably because one of its + // arguments is an array + // FIXME: still required? + "lio_listio" => true, + + // Definition of those functions as changed since unified headers from NDK r14b + // These changes imply some API breaking changes but are still ABI compatible. + // We can wait for the next major release to be compliant with the new API. + // FIXME: unskip these for next major release + // FIXME: still required ? + "strerror_r" | "madvise" | "msync" | "mprotect" | "recvfrom" | "getpriority" | + + _ => false, + } + }); + + cfg.skip_field_type(move |struct_, field| { + // This is a weird union, don't check the type. + // FIXME: still required? + (struct_ == "ifaddrs" && field == "ifa_ifu") || + // FIXME: still required? + // sighandler_t type is super weird + (struct_ == "sigaction" && field == "sa_sigaction") || + // FIXME: still required? + // sigval is actually a union, but we pretend it's a struct + (struct_ == "sigevent" && field == "sigev_value") || + // aio_buf is "volatile void*" and Rust doesn't understand volatile + // FIXME: still required? + (struct_ == "aiocb" && field == "aio_buf") || + // stack_t.ss_sp's type changed from FreeBSD 10 to 11 in svn r294930 + // FIXME: still required? + (struct_ == "stack_t" && field == "ss_sp") + }); + + cfg.skip_field(move |struct_, field| { + // this is actually a union on linux, so we can't represent it well and + // just insert some padding. + // FIXME: still required? + (struct_ == "siginfo_t" && field == "_pad") || + // sigev_notify_thread_id is actually part of a sigev_un union + // FIXME: still required? + (struct_ == "sigevent" && field == "sigev_notify_thread_id") || + // signalfd had SIGSYS fields added in Linux 4.18, but no libc release has them yet. + // FIXME: still required? + (struct_ == "signalfd_siginfo" && (field == "ssi_addr_lsb" || + field == "_pad2" || + field == "ssi_syscall" || + field == "ssi_call_addr" || + field == "ssi_arch")) + }); + + // FIXME: remove + cfg.fn_cname(move |name, _cname| name.to_string()); + + cfg.generate("../src/lib.rs", "main.rs"); +} From ac90c574e5a8a9c69c195929af583de45c525876 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 14 May 2019 11:55:26 +0200 Subject: [PATCH 05/50] Refactor Linux target --- libc-test/build.rs | 3374 ++++++++++++++++++++++++-------------------- 1 file changed, 1870 insertions(+), 1504 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 45e0b0836804c..567fa975612b1 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -13,600 +13,613 @@ fn do_cc() { } fn do_ctest() { - let target = env::var("TARGET").unwrap(); - let i686 = target.contains("i686"); - let x86_64 = target.contains("x86_64"); - let x32 = target.ends_with("gnux32"); - let linux = target.contains("unknown-linux"); - let emscripten = target.contains("asm"); - let musl = target.contains("musl") || emscripten; - let uclibc = target.contains("uclibc"); - let mips = target.contains("mips"); - let mut cfg = ctest::TestGenerator::new(); - - match &target { + match &env::var("TARGET").unwrap() { + t if t.contains("android") => return test_android(t), t if t.contains("apple") => return test_apple(t), + t if t.contains("cloudabi") => return test_cloudabi(t), + t if t.contains("dragonfly") => return test_dragonflybsd(t), + t if t.contains("emscripten") => return test_emscripten(t), + t if t.contains("freebsd") => return test_freebsd(t), + t if t.contains("linux") => return test_linux(t), + t if t.contains("netbsd") => return test_netbsd(t), t if t.contains("openbsd") => return test_openbsd(t), - t if t.contains("windows") => return test_windows(t), t if t.contains("redox") => return test_redox(t), - t if t.contains("cloudabi") => return test_cloudabi(t), t if t.contains("solaris") => return test_solaris(t), - t if t.contains("netbsd") => return test_netbsd(t), - t if t.contains("dragonfly") => return test_dragonflybsd(t), t if t.contains("wasi") => return test_wasi(t), - t if t.contains("android") => return test_android(t), - t if t.contains("freebsd") => return test_freebsd(t), - _ => (), + t if t.contains("windows") => return test_windows(t), + t => panic!("unknown target {}", t), } +} - // Pull in extra goodies - cfg.define("_GNU_SOURCE", None); +fn main() { + do_cc(); + do_ctest(); +} + +macro_rules! headers { + ($cfg:ident: $header:expr) => { + $cfg.header($header); + }; + ($cfg:ident: $($header:expr),*) => { + $(headers!($cfg: $header);)* + }; + ($cfg:ident: $($header:expr,)*) => { + $(headers!($cfg: $header);)* + }; +} - cfg.header("errno.h") - .header("fcntl.h") - .header("limits.h") - .header("locale.h") - .header("stddef.h") - .header("stdint.h") - .header("stdio.h") - .header("stdlib.h") - .header("sys/stat.h") - .header("sys/types.h") - .header("time.h") - .header("wchar.h"); +fn test_apple(target: &str) { + assert!(target.contains("apple")); + let x86_64 = target.contains("x86_64"); + let mut cfg = ctest::TestGenerator::new(); cfg.flag("-Wno-deprecated-declarations"); + cfg.define("__APPLE_USE_RFC_3542", None); - cfg.header("ctype.h"); - cfg.header("dirent.h"); - cfg.header("net/if.h"); - cfg.header("net/route.h"); - cfg.header("net/if_arp.h"); - if linux { - cfg.header("linux/if_alg.h"); - } - cfg.header("netdb.h"); - cfg.header("netinet/in.h"); - cfg.header("netinet/ip.h"); - cfg.header("netinet/tcp.h"); - cfg.header("netinet/udp.h"); - cfg.header("resolv.h"); - cfg.header("pthread.h"); - cfg.header("dlfcn.h"); - cfg.header("signal.h"); - cfg.header("string.h"); - cfg.header("sys/file.h"); - cfg.header("sys/ioctl.h"); - cfg.header("sys/mman.h"); - cfg.header("sys/resource.h"); - cfg.header("sys/socket.h"); - if linux && !musl { - cfg.header("linux/if.h"); - cfg.header("sys/auxv.h"); - } - cfg.header("sys/time.h"); - cfg.header("sys/un.h"); - cfg.header("sys/wait.h"); - cfg.header("unistd.h"); - cfg.header("utime.h"); - cfg.header("pwd.h"); - cfg.header("grp.h"); - cfg.header("sys/utsname.h"); - cfg.header("sys/ptrace.h"); - cfg.header("sys/mount.h"); - cfg.header("sys/uio.h"); - cfg.header("sched.h"); - cfg.header("termios.h"); - cfg.header("poll.h"); - cfg.header("syslog.h"); - cfg.header("semaphore.h"); - cfg.header("sys/statvfs.h"); - cfg.header("sys/times.h"); - - cfg.header("glob.h"); - cfg.header("ifaddrs.h"); - cfg.header("langinfo.h"); - - cfg.header("sys/quota.h"); - - if !musl && !x32 { - cfg.header("sys/sysctl.h"); + headers! { cfg: + "aio.h", + "ctype.h", + "dirent.h", + "dlfcn.h", + "errno.h", + "execinfo.h", + "fcntl.h", + "glob.h", + "grp.h", + "ifaddrs.h", + "langinfo.h", + "limits.h", + "locale.h", + "mach-o/dyld.h", + "mach/mach_time.h", + "malloc/malloc.h", + "net/bpf.h", + "net/if.h", + "net/if_arp.h", + "net/if_dl.h", + "net/if_utun.h", + "net/route.h", + "net/route.h", + "netdb.h", + "netinet/if_ether.h", + "netinet/in.h", + "netinet/in.h", + "netinet/ip.h", + "netinet/tcp.h", + "netinet/udp.h", + "poll.h", + "pthread.h", + "pwd.h", + "resolv.h", + "sched.h", + "semaphore.h", + "signal.h", + "spawn.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/event.h", + "sys/file.h", + "sys/ioctl.h", + "sys/ipc.h", + "sys/kern_control.h", + "sys/mman.h", + "sys/mount.h", + "sys/proc_info.h", + "sys/ptrace.h", + "sys/quota.h", + "sys/resource.h", + "sys/sem.h", + "sys/shm.h", + "sys/socket.h", + "sys/stat.h", + "sys/statvfs.h", + "sys/sys_domain.h", + "sys/sysctl.h", + "sys/time.h", + "sys/times.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/utsname.h", + "sys/wait.h", + "sys/xattr.h", + "syslog.h", + "termios.h", + "time.h", + "unistd.h", + "util.h", + "utime.h", + "utmpx.h", + "wchar.h", + "xlocale.h", } - if !musl && !uclibc { - if !uclibc { - cfg.header("execinfo.h"); - } - - cfg.header("utmpx.h"); + if x86_64 { + headers! { cfg: "crt_externs.h" } } - if linux || emscripten { - cfg.header("mntent.h"); - cfg.header("mqueue.h"); - cfg.header("ucontext.h"); - if !uclibc { - // optionally included in uclibc - cfg.header("sys/xattr.h"); - } - cfg.header("sys/ipc.h"); - cfg.header("sys/sem.h"); - cfg.header("sys/msg.h"); - cfg.header("sys/shm.h"); - cfg.header("sys/user.h"); - cfg.header("sys/timerfd.h"); - cfg.header("shadow.h"); - if !emscripten { - cfg.header("linux/input.h"); - cfg.header("linux/falloc.h"); - } - if x86_64 { - cfg.header("sys/io.h"); - } - if i686 || x86_64 { - cfg.header("sys/reg.h"); + cfg.skip_struct(move |ty| { + match ty { + // FIXME: actually a union + "sigval" => true, + + _ => false, } - } + }); - if linux || emscripten { - cfg.header("malloc.h"); - cfg.header("net/ethernet.h"); - cfg.header("netpacket/packet.h"); - cfg.header("sched.h"); - cfg.header("sys/epoll.h"); - cfg.header("sys/eventfd.h"); - cfg.header("sys/prctl.h"); - cfg.header("sys/sendfile.h"); - cfg.header("sys/signalfd.h"); - cfg.header("sys/vfs.h"); - cfg.header("sys/syscall.h"); - cfg.header("sys/personality.h"); - cfg.header("sys/swap.h"); - cfg.header("pty.h"); - cfg.header("utmp.h"); - if !uclibc { - cfg.header("sys/sysinfo.h"); - } - cfg.header("sys/reboot.h"); - if !emscripten { - cfg.header("linux/sockios.h"); - cfg.header("linux/netlink.h"); - cfg.header("linux/genetlink.h"); - cfg.header("linux/netfilter_ipv4.h"); - cfg.header("linux/netfilter_ipv6.h"); - cfg.header("linux/fs.h"); - } - if !musl { - cfg.header("asm/mman.h"); - cfg.header("linux/magic.h"); - cfg.header("linux/reboot.h"); - cfg.header("linux/netfilter/nf_tables.h"); - - if !mips { - cfg.header("linux/quota.h"); - } + cfg.skip_const(move |name| { + match name { + // These OSX constants are removed in Sierra. + // https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html + "KERN_KDENABLE_BG_TRACE" | "KERN_KDDISABLE_BG_TRACE" => true, + _ => false, } - } + }); - if linux { - cfg.header("sys/fsuid.h"); - cfg.header("linux/module.h"); - cfg.header("linux/seccomp.h"); - cfg.header("linux/if_ether.h"); - cfg.header("linux/if_tun.h"); - cfg.header("linux/net_tstamp.h"); - cfg.header("sys/inotify.h"); + cfg.skip_fn(move |name| { + // skip those that are manually verified + match name { + // FIXME: https://github.com/rust-lang/libc/issues/1272 + "execv" | "execve" | "execvp" => true, - // DCCP support - if !uclibc && !musl && !emscripten { - cfg.header("linux/dccp.h"); - } + // close calls the close_nocancel system call + "close" => true, - if !musl || mips { - cfg.header("linux/memfd.h"); + _ => false, } - } + }); - if linux { - cfg.header("linux/random.h"); - cfg.header("elf.h"); - cfg.header("link.h"); - cfg.header("spawn.h"); - } + cfg.skip_field_type(move |struct_, field| { + match (struct_, field) { + // FIXME: actually a union + ("sigevent", "sigev_value") => true, + _ => false, + } + }); - if linux || emscripten { - if !uclibc { - cfg.header("aio.h"); + cfg.volatile_item(|i| { + use ctest::VolatileItemKind::*; + match i { + StructField(ref n, ref f) if n == "aiocb" && f == "aio_buf" => { + true + } + _ => false, } - } + }); cfg.type_name(move |ty, is_struct, is_union| { match ty { // Just pass all these through, no need for a "struct" prefix - "FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" - | "Elf64_Phdr" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym" - | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr" - | "Elf64_Chdr" => ty.to_string(), + "FILE" | "DIR" | "Dl_info" => ty.to_string(), - t if is_union => format!("union {}", t), + // OSX calls this something else + "sighandler_t" => "sig_t".to_string(), + t if is_union => format!("union {}", t), t if t.ends_with("_t") => t.to_string(), - - // put `struct` in front of all structs:. t if is_struct => format!("struct {}", t), - t => t.to_string(), } }); cfg.field_name(move |struct_, field| { match field { - // Our stat *_nsec fields normally don't actually exist but are part - // of a timeval struct s if s.ends_with("_nsec") && struct_.starts_with("stat") => { - s.replace("e_nsec", ".tv_nsec") + s.replace("e_nsec", "espec.tv_nsec") } - "u64" if struct_ == "epoll_event" => "data.u64".to_string(), - "type_" - if linux - && (struct_ == "input_event" - || struct_ == "input_mask" - || struct_ == "ff_effect" - || struct_ == "rtprio") => - { - "type".to_string() + // FIXME: sigaction actually contains a union with two variants: + // a sa_sigaction with type: (*)(int, struct __siginfo *, void *) + // a sa_handler with type sig_t + "sa_sigaction" if struct_ == "sigaction" => { + "sa_handler".to_string() } s => s.to_string(), } }); - cfg.skip_type(move |ty| { - match ty { - // sighandler_t is crazy across platforms - "sighandler_t" => true, - - _ => false, - } - }); - - cfg.skip_struct(move |ty| { - match ty { - "sockaddr_nl" => musl, - - // On Linux, the type of `ut_tv` field of `struct utmpx` - // can be an anonymous struct, so an extra struct, - // which is absent in glibc, has to be defined. - "__timeval" if linux => true, - - // This is actually a union, not a struct - "sigval" => true, - - // Linux kernel headers used on musl are too old to have this - // definition. Because it's tested on other Linux targets, skip it. - "input_mask" if musl => true, - - // These are tested as part of the linux_fcntl tests since there are - // header conflicts when including them with all the other structs. - "termios2" => true, - - _ => false, - } - }); - - cfg.skip_signededness(move |c| match c { - "LARGE_INTEGER" | "float" | "double" => true, - n if n.starts_with("pthread") => true, - _ => false, - }); + cfg.generate("../src/lib.rs", "main.rs"); +} - cfg.skip_const(move |name| { - match name { - "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness - "SIGUNUSED" => true, // removed in glibc 2.26 +fn test_openbsd(target: &str) { + assert!(target.contains("openbsd")); - // types on musl are defined a little differently - n if musl && n.contains("__SIZEOF_PTHREAD") => true, + let mut cfg = ctest::TestGenerator::new(); + cfg.flag("-Wno-deprecated-declarations"); - // Skip constants not defined in MUSL but just passed down to the - // kernel regardless - "RLIMIT_NLIMITS" - | "TCP_COOKIE_TRANSACTIONS" - | "RLIMIT_RTTIME" - | "MSG_COPY" - if musl => - { - true - } - // work around super old mips toolchain - "SCHED_IDLE" | "SHM_NORESERVE" => mips, - - // weird signed extension or something like that? - "MS_NOUSER" => true, - "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13 - - // These are either unimplemented or optionally built into uClibc - "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" - | "RTLD_DEEPBIND" - | "SOL_IPV6" - | "SOL_ICMPV6" - if uclibc => - { - true - } + headers! { cfg: + "errno.h", + "fcntl.h", + "limits.h", + "locale.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "sys/stat.h", + "sys/types.h", + "time.h", + "wchar.h", + "ctype.h", + "dirent.h", + "sys/socket.h", + "net/if.h", + "net/route.h", + "net/if_arp.h", + "netdb.h", + "netinet/in.h", + "netinet/ip.h", + "netinet/tcp.h", + "netinet/udp.h", + "resolv.h", + "pthread.h", + "dlfcn.h", + "signal.h", + "string.h", + "sys/file.h", + "sys/ioctl.h", + "sys/mman.h", + "sys/resource.h", + "sys/socket.h", + "sys/time.h", + "sys/un.h", + "sys/wait.h", + "unistd.h", + "utime.h", + "pwd.h", + "grp.h", + "sys/utsname.h", + "sys/ptrace.h", + "sys/mount.h", + "sys/uio.h", + "sched.h", + "termios.h", + "poll.h", + "syslog.h", + "semaphore.h", + "sys/statvfs.h", + "sys/times.h", + "glob.h", + "ifaddrs.h", + "langinfo.h", + "sys/sysctl.h", + "utmp.h", + "sys/event.h", + "net/if_dl.h", + "util.h", + "ufs/ufs/quota.h", + "pthread_np.h", + "sys/syscall.h", + } - // Musl uses old, patched kernel headers - "FALLOC_FL_COLLAPSE_RANGE" - | "FALLOC_FL_ZERO_RANGE" - | "FALLOC_FL_INSERT_RANGE" - | "FALLOC_FL_UNSHARE_RANGE" - | "RENAME_NOREPLACE" - | "RENAME_EXCHANGE" - | "RENAME_WHITEOUT" - // ALG_SET_AEAD_* constants are available starting from kernel 3.19 - | "ALG_SET_AEAD_ASSOCLEN" - | "ALG_SET_AEAD_AUTHSIZE" - if musl => - { - true - } + cfg.skip_struct(move |ty| { + match ty { + // FIXME: actually a union + "sigval" => true, - // musl uses old kernel headers - // These are constants used in getrandom syscall - "GRND_NONBLOCK" | "GRND_RANDOM" if musl => true, + _ => false, + } + }); - // Defined by libattr not libc on linux (hard to test). - // See constant definition for more details. - "ENOATTR" if linux => true, + cfg.skip_const(move |name| { + match name { + // Removed in OpenBSD 6.0 + "KERN_USERMOUNT" | "KERN_ARND" => true, + _ => false, + } + }); - // On mips*-unknown-linux-gnu* CMSPAR cannot be included with the set of headers we - // want to use here for testing. It's originally defined in asm/termbits.h, which is - // also included by asm/termios.h, but not the standard termios.h. There's no way to - // include both asm/termbits.h and termios.h and there's no way to include both - // asm/termios.h and ioctl.h (+ some other headers) because of redeclared types. - "CMSPAR" if mips && linux && !musl => true, + cfg.skip_fn(move |name| { + match name { + "execv" | "execve" | "execvp" | "execvpe" => true, - // On mips Linux targets, MADV_SOFT_OFFLINE is currently missing, though it's been added but CI has too old - // of a Linux version. Since it exists on all other Linux targets, just ignore this for now and remove once - // it's been fixed in CI. - "MADV_SOFT_OFFLINE" if mips && linux => true, + // typed 2nd arg + "gettimeofday" => true, - // These constants are tested in a separate test program generated below because there - // are header conflicts if we try to include the headers that define them here. - "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => true, - "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" - | "F_SEAL_WRITE" => true, - "QFMT_VFS_OLD" | "QFMT_VFS_V0" | "QFMT_VFS_V1" - if mips && linux => - { - true - } // Only on MIPS - "BOTHER" => true, + // Removed in OpenBSD 6.5 + // https://marc.info/?l=openbsd-cvs&m=154723400730318 + "mincore" => true, - "MFD_CLOEXEC" | "MFD_ALLOW_SEALING" if !mips && musl => true, - // MFD_HUGETLB is not available in some older libc versions on the CI builders. On the - // x86_64 and i686 builders it seems to be available for all targets, so at least test - // it there. - "MFD_HUGETLB" - if !(x86_64 || i686) || musl => - { - true - } + _ => false, + } + }); - // These are defined for Solaris 11, but the crate is tested on - // illumos, where they are currently not defined - "EADI" - | "PORT_SOURCE_POSTWAIT" - | "PORT_SOURCE_SIGNAL" - | "PTHREAD_STACK_MIN" => true, + cfg.type_name(move |ty, is_struct, is_union| { + match ty { + // Just pass all these through, no need for a "struct" prefix + "FILE" | "DIR" | "Dl_info" => ty.to_string(), - // These change all the time from release to release of linux - // distros, let's just not bother trying to verify them. They - // shouldn't be used in code anyway... - "AF_MAX" | "PF_MAX" => true, + // OSX calls this something else + "sighandler_t" => "sig_t".to_string(), - // These are not in a glibc release yet, only in kernel headers. - "AF_XDP" - | "PF_XDP" - | "SOL_XDP" - | "IPV6_FLOWINFO" - | "IPV6_FLOWLABEL_MGR" - | "IPV6_FLOWINFO_SEND" - | "IPV6_FLOWINFO_FLOWLABEL" - | "IPV6_FLOWINFO_PRIORITY" - if linux => - { - true - } + t if is_union => format!("union {}", t), + t if t.ends_with("_t") => t.to_string(), + t if is_struct => format!("struct {}", t), + t => t.to_string(), + } + }); - _ => false, + cfg.field_name(move |struct_, field| match field { + "st_birthtime" if struct_.starts_with("stat") => { + "__st_birthtime".to_string() + } + "st_birthtime_nsec" if struct_.starts_with("stat") => { + "__st_birthtimensec".to_string() + } + s if s.ends_with("_nsec") && struct_.starts_with("stat") => { + s.replace("e_nsec", ".tv_nsec") } + "sa_sigaction" if struct_ == "sigaction" => "sa_handler".to_string(), + s => s.to_string(), }); - cfg.skip_fn(move |name| { - // skip those that are manually verified - match name { - "execv" | // crazy stuff with const/mut - "execve" | - "execvp" | - "execvpe" | - "fexecve" => true, + cfg.skip_field_type(move |struct_, field| { + // type siginfo_t.si_addr changed from OpenBSD 6.0 to 6.1 + (struct_ == "siginfo_t" && field == "si_addr") + }); - "getrlimit" | "getrlimit64" | // non-int in 1st arg - "setrlimit" | "setrlimit64" | // non-int in 1st arg - "prlimit" | "prlimit64" | // non-int in 2nd arg - "strerror_r" if linux => true, // actually xpg-something-or-other + cfg.generate("../src/lib.rs", "main.rs"); +} - // int vs uint. Sorry musl, your prototype declarations are "correct" in the sense that - // they match the interface defined by Linux verbatim, but they conflict with other - // send*/recv* syscalls - "sendmmsg" | "recvmmsg" if musl => true, +fn test_windows(target: &str) { + assert!(target.contains("windows")); + let gnu = target.contains("gnu"); - // typed 2nd arg on linux - "gettimeofday" if linux => true, + let mut cfg = ctest::TestGenerator::new(); + cfg.define("_WIN32_WINNT", Some("0x8000")); - "dladdr" if musl => true, // const-ness only added recently + headers! { cfg: + "direct.h", + "errno.h", + "fcntl.h", + "io.h", + "limits.h", + "locale.h", + "process.h", + "signal.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "sys/stat.h", + "sys/types.h", + "sys/utime.h", + "time.h", + "wchar.h", + } - // There seems to be a small error in EGLIBC's eventfd.h header. The - // [underlying system call][1] always takes its first `count` - // argument as an `unsigned int`, but [EGLIBC's - // header][2] declares it to take an `int`. [GLIBC's header][3] - // matches the kernel. - // - // EGLIBC is no longer actively developed, and Debian, the largest - // distribution that had been using it, switched back to GLIBC in - // April 2015. So effectively all Linux headers will - // be using `unsigned int` soon. - // - // [1]: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/fs/eventfd.c?id=refs/tags/v3.12.51#n397 - // [2]: http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/trusty/eglibc/trusty/view/head:/sysdeps/unix/sysv/linux/sys/eventfd.h - // [3]: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/sys/eventfd.h;h=6295f32e937e779e74318eb9d3bdbe76aef8a8f3;hb=4e42b5b8f89f0e288e68be7ad70f9525aebc2cff#l34 - "eventfd" if linux => true, + if gnu { + headers! { cfg: "ws2tcpip.h" } + } else { + headers! { cfg: "Winsock2.h" }; + } - "lio_listio" if musl => true, + cfg.type_name(move |ty, is_struct, is_union| { + match ty { + // Just pass all these through, no need for a "struct" prefix + "FILE" | "DIR" | "Dl_info" => ty.to_string(), - // 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 - "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 => true, + // FIXME: these don't exist: + "time64_t" => "__time64_t".to_string(), + "ssize_t" => "SSIZE_T".to_string(), - // Definition of those functions as changed since unified headers from NDK r14b - // These changes imply some API breaking changes but are still ABI compatible. - // We can wait for the next major release to be compliant with the new API. - // FIXME: unskip these for next major release - "strerror_r" | "madvise" | "msync" | "mprotect" | "recvfrom" | "getpriority" | + "sighandler_t" if !gnu => "_crt_signal_t".to_string(), + "sighandler_t" if gnu => "__p_sig_fn_t".to_string(), + + t if is_union => format!("union {}", t), + t if t.ends_with("_t") => t.to_string(), + + // Windows uppercase structs don't have `struct` in front: + t if is_struct => { + if ty.clone().chars().next().unwrap().is_uppercase() { + t.to_string() + } else if t == "stat" { + "struct __stat64".to_string() + } else if t == "utimbuf" { + "struct __utimbuf64".to_string() + } else { + // put `struct` in front of all structs: + format!("struct {}", t) + } + } + t => t.to_string(), + } + }); + + cfg.fn_cname(move |name, cname| cname.unwrap_or(name).to_string()); + cfg.skip_type(move |name| match name { + "SSIZE_T" if !gnu => true, + "ssize_t" if !gnu => true, + _ => false, + }); + + cfg.skip_const(move |name| { + match name { + // FIXME: API error: + // SIG_ERR type is "void (*)(int)", not "int" + "SIG_ERR" => true, _ => false, } }); - cfg.skip_field_type(move |struct_, field| { - // This is a weird union, don't check the type. - (struct_ == "ifaddrs" && field == "ifa_ifu") || - // sighandler_t type is super weird - (struct_ == "sigaction" && field == "sa_sigaction") || - // __timeval type is a patch which doesn't exist in glibc - (linux && struct_ == "utmpx" && field == "ut_tv") || - // sigval is actually a union, but we pretend it's a struct - (struct_ == "sigevent" && field == "sigev_value") || - // aio_buf is "volatile void*" and Rust doesn't understand volatile - (struct_ == "aiocb" && field == "aio_buf") || - // this one is an anonymous union - (linux && struct_ == "ff_effect" && field == "u") + // FIXME: All functions point to the wrong addresses? + cfg.skip_fn_ptrcheck(|_| true); + + cfg.skip_signededness(move |c| { + match c { + // windows-isms + n if n.starts_with("P") => true, + n if n.starts_with("H") => true, + n if n.starts_with("LP") => true, + "sighandler_t" if gnu => true, + _ => false, + } }); - cfg.skip_field(move |struct_, field| { - // this is actually a union on linux, so we can't represent it well and - // just insert some padding. - (struct_ == "siginfo_t" && field == "_pad") || - // musl names this __dummy1 but it's still there - (musl && struct_ == "glob_t" && field == "gl_flags") || - // 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") || - // signalfd had SIGSYS fields added in Linux 4.18, but no libc release has them yet. - (struct_ == "signalfd_siginfo" && (field == "ssi_addr_lsb" || - field == "_pad2" || - field == "ssi_syscall" || - field == "ssi_call_addr" || - field == "ssi_arch")) + cfg.skip_fn(move |name| { + match name { + // FIXME: API error: + "execv" | "execve" | "execvp" | "execvpe" => true, + + _ => false, + } }); - // FIXME: remove - cfg.fn_cname(move |name, _cname| name.to_string()); + cfg.generate("../src/lib.rs", "main.rs"); +} + +fn test_redox(target: &str) { + assert!(target.contains("redox")); + + let mut cfg = ctest::TestGenerator::new(); + cfg.flag("-Wno-deprecated-declarations"); + + headers! { + cfg: + "ctype.h", + "dirent.h", + "dlfcn.h", + "errno.h", + "execinfo.h", + "fcntl.h", + "glob.h", + "grp.h", + "ifaddrs.h", + "langinfo.h", + "limits.h", + "locale.h", + "net/if.h", + "net/if_arp.h", + "net/route.h", + "netdb.h", + "netinet/in.h", + "netinet/ip.h", + "netinet/tcp.h", + "netinet/udp.h", + "poll.h", + "pthread.h", + "pwd.h", + "resolv.h", + "sched.h", + "semaphore.h", + "string.h", + "strings.h", + "sys/file.h", + "sys/ioctl.h", + "sys/mman.h", + "sys/mount.h", + "sys/ptrace.h", + "sys/quota.h", + "sys/resource.h", + "sys/socket.h", + "sys/stat.h", + "sys/statvfs.h", + "sys/sysctl.h", + "sys/time.h", + "sys/times.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/utsname.h", + "sys/wait.h", + "syslog.h", + "termios.h", + "time.h", + "unistd.h", + "utime.h", + "utmpx.h", + "wchar.h", + } cfg.generate("../src/lib.rs", "main.rs"); +} + +fn test_cloudabi(target: &str) { + assert!(target.contains("cloudabi")); - // On Linux also generate another script for testing linux/fcntl declarations. - // These cannot be tested normally because including both `linux/fcntl.h` and `fcntl.h` - // fails on a lot of platforms. let mut cfg = ctest::TestGenerator::new(); - cfg.skip_type(|_| true) - .skip_fn(|_| true) - .skip_static(|_| true); - if linux { - // musl defines these directly in `fcntl.h` - if musl { - cfg.header("fcntl.h"); - } else { - cfg.header("linux/fcntl.h"); - } - if !musl { - cfg.header("net/if.h"); - cfg.header("linux/if.h"); - } - cfg.header("linux/quota.h"); - cfg.header("asm/termbits.h"); - cfg.skip_const(move |name| match name { - "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => false, - "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" - | "F_SEAL_WRITE" => false, - "QFMT_VFS_OLD" | "QFMT_VFS_V0" | "QFMT_VFS_V1" - if mips && linux => - { - false - } - "BOTHER" => false, - _ => true, - }); - cfg.skip_struct(|s| s != "termios2"); - cfg.type_name(move |ty, is_struct, is_union| match ty { - t if is_struct => format!("struct {}", t), - t if is_union => format!("union {}", t), - t => t.to_string(), - }); - } else { - cfg.skip_const(|_| true); - cfg.skip_struct(|_| true); - } - cfg.generate("../src/lib.rs", "linux_fcntl.rs"); -} + cfg.flag("-Wno-deprecated-declarations"); -fn main() { - do_cc(); - do_ctest(); -} + headers! { + cfg: + "execinfo.h", + "glob.h", + "ifaddrs.h", + "langinfo.h", + "sys/ptrace.h", + "sys/quota.h", + "sys/sysctl.h", + "utmpx.h", + "ctype.h", + "dirent.h", + "dlfcn.h", + "errno.h", + "fcntl.h", + "grp.h", + "limits.h", + "locale.h", + "net/if.h", + "net/if_arp.h", + "net/route.h", + "netdb.h", + "netinet/in.h", + "netinet/ip.h", + "netinet/tcp.h", + "netinet/udp.h", + "poll.h", + "pthread.h", + "pwd.h", + "resolv.h", + "sched.h", + "semaphore.h", + "signal.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "strings.h", + "sys/file.h", + "sys/ioctl.h", + "sys/mman.h", + "sys/mount.h", + "sys/resource.h", + "sys/socket.h", + "sys/stat.h", + "sys/statvfs.h", + "sys/time.h", + "sys/times.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/utsname.h", + "sys/wait.h", + "syslog.h", + "termios.h", + "time.h", + "unistd.h", + "utime.h", + "wchar.h", + } -macro_rules! headers { - ($cfg:ident: $header:expr) => { - $cfg.header($header); - }; - ($cfg:ident: $($header:expr),*) => { - $(headers!($cfg: $header);)* - }; - ($cfg:ident: $($header:expr,)*) => { - $(headers!($cfg: $header);)* - }; + cfg.generate("../src/lib.rs", "main.rs"); } -fn test_apple(target: &str) { - assert!(target.contains("apple")); - let x86_64 = target.contains("x86_64"); +fn test_solaris(target: &str) { + assert!(target.contains("solaris")); let mut cfg = ctest::TestGenerator::new(); cfg.flag("-Wno-deprecated-declarations"); - cfg.define("__APPLE_USE_RFC_3542", None); - headers! { cfg: - "aio.h", + cfg.define("_XOPEN_SOURCE", Some("700")); + cfg.define("__EXTENSIONS__", None); + cfg.define("_LCONV_C99", None); + + headers! { + cfg: "ctype.h", "dirent.h", "dlfcn.h", @@ -619,54 +632,38 @@ fn test_apple(target: &str) { "langinfo.h", "limits.h", "locale.h", - "mach-o/dyld.h", - "mach/mach_time.h", - "malloc/malloc.h", - "net/bpf.h", "net/if.h", "net/if_arp.h", - "net/if_dl.h", - "net/if_utun.h", - "net/route.h", "net/route.h", "netdb.h", - "netinet/if_ether.h", - "netinet/in.h", "netinet/in.h", "netinet/ip.h", "netinet/tcp.h", "netinet/udp.h", "poll.h", + "port.h", "pthread.h", "pwd.h", "resolv.h", "sched.h", "semaphore.h", "signal.h", - "spawn.h", "stddef.h", "stdint.h", "stdio.h", "stdlib.h", "string.h", - "sys/event.h", + "sys/epoll.h", "sys/file.h", + "sys/filio.h", "sys/ioctl.h", - "sys/ipc.h", - "sys/kern_control.h", + "sys/loadavg.h", "sys/mman.h", "sys/mount.h", - "sys/proc_info.h", - "sys/ptrace.h", - "sys/quota.h", "sys/resource.h", - "sys/sem.h", - "sys/shm.h", "sys/socket.h", "sys/stat.h", "sys/statvfs.h", - "sys/sys_domain.h", - "sys/sysctl.h", "sys/time.h", "sys/times.h", "sys/types.h", @@ -674,111 +671,64 @@ fn test_apple(target: &str) { "sys/un.h", "sys/utsname.h", "sys/wait.h", - "sys/xattr.h", "syslog.h", "termios.h", "time.h", + "ucontext.h", "unistd.h", - "util.h", "utime.h", "utmpx.h", "wchar.h", - "xlocale.h", - } - - if x86_64 { - headers! { cfg: "crt_externs.h" } } - cfg.skip_struct(move |ty| { - match ty { - // FIXME: actually a union - "sigval" => true, - - _ => false, + cfg.skip_const(move |name| match name { + "DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK" + | "DT_SOCK" | "USRQUOTA" | "GRPQUOTA" | "PRIO_MIN" | "PRIO_MAX" => { + true } - }); - cfg.skip_const(move |name| { - match name { - // These OSX constants are removed in Sierra. - // https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html - "KERN_KDENABLE_BG_TRACE" | "KERN_KDDISABLE_BG_TRACE" => true, - _ => false, - } + _ => false, }); cfg.skip_fn(move |name| { // skip those that are manually verified match name { - // FIXME: https://github.com/rust-lang/libc/issues/1272 - "execv" | "execve" | "execvp" => true, - - // close calls the close_nocancel system call - "close" => true, - - _ => false, - } - }); - - cfg.skip_field_type(move |struct_, field| { - match (struct_, field) { - // FIXME: actually a union - ("sigevent", "sigev_value") => true, - _ => false, - } - }); + // const-ness only added recently + "dladdr" => true, - cfg.volatile_item(|i| { - use ctest::VolatileItemKind::*; - match i { - StructField(ref n, ref f) if n == "aiocb" && f == "aio_buf" => { - true - } - _ => false, - } - }); + // Definition of those functions as changed since unified headers + // from NDK r14b These changes imply some API breaking changes but + // are still ABI compatible. We can wait for the next major release + // to be compliant with the new API. + // + // FIXME: unskip these for next major release + "setpriority" | "personality" => true, - cfg.type_name(move |ty, is_struct, is_union| { - match ty { - // Just pass all these through, no need for a "struct" prefix - "FILE" | "DIR" | "Dl_info" => ty.to_string(), + // signal is defined with sighandler_t, so ignore + "signal" => true, - // OSX calls this something else - "sighandler_t" => "sig_t".to_string(), + "cfmakeraw" | "cfsetspeed" => true, - t if is_union => format!("union {}", t), - t if t.ends_with("_t") => t.to_string(), - t if is_struct => format!("struct {}", t), - t => t.to_string(), - } - }); + // FIXME: mincore is defined with caddr_t on Solaris. + "mincore" => true, - cfg.field_name(move |struct_, field| { - match field { - s if s.ends_with("_nsec") && struct_.starts_with("stat") => { - s.replace("e_nsec", "espec.tv_nsec") - } - // FIXME: sigaction actually contains a union with two variants: - // a sa_sigaction with type: (*)(int, struct __siginfo *, void *) - // a sa_handler with type sig_t - "sa_sigaction" if struct_ == "sigaction" => { - "sa_handler".to_string() - } - s => s.to_string(), + _ => false, } }); cfg.generate("../src/lib.rs", "main.rs"); -} - -fn test_openbsd(target: &str) { - assert!(target.contains("openbsd")); +} +fn test_netbsd(target: &str) { + assert!(target.contains("netbsd")); + let rumprun = target.contains("rumprun"); let mut cfg = ctest::TestGenerator::new(); + cfg.flag("-Wno-deprecated-declarations"); + cfg.define("_NETBSD_SOURCE", Some("1")); - headers! { cfg: + headers! { + cfg: "errno.h", "fcntl.h", "limits.h", @@ -791,243 +741,198 @@ fn test_openbsd(target: &str) { "sys/types.h", "time.h", "wchar.h", + "aio.h", "ctype.h", "dirent.h", - "sys/socket.h", + "dlfcn.h", + "glob.h", + "grp.h", + "ifaddrs.h", + "langinfo.h", "net/if.h", - "net/route.h", "net/if_arp.h", + "net/if_dl.h", + "net/route.h", "netdb.h", "netinet/in.h", "netinet/ip.h", "netinet/tcp.h", "netinet/udp.h", - "resolv.h", + "poll.h", "pthread.h", - "dlfcn.h", + "pwd.h", + "resolv.h", + "sched.h", + "semaphore.h", "signal.h", "string.h", + "sys/extattr.h", "sys/file.h", "sys/ioctl.h", + "sys/ioctl_compat.h", "sys/mman.h", + "sys/mount.h", + "sys/ptrace.h", "sys/resource.h", "sys/socket.h", + "sys/statvfs.h", + "sys/sysctl.h", "sys/time.h", + "sys/times.h", + "sys/uio.h", "sys/un.h", + "sys/utsname.h", "sys/wait.h", + "syslog.h", + "termios.h", + "ufs/ufs/quota.h", + "ufs/ufs/quota1.h", "unistd.h", + "util.h", "utime.h", - "pwd.h", - "grp.h", - "sys/utsname.h", - "sys/ptrace.h", - "sys/mount.h", - "sys/uio.h", - "sched.h", - "termios.h", - "poll.h", - "syslog.h", - "semaphore.h", - "sys/statvfs.h", - "sys/times.h", - "glob.h", - "ifaddrs.h", - "langinfo.h", - "sys/sysctl.h", - "utmp.h", + "mqueue.h", + "netinet/dccp.h", "sys/event.h", - "net/if_dl.h", - "util.h", - "ufs/ufs/quota.h", - "pthread_np.h", - "sys/syscall.h", + "sys/quota.h", } - cfg.skip_struct(move |ty| { - match ty { - // FIXME: actually a union - "sigval" => true, - - _ => false, - } - }); - - cfg.skip_const(move |name| { - match name { - // Removed in OpenBSD 6.0 - "KERN_USERMOUNT" | "KERN_ARND" => true, - _ => false, - } - }); - - cfg.skip_fn(move |name| { - match name { - "execv" | "execve" | "execvp" | "execvpe" => true, - - // typed 2nd arg - "gettimeofday" => true, - - // Removed in OpenBSD 6.5 - // https://marc.info/?l=openbsd-cvs&m=154723400730318 - "mincore" => true, - - _ => false, - } - }); - cfg.type_name(move |ty, is_struct, is_union| { match ty { // Just pass all these through, no need for a "struct" prefix - "FILE" | "DIR" | "Dl_info" => ty.to_string(), + "FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" + | "Elf64_Phdr" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym" + | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr" + | "Elf64_Chdr" => ty.to_string(), // OSX calls this something else "sighandler_t" => "sig_t".to_string(), t if is_union => format!("union {}", t), + t if t.ends_with("_t") => t.to_string(), + + // put `struct` in front of all structs:. t if is_struct => format!("struct {}", t), + t => t.to_string(), } }); - cfg.field_name(move |struct_, field| match field { - "st_birthtime" if struct_.starts_with("stat") => { - "__st_birthtime".to_string() - } - "st_birthtime_nsec" if struct_.starts_with("stat") => { - "__st_birthtimensec".to_string() - } - s if s.ends_with("_nsec") && struct_.starts_with("stat") => { - s.replace("e_nsec", ".tv_nsec") + cfg.field_name(move |struct_, field| { + match field { + // Our stat *_nsec fields normally don't actually exist but are part + // of a timeval struct + s if s.ends_with("_nsec") && struct_.starts_with("stat") => { + s.replace("e_nsec", ".tv_nsec") + } + "u64" if struct_ == "epoll_event" => "data.u64".to_string(), + s => s.to_string(), } - "sa_sigaction" if struct_ == "sigaction" => "sa_handler".to_string(), - s => s.to_string(), }); - cfg.skip_field_type(move |struct_, field| { - // type siginfo_t.si_addr changed from OpenBSD 6.0 to 6.1 - (struct_ == "siginfo_t" && field == "si_addr") + cfg.skip_type(move |ty| { + match ty { + // FIXME: sighandler_t is crazy across platforms + "sighandler_t" => true, + _ => false, + } }); - cfg.generate("../src/lib.rs", "main.rs"); -} - -fn test_windows(target: &str) { - assert!(target.contains("windows")); - let gnu = target.contains("gnu"); - - let mut cfg = ctest::TestGenerator::new(); - cfg.define("_WIN32_WINNT", Some("0x8000")); - - headers! { cfg: - "direct.h", - "errno.h", - "fcntl.h", - "io.h", - "limits.h", - "locale.h", - "process.h", - "signal.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "sys/stat.h", - "sys/types.h", - "sys/utime.h", - "time.h", - "wchar.h", - } - - if gnu { - headers! { cfg: "ws2tcpip.h" } - } else { - headers! { cfg: "Winsock2.h" }; - } - - cfg.type_name(move |ty, is_struct, is_union| { + cfg.skip_struct(move |ty| { match ty { - // Just pass all these through, no need for a "struct" prefix - "FILE" | "DIR" | "Dl_info" => ty.to_string(), - - // FIXME: these don't exist: - "time64_t" => "__time64_t".to_string(), - "ssize_t" => "SSIZE_T".to_string(), - - "sighandler_t" if !gnu => "_crt_signal_t".to_string(), - "sighandler_t" if gnu => "__p_sig_fn_t".to_string(), - - t if is_union => format!("union {}", t), - t if t.ends_with("_t") => t.to_string(), - - // Windows uppercase structs don't have `struct` in front: - t if is_struct => { - if ty.clone().chars().next().unwrap().is_uppercase() { - t.to_string() - } else if t == "stat" { - "struct __stat64".to_string() - } else if t == "utimbuf" { - "struct __utimbuf64".to_string() - } else { - // put `struct` in front of all structs: - format!("struct {}", t) - } - } - t => t.to_string(), + // This is actually a union, not a struct + "sigval" => true, + // These are tested as part of the linux_fcntl tests since there are + // header conflicts when including them with all the other structs. + "termios2" => true, + _ => false, } }); - cfg.fn_cname(move |name, cname| cname.unwrap_or(name).to_string()); - - cfg.skip_type(move |name| match name { - "SSIZE_T" if !gnu => true, - "ssize_t" if !gnu => true, - _ => false, + cfg.skip_signededness(move |c| { + match c { + "LARGE_INTEGER" | "float" | "double" => true, + // uuid_t is a struct, not an integer. + n if n.starts_with("pthread") => true, + // sem_t is a struct or pointer + "sem_t" => true, + _ => false, + } }); cfg.skip_const(move |name| { match name { - // FIXME: API error: - // SIG_ERR type is "void (*)(int)", not "int" - "SIG_ERR" => true, + "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness + "SIGUNUSED" => true, // removed in glibc 2.26 + + // weird signed extension or something like that? + "MS_NOUSER" => true, + "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13 + "BOTHER" => true, + _ => false, } }); - // FIXME: All functions point to the wrong addresses? - cfg.skip_fn_ptrcheck(|_| true); + cfg.skip_fn(move |name| { + match name { + // FIXME: incorrect API + "execv" | + "execve" | + "execvp" | + "execvpe" | + "fexecve" => true, + + "getrlimit" | "getrlimit64" | // non-int in 1st arg + "setrlimit" | "setrlimit64" | // non-int in 1st arg + "prlimit" | "prlimit64" | // non-int in 2nd arg + + // These functions presumably exist on netbsd but don't look like + // they're implemented on rumprun yet, just let them slide for now. + // Some of them look like they have headers but then don't have + // corresponding actual definitions either... + "shm_open" | + "shm_unlink" | + "syscall" | + "mq_open" | + "mq_close" | + "mq_getattr" | + "mq_notify" | + "mq_receive" | + "mq_send" | + "mq_setattr" | + "mq_timedreceive" | + "mq_timedsend" | + "mq_unlink" | + "ptrace" | + "sigaltstack" if rumprun => true, - cfg.skip_signededness(move |c| { - match c { - // windows-isms - n if n.starts_with("P") => true, - n if n.starts_with("H") => true, - n if n.starts_with("LP") => true, - "sighandler_t" if gnu => true, _ => false, } }); - cfg.skip_fn(move |name| { - match name { - // FIXME: API error: - "execv" | "execve" | "execvp" | "execvpe" => true, - - _ => false, - } + cfg.skip_field_type(move |struct_, field| { + // This is a weird union, don't check the type. + (struct_ == "ifaddrs" && field == "ifa_ifu") || + // sighandler_t type is super weird + (struct_ == "sigaction" && field == "sa_sigaction") || + // sigval is actually a union, but we pretend it's a struct + (struct_ == "sigevent" && field == "sigev_value") || + // aio_buf is "volatile void*" and Rust doesn't understand volatile + (struct_ == "aiocb" && field == "aio_buf") }); cfg.generate("../src/lib.rs", "main.rs"); } -fn test_redox(target: &str) { - assert!(target.contains("redox")); - +fn test_dragonflybsd(target: &str) { + assert!(target.contains("dragonfly")); let mut cfg = ctest::TestGenerator::new(); cfg.flag("-Wno-deprecated-declarations"); headers! { cfg: + "aio.h", "ctype.h", "dirent.h", "dlfcn.h", @@ -1040,8 +945,10 @@ fn test_redox(target: &str) { "langinfo.h", "limits.h", "locale.h", + "mqueue.h", "net/if.h", "net/if_arp.h", + "net/if_dl.h", "net/route.h", "netdb.h", "netinet/in.h", @@ -1050,19 +957,25 @@ fn test_redox(target: &str) { "netinet/udp.h", "poll.h", "pthread.h", + "pthread_np.h", "pwd.h", "resolv.h", "sched.h", "semaphore.h", + "signal.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", "string.h", - "strings.h", + "sys/event.h", "sys/file.h", "sys/ioctl.h", "sys/mman.h", "sys/mount.h", "sys/ptrace.h", - "sys/quota.h", "sys/resource.h", + "sys/rtprio.h", "sys/socket.h", "sys/stat.h", "sys/statvfs.h", @@ -1077,285 +990,360 @@ fn test_redox(target: &str) { "syslog.h", "termios.h", "time.h", + "ufs/ufs/quota.h", "unistd.h", + "util.h", "utime.h", "utmpx.h", "wchar.h", } - cfg.generate("../src/lib.rs", "main.rs"); -} + cfg.type_name(move |ty, is_struct, is_union| { + match ty { + // Just pass all these through, no need for a "struct" prefix + "FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" + | "Elf64_Phdr" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym" + | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr" + | "Elf64_Chdr" => ty.to_string(), -fn test_cloudabi(target: &str) { - assert!(target.contains("cloudabi")); + // FIXME: OSX calls this something else + "sighandler_t" => "sig_t".to_string(), - let mut cfg = ctest::TestGenerator::new(); - cfg.flag("-Wno-deprecated-declarations"); + t if is_union => format!("union {}", t), - headers! { - cfg: - "execinfo.h", - "glob.h", - "ifaddrs.h", - "langinfo.h", - "sys/ptrace.h", - "sys/quota.h", - "sys/sysctl.h", - "utmpx.h", - "ctype.h", - "dirent.h", - "dlfcn.h", - "errno.h", - "fcntl.h", - "grp.h", - "limits.h", - "locale.h", - "net/if.h", - "net/if_arp.h", - "net/route.h", - "netdb.h", - "netinet/in.h", - "netinet/ip.h", - "netinet/tcp.h", - "netinet/udp.h", - "poll.h", - "pthread.h", - "pwd.h", - "resolv.h", - "sched.h", - "semaphore.h", - "signal.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "strings.h", - "sys/file.h", - "sys/ioctl.h", - "sys/mman.h", - "sys/mount.h", - "sys/resource.h", - "sys/socket.h", - "sys/stat.h", - "sys/statvfs.h", - "sys/time.h", - "sys/times.h", - "sys/types.h", - "sys/uio.h", - "sys/un.h", - "sys/utsname.h", - "sys/wait.h", - "syslog.h", - "termios.h", - "time.h", - "unistd.h", - "utime.h", - "wchar.h", - } + t if t.ends_with("_t") => t.to_string(), + + // put `struct` in front of all structs:. + t if is_struct => format!("struct {}", t), + + t => t.to_string(), + } + }); + + cfg.field_name(move |struct_, field| { + match field { + // Our stat *_nsec fields normally don't actually exist but are part + // of a timeval struct + s if s.ends_with("_nsec") && struct_.starts_with("stat") => { + s.replace("e_nsec", ".tv_nsec") + } + "u64" if struct_ == "epoll_event" => "data.u64".to_string(), + "type_" + if struct_ == "input_event" + || struct_ == "input_mask" + || struct_ == "ff_effect" + || struct_ == "rtprio" => + { + "type".to_string() + } + s => s.to_string(), + } + }); + + cfg.skip_type(move |ty| { + match ty { + // sighandler_t is crazy across platforms + "sighandler_t" => true, + + _ => false, + } + }); + + cfg.skip_struct(move |ty| { + match ty { + // This is actually a union, not a struct + "sigval" => true, + + // FIXME: These are tested as part of the linux_fcntl tests since + // there are header conflicts when including them with all the other + // structs. + "termios2" => true, + + _ => false, + } + }); + + cfg.skip_signededness(move |c| { + match c { + "LARGE_INTEGER" | "float" | "double" => true, + // uuid_t is a struct, not an integer. + "uuid_t" => true, + n if n.starts_with("pthread") => true, + // sem_t is a struct or pointer + "sem_t" => true, + // mqd_t is a pointer on DragonFly + "mqd_t" => true, + + _ => false, + } + }); + + cfg.skip_const(move |name| { + match name { + "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness + + // weird signed extension or something like that? + "MS_NOUSER" => true, + "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13 + + // These are defined for Solaris 11, but the crate is tested on + // illumos, where they are currently not defined + "EADI" + | "PORT_SOURCE_POSTWAIT" + | "PORT_SOURCE_SIGNAL" + | "PTHREAD_STACK_MIN" => true, + + // These change all the time from release to release of linux + // distros, let's just not bother trying to verify them. They + // shouldn't be used in code anyway... + "AF_MAX" | "PF_MAX" => true, + + _ => false, + } + }); + + cfg.skip_fn(move |name| { + // skip those that are manually verified + match name { + "execv" | // crazy stuff with const/mut + "execve" | + "execvp" | + "execvpe" | + "fexecve" => true, + + "getrlimit" | "getrlimit64" | // non-int in 1st arg + "setrlimit" | "setrlimit64" | // non-int in 1st arg + "prlimit" | "prlimit64" | // non-int in 2nd arg + // typed 2nd arg on linux + "gettimeofday" => true, + + _ => false, + } + }); + + cfg.skip_field_type(move |struct_, field| { + // This is a weird union, don't check the type. + (struct_ == "ifaddrs" && field == "ifa_ifu") || + // sighandler_t type is super weird + (struct_ == "sigaction" && field == "sa_sigaction") || + // sigval is actually a union, but we pretend it's a struct + (struct_ == "sigevent" && field == "sigev_value") || + // aio_buf is "volatile void*" and Rust doesn't understand volatile + (struct_ == "aiocb" && field == "aio_buf") + }); + + cfg.skip_field(move |struct_, field| { + // this is actually a union on linux, so we can't represent it well and + // just insert some padding. + (struct_ == "siginfo_t" && field == "_pad") || + // sigev_notify_thread_id is actually part of a sigev_un union + (struct_ == "sigevent" && field == "sigev_notify_thread_id") + }); cfg.generate("../src/lib.rs", "main.rs"); } -fn test_solaris(target: &str) { - assert!(target.contains("solaris")); +fn test_wasi(target: &str) { + assert!(target.contains("wasi")); let mut cfg = ctest::TestGenerator::new(); - cfg.flag("-Wno-deprecated-declarations"); - - cfg.define("_XOPEN_SOURCE", Some("700")); - cfg.define("__EXTENSIONS__", None); - cfg.define("_LCONV_C99", None); + cfg.define("_GNU_SOURCE", None); - headers! { - cfg: + headers! { cfg: "ctype.h", "dirent.h", - "dlfcn.h", "errno.h", - "execinfo.h", "fcntl.h", - "glob.h", - "grp.h", - "ifaddrs.h", - "langinfo.h", "limits.h", "locale.h", - "net/if.h", - "net/if_arp.h", - "net/route.h", - "netdb.h", - "netinet/in.h", - "netinet/ip.h", - "netinet/tcp.h", - "netinet/udp.h", + "malloc.h", "poll.h", - "port.h", - "pthread.h", - "pwd.h", - "resolv.h", - "sched.h", - "semaphore.h", - "signal.h", + "stdbool.h", "stddef.h", "stdint.h", "stdio.h", "stdlib.h", "string.h", - "sys/epoll.h", - "sys/file.h", - "sys/filio.h", - "sys/ioctl.h", - "sys/loadavg.h", - "sys/mman.h", - "sys/mount.h", "sys/resource.h", + "sys/select.h", "sys/socket.h", "sys/stat.h", - "sys/statvfs.h", - "sys/time.h", "sys/times.h", "sys/types.h", "sys/uio.h", - "sys/un.h", "sys/utsname.h", - "sys/wait.h", - "syslog.h", - "termios.h", "time.h", - "ucontext.h", "unistd.h", - "utime.h", - "utmpx.h", + "wasi/core.h", + "wasi/libc.h", + "wasi/libc-find-relpath.h", "wchar.h", } - cfg.skip_const(move |name| match name { - "DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK" - | "DT_SOCK" | "USRQUOTA" | "GRPQUOTA" | "PRIO_MIN" | "PRIO_MAX" => { - true + cfg.type_name(move |ty, is_struct, is_union| match ty { + "FILE" | "fd_set" | "DIR" => ty.to_string(), + t if is_union => format!("union {}", t), + t if t.starts_with("__wasi") && t.ends_with("_u") => { + format!("union {}", t) } - - _ => false, + t if t.starts_with("__wasi") && is_struct => format!("struct {}", t), + t if t.ends_with("_t") => t.to_string(), + t if is_struct => format!("struct {}", t), + t => t.to_string(), }); - cfg.skip_fn(move |name| { - // skip those that are manually verified - match name { - // const-ness only added recently - "dladdr" => true, - - // Definition of those functions as changed since unified headers - // from NDK r14b These changes imply some API breaking changes but - // are still ABI compatible. We can wait for the next major release - // to be compliant with the new API. - // - // FIXME: unskip these for next major release - "setpriority" | "personality" => true, - - // signal is defined with sighandler_t, so ignore - "signal" => true, - - "cfmakeraw" | "cfsetspeed" => true, - - // FIXME: mincore is defined with caddr_t on Solaris. - "mincore" => true, - - _ => false, + cfg.field_name(move |_struct, field| { + match field { + // deal with fields as rust keywords + "type_" => "type".to_string(), + s => s.to_string(), } }); + // Looks like LLD doesn't merge duplicate imports, so if the Rust + // code imports from a module and the C code also imports from a + // module we end up with two imports of function pointers which + // import the same thing but have different function pointers + cfg.skip_fn_ptrcheck(|f| f.starts_with("__wasi")); + + // d_name is declared as a flexible array in WASI libc, so it + // doesn't support sizeof. + cfg.skip_field(|s, field| s == "dirent" && field == "d_name"); + cfg.generate("../src/lib.rs", "main.rs"); } -fn test_netbsd(target: &str) { - assert!(target.contains("netbsd")); - let rumprun = target.contains("rumprun"); +fn test_android(target: &str) { + assert!(target.contains("android")); + let target_pointer_width = match target { + t if t.contains("aarch64") || t.contains("x86_64") => 64, + t if t.contains("i686") || t.contains("arm") => 32, + t => panic!("unsupported target: {}", t), + }; + let x86 = target.contains("i686") || target.contains("x86_64"); + let mut cfg = ctest::TestGenerator::new(); + cfg.define("_GNU_SOURCE", None); + // FIXME: still necessary? cfg.flag("-Wno-deprecated-declarations"); - cfg.define("_NETBSD_SOURCE", Some("1")); - headers! { - cfg: - "errno.h", - "fcntl.h", - "limits.h", - "locale.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "sys/stat.h", - "sys/types.h", - "time.h", - "wchar.h", - "aio.h", - "ctype.h", - "dirent.h", - "dlfcn.h", - "glob.h", - "grp.h", - "ifaddrs.h", - "langinfo.h", - "net/if.h", - "net/if_arp.h", - "net/if_dl.h", - "net/route.h", - "netdb.h", - "netinet/in.h", - "netinet/ip.h", - "netinet/tcp.h", - "netinet/udp.h", - "poll.h", - "pthread.h", - "pwd.h", - "resolv.h", - "sched.h", - "semaphore.h", - "signal.h", - "string.h", - "sys/extattr.h", - "sys/file.h", - "sys/ioctl.h", - "sys/ioctl_compat.h", - "sys/mman.h", - "sys/mount.h", - "sys/ptrace.h", - "sys/resource.h", - "sys/socket.h", - "sys/statvfs.h", - "sys/sysctl.h", - "sys/time.h", - "sys/times.h", - "sys/uio.h", - "sys/un.h", - "sys/utsname.h", - "sys/wait.h", - "syslog.h", - "termios.h", - "ufs/ufs/quota.h", - "ufs/ufs/quota1.h", - "unistd.h", - "util.h", - "utime.h", - "mqueue.h", - "netinet/dccp.h", - "sys/event.h", - "sys/quota.h", + // Android doesn't actually have in_port_t but it's much easier if we + // provide one for us to test against + // FIXME: still necessary? + cfg.define("in_port_t", Some("uint16_t")); + + headers! { cfg: + "arpa/inet.h", + "asm/mman.h", + "ctype.h", + "dirent.h", + "dlfcn.h", + "errno.h", + "fcntl.h", + "grp.h", + "ifaddrs.h", + "limits.h", + "linux/dccp.h", + "linux/fs.h", + "linux/genetlink.h", + "linux/if_alg.h", + "linux/if_ether.h", + "linux/if_tun.h", + "linux/magic.h", + "linux/memfd.h", + "linux/module.h", + "linux/net_tstamp.h", + "linux/netfilter/nf_tables.h", + "linux/netfilter_ipv4.h", + "linux/netfilter_ipv6.h", + "linux/netlink.h", + "linux/quota.h", + "linux/reboot.h", + "linux/seccomp.h", + "linux/sockios.h", + "locale.h", + "malloc.h", + "net/ethernet.h", + "net/if.h", + "net/if_arp.h", + "net/route.h", + "netdb.h", + "netinet/in.h", + "netinet/ip.h", + "netinet/tcp.h", + "netinet/udp.h", + "netpacket/packet.h", + "poll.h", + "pthread.h", + "pty.h", + "pwd.h", + "resolv.h", + "sched.h", + "semaphore.h", + "signal.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/epoll.h", + "sys/eventfd.h", + "sys/file.h", + "sys/fsuid.h", + "sys/inotify.h", + "sys/ioctl.h", + "sys/mman.h", + "sys/mount.h", + "sys/personality.h", + "sys/prctl.h", + "sys/ptrace.h", + "sys/reboot.h", + "sys/resource.h", + "sys/sendfile.h", + "sys/signalfd.h", + "sys/socket.h", + "sys/stat.h", + "sys/statvfs.h", + "sys/swap.h", + "sys/syscall.h", + "sys/sysinfo.h", + "sys/time.h", + "sys/times.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/utsname.h", + "sys/vfs.h", + "sys/wait.h", + "syslog.h", + "termios.h", + "time.h", + "unistd.h", + "utime.h", + "utmp.h", + "wchar.h", + "xlocale.h", + } + + if target_pointer_width == 32 { + // time64_t is not defined for 64-bit targets If included it will + // generate the error 'Your time_t is already 64-bit' + cfg.header("time64.h"); + } + if x86 { + cfg.header("sys/reg.h"); } cfg.type_name(move |ty, is_struct, is_union| { match ty { // Just pass all these through, no need for a "struct" prefix + // FIXME: still required ? "FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" | "Elf64_Phdr" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym" | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr" | "Elf64_Chdr" => ty.to_string(), - // OSX calls this something else - "sighandler_t" => "sig_t".to_string(), - t if is_union => format!("union {}", t), t if t.ends_with("_t") => t.to_string(), @@ -1372,8 +1360,9 @@ fn test_netbsd(target: &str) { // Our stat *_nsec fields normally don't actually exist but are part // of a timeval struct s if s.ends_with("_nsec") && struct_.starts_with("stat") => { - s.replace("e_nsec", ".tv_nsec") + s.to_string() } + // FIXME: still necessary? "u64" if struct_ == "epoll_event" => "data.u64".to_string(), s => s.to_string(), } @@ -1381,7 +1370,8 @@ fn test_netbsd(target: &str) { cfg.skip_type(move |ty| { match ty { - // FIXME: sighandler_t is crazy across platforms + // sighandler_t is crazy across platforms + // FIXME: still necessary? "sighandler_t" => true, _ => false, } @@ -1390,76 +1380,131 @@ fn test_netbsd(target: &str) { cfg.skip_struct(move |ty| { match ty { // This is actually a union, not a struct + // FIXME: still necessary "sigval" => true, + + // These structs have changed since unified headers in NDK r14b. + // `st_atime` and `st_atime_nsec` have changed sign. + // FIXME: unskip it for next major release + "stat" | "stat64" => true, + // These are tested as part of the linux_fcntl tests since there are // header conflicts when including them with all the other structs. + // FIXME: still necessary "termios2" => true, + _ => false, } }); cfg.skip_signededness(move |c| { match c { + // FIXME: still necessary? "LARGE_INTEGER" | "float" | "double" => true, - // uuid_t is a struct, not an integer. + // FIXME: still necessary? n if n.starts_with("pthread") => true, - // sem_t is a struct or pointer - "sem_t" => true, _ => false, } }); cfg.skip_const(move |name| { match name { + // FIXME: still necessary? "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness - "SIGUNUSED" => true, // removed in glibc 2.26 + // FIXME: still necessary? + "SIGUNUSED" => true, // removed in glibc 2.26 // weird signed extension or something like that? + // FIXME: still necessary? "MS_NOUSER" => true, + // FIXME: still necessary? "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13 + + // Android uses old kernel headers + // These are constants used in getrandom syscall + // FIXME: still necessary? + "GRND_NONBLOCK" | "GRND_RANDOM" => true, + + // Defined by libattr not libc on linux (hard to test). + // See constant definition for more details. + // FIXME: still necessary? + "ENOATTR" => true, + + // FIXME: still necessary? "BOTHER" => true, + // MFD_HUGETLB is not available in some older libc versions on the CI builders. On the + // x86_64 and i686 builders it seems to be available for all targets, so at least test + // it there. + // FIXME: still necessary? + "MFD_HUGETLB" => true, + + // These change all the time from release to release of linux + // distros, let's just not bother trying to verify them. They + // shouldn't be used in code anyway... + // FIXME: still necessary? + "AF_MAX" | "PF_MAX" => true, + _ => false, } }); cfg.skip_fn(move |name| { + // skip those that are manually verified match name { - // FIXME: incorrect API - "execv" | + // FIXME: still necessary? + "execv" | // crazy stuff with const/mut "execve" | "execvp" | "execvpe" | "fexecve" => true, - "getrlimit" | "getrlimit64" | // non-int in 1st arg - "setrlimit" | "setrlimit64" | // non-int in 1st arg - "prlimit" | "prlimit64" | // non-int in 2nd arg + // typed 2nd arg on android + // FIXME: still necessary? + "gettimeofday" => true, - // These functions presumably exist on netbsd but don't look like - // they're implemented on rumprun yet, just let them slide for now. - // Some of them look like they have headers but then don't have - // corresponding actual definitions either... - "shm_open" | - "shm_unlink" | - "syscall" | - "mq_open" | - "mq_close" | - "mq_getattr" | - "mq_notify" | - "mq_receive" | - "mq_send" | - "mq_setattr" | - "mq_timedreceive" | - "mq_timedsend" | - "mq_unlink" | - "ptrace" | - "sigaltstack" if rumprun => true, + // not declared in newer android toolchains + // FIXME: still necessary? + "getdtablesize" => true, + + // FIXME: still necessary? + "dlerror" => true, // const-ness is added + + // Apparently the NDK doesn't have this defined on android, but + // it's in a header file? + // FIXME: still necessary? + "endpwent" => true, + + // Apparently res_init exists on Android, but isn't defined in a header: + // https://mail.gnome.org/archives/commits-list/2013-May/msg01329.html + // FIXME: still necessary? + "res_init" => true, + + // Definition of those functions as changed since unified headers from NDK r14b + // These changes imply some API breaking changes but are still ABI compatible. + // We can wait for the next major release to be compliant with the new API. + // FIXME: unskip these for next major release + "strerror_r" | "madvise" | "msync" | "mprotect" | "recvfrom" | "getpriority" | + "setpriority" | "personality" => true, + // In Android 64 bits, these functions have been fixed since unified headers. + // Ignore these until next major version. + "bind" | "writev" | "readv" | "sendmsg" | "recvmsg" + if target_pointer_width == 64 => true, + + _ => false, + } + }); + cfg.skip_static(move |name| { + match name { + // Internal constant, not declared in any headers. + // FIXME: still necessary + "__progname" => true, _ => false, } }); + // FIXME: still necessary? cfg.skip_field_type(move |struct_, field| { // This is a weird union, don't check the type. (struct_ == "ifaddrs" && field == "ifa_ifu") || @@ -1471,91 +1516,150 @@ fn test_netbsd(target: &str) { (struct_ == "aiocb" && field == "aio_buf") }); - cfg.generate("../src/lib.rs", "main.rs"); -} + // FIXME: still necessary? + cfg.skip_field(move |struct_, field| { + // this is actually a union on linux, so we can't represent it well and + // just insert some padding. + (struct_ == "siginfo_t" && field == "_pad") || + // sigev_notify_thread_id is actually part of a sigev_un union + (struct_ == "sigevent" && field == "sigev_notify_thread_id") || + // signalfd had SIGSYS fields added in Linux 4.18, but no libc release has them yet. + (struct_ == "signalfd_siginfo" && (field == "ssi_addr_lsb" || + field == "_pad2" || + field == "ssi_syscall" || + field == "ssi_call_addr" || + field == "ssi_arch")) + }); -fn test_dragonflybsd(target: &str) { - assert!(target.contains("dragonfly")); - let mut cfg = ctest::TestGenerator::new(); - cfg.flag("-Wno-deprecated-declarations"); + // FIXME: remove + cfg.fn_cname(move |name, _cname| name.to_string()); - headers! { - cfg: - "aio.h", - "ctype.h", - "dirent.h", - "dlfcn.h", - "errno.h", - "execinfo.h", - "fcntl.h", - "glob.h", - "grp.h", - "ifaddrs.h", - "langinfo.h", - "limits.h", - "locale.h", - "mqueue.h", - "net/if.h", - "net/if_arp.h", - "net/if_dl.h", - "net/route.h", - "netdb.h", - "netinet/in.h", - "netinet/ip.h", - "netinet/tcp.h", - "netinet/udp.h", - "poll.h", - "pthread.h", - "pthread_np.h", - "pwd.h", - "resolv.h", - "sched.h", - "semaphore.h", - "signal.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "sys/event.h", - "sys/file.h", - "sys/ioctl.h", - "sys/mman.h", - "sys/mount.h", - "sys/ptrace.h", - "sys/resource.h", - "sys/rtprio.h", - "sys/socket.h", - "sys/stat.h", - "sys/statvfs.h", - "sys/sysctl.h", - "sys/time.h", - "sys/times.h", - "sys/types.h", - "sys/uio.h", - "sys/un.h", - "sys/utsname.h", - "sys/wait.h", - "syslog.h", - "termios.h", - "time.h", - "ufs/ufs/quota.h", - "unistd.h", - "util.h", - "utime.h", - "utmpx.h", - "wchar.h", + cfg.generate("../src/lib.rs", "main.rs"); + + // On Android also generate another script for testing linux/fcntl + // declarations. These cannot be tested normally because including both + // `linux/fcntl.h` and `fcntl.h` fails. + // + // FIXME: is still necessary? + let mut cfg = ctest::TestGenerator::new(); + cfg.skip_type(|_| true) + .skip_fn(|_| true) + .skip_static(|_| true); + cfg.header("linux/fcntl.h"); + cfg.header("net/if.h"); + cfg.header("linux/if.h"); + cfg.header("linux/quota.h"); + cfg.header("asm/termbits.h"); + cfg.skip_const(move |name| match name { + "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => false, + "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => { + false + } + "BOTHER" => false, + _ => true, + }); + cfg.skip_struct(|s| s != "termios2"); + cfg.type_name(move |ty, is_struct, is_union| match ty { + t if is_struct => format!("struct {}", t), + t if is_union => format!("union {}", t), + t => t.to_string(), + }); + cfg.generate("../src/lib.rs", "linux_fcntl.rs"); +} + +fn test_freebsd(target: &str) { + assert!(target.contains("freebsd")); + let x86 = target.contains("i686") || target.contains("x86_64"); + + let mut cfg = ctest::TestGenerator::new(); + // FIXME: still necessary? + cfg.define("_WITH_GETLINE", None); + + // FIXME: still necessary? + cfg.flag("-Wno-deprecated-declarations"); + + headers! { cfg: + "aio.h", + "arpa/inet.h", + "ctype.h", + "dirent.h", + "dlfcn.h", + "errno.h", + "fcntl.h", + "glob.h", + "grp.h", + "ifaddrs.h", + "langinfo.h", + "libutil.h", + "limits.h", + "locale.h", + "mqueue.h", + "net/bpf.h", + "net/if.h", + "net/if_arp.h", + "net/if_dl.h", + "net/route.h", + "netdb.h", + "netinet/in.h", + "netinet/tcp.h", + "netinet/udp.h", + "poll.h", + "pthread.h", + "pthread_np.h", + "pwd.h", + "resolv.h", + "sched.h", + "semaphore.h", + "signal.h", + "spawn.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/event.h", + "sys/extattr.h", + "sys/file.h", + "sys/ioctl.h", + "sys/ipc.h", + "sys/jail.h", + "sys/mman.h", + "sys/mount.h", + "sys/msg.h", + "sys/procdesc.h", + "sys/ptrace.h", + "sys/resource.h", + "sys/rtprio.h", + "sys/shm.h", + "sys/socket.h", + "sys/stat.h", + "sys/statvfs.h", + "sys/time.h", + "sys/times.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/utsname.h", + "sys/wait.h", + "syslog.h", + "termios.h", + "time.h", + "ufs/ufs/quota.h", + "unistd.h", + "utime.h", + "wchar.h", } cfg.type_name(move |ty, is_struct, is_union| { match ty { // Just pass all these through, no need for a "struct" prefix + // FIXME: still required? "FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" | "Elf64_Phdr" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym" | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr" | "Elf64_Chdr" => ty.to_string(), - // FIXME: OSX calls this something else + // FIXME: still required? "sighandler_t" => "sig_t".to_string(), t if is_union => format!("union {}", t), @@ -1576,7 +1680,9 @@ fn test_dragonflybsd(target: &str) { s if s.ends_with("_nsec") && struct_.starts_with("stat") => { s.replace("e_nsec", ".tv_nsec") } + // FIXME: still required? "u64" if struct_ == "epoll_event" => "data.u64".to_string(), + // FIXME: still required? "type_" if struct_ == "input_event" || struct_ == "input_mask" @@ -1592,6 +1698,7 @@ fn test_dragonflybsd(target: &str) { cfg.skip_type(move |ty| { match ty { // sighandler_t is crazy across platforms + // FIXME: still required? "sighandler_t" => true, _ => false, @@ -1601,11 +1708,12 @@ fn test_dragonflybsd(target: &str) { cfg.skip_struct(move |ty| { match ty { // This is actually a union, not a struct + // FIXME: still required? "sigval" => true, - // FIXME: These are tested as part of the linux_fcntl tests since - // there are header conflicts when including them with all the other - // structs. + // These are tested as part of the linux_fcntl tests since there are + // header conflicts when including them with all the other structs. + // FIXME: still required? "termios2" => true, _ => false, @@ -1614,13 +1722,15 @@ fn test_dragonflybsd(target: &str) { cfg.skip_signededness(move |c| { match c { + // FIXME: still required? "LARGE_INTEGER" | "float" | "double" => true, - // uuid_t is a struct, not an integer. - "uuid_t" => true, + // FIXME: still required? n if n.starts_with("pthread") => true, // sem_t is a struct or pointer + // FIXME: still required? "sem_t" => true, - // mqd_t is a pointer on DragonFly + // mqd_t is a pointer on FreeBSD + // FIXME: still required? "mqd_t" => true, _ => false, @@ -1629,24 +1739,66 @@ fn test_dragonflybsd(target: &str) { cfg.skip_const(move |name| { match name { + // FIXME: still required? "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness + // FIXME: still required? + "SIGUNUSED" => true, // removed in glibc 2.26 // weird signed extension or something like that? + // FIXME: still required? "MS_NOUSER" => true, + // FIXME: still required? "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13 - // These are defined for Solaris 11, but the crate is tested on - // illumos, where they are currently not defined - "EADI" - | "PORT_SOURCE_POSTWAIT" - | "PORT_SOURCE_SIGNAL" - | "PTHREAD_STACK_MIN" => true, + // These constants were removed in FreeBSD 11 (svn r273250) but will + // still be accepted and ignored at runtime. + "MAP_RENAME" | "MAP_NORESERVE" => true, + + // These constants were removed in FreeBSD 11 (svn r262489), + // and they've never had any legitimate use outside of the + // base system anyway. + "CTL_MAXID" | "KERN_MAXID" | "HW_MAXID" | "NET_MAXID" + | "USER_MAXID" => true, + + // These constants were added in FreeBSD 11 + // FIXME: still required? + "EVFILT_PROCDESC" | "EVFILT_SENDFILE" | "EVFILT_EMPTY" + | "PD_CLOEXEC" | "PD_ALLOWED_AT_FORK" => true, + + // These constants were added in FreeBSD 12 + // FIXME: still required? + "SF_USER_READAHEAD" | "SO_REUSEPORT_LB" => true, + + // These constants are tested in a separate test program generated + // below because there are header conflicts if we try to include the + // headers that define them here. + // FIXME: still required? + "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => true, + // FIXME: still required? + "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" + | "F_SEAL_WRITE" => true, + // FIXME: still required? + "BOTHER" => true, + + // MFD_HUGETLB is not available in some older libc versions on the + // CI builders. On the x86_64 and i686 builders it seems to be + // available for all targets, so at least test it there. + // FIXME: still required? + "MFD_HUGETLB" if !x86 => true, // These change all the time from release to release of linux // distros, let's just not bother trying to verify them. They // shouldn't be used in code anyway... + // FIXME: still required? "AF_MAX" | "PF_MAX" => true, + // FreeBSD 12 required, but CI has FreeBSD 11. + // FIXME: still required? + "IP_ORIGDSTADDR" + | "IP_RECVORIGDSTADDR" + | "IPV6_ORIGDSTADDR" + | "IPV6_RECVORIGDSTADDR" => true, + _ => false, } }); @@ -1654,165 +1806,111 @@ fn test_dragonflybsd(target: &str) { cfg.skip_fn(move |name| { // skip those that are manually verified match name { + // FIXME: still required? "execv" | // crazy stuff with const/mut "execve" | "execvp" | "execvpe" | "fexecve" => true, - "getrlimit" | "getrlimit64" | // non-int in 1st arg - "setrlimit" | "setrlimit64" | // non-int in 1st arg - "prlimit" | "prlimit64" | // non-int in 2nd arg - // typed 2nd arg on linux - "gettimeofday" => true, - - _ => false, - } - }); - - cfg.skip_field_type(move |struct_, field| { - // This is a weird union, don't check the type. - (struct_ == "ifaddrs" && field == "ifa_ifu") || - // sighandler_t type is super weird - (struct_ == "sigaction" && field == "sa_sigaction") || - // sigval is actually a union, but we pretend it's a struct - (struct_ == "sigevent" && field == "sigev_value") || - // aio_buf is "volatile void*" and Rust doesn't understand volatile - (struct_ == "aiocb" && field == "aio_buf") - }); - - cfg.skip_field(move |struct_, field| { - // this is actually a union on linux, so we can't represent it well and - // just insert some padding. - (struct_ == "siginfo_t" && field == "_pad") || - // sigev_notify_thread_id is actually part of a sigev_un union - (struct_ == "sigevent" && field == "sigev_notify_thread_id") - }); - - cfg.generate("../src/lib.rs", "main.rs"); -} - -fn test_wasi(target: &str) { - assert!(target.contains("wasi")); - - let mut cfg = ctest::TestGenerator::new(); - cfg.define("_GNU_SOURCE", None); - - headers! { cfg: - "ctype.h", - "dirent.h", - "errno.h", - "fcntl.h", - "limits.h", - "locale.h", - "malloc.h", - "poll.h", - "stdbool.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "sys/resource.h", - "sys/select.h", - "sys/socket.h", - "sys/stat.h", - "sys/times.h", - "sys/types.h", - "sys/uio.h", - "sys/utsname.h", - "time.h", - "unistd.h", - "wasi/core.h", - "wasi/libc.h", - "wasi/libc-find-relpath.h", - "wchar.h", - } + // The `uname` function in freebsd is now an inline wrapper that + // delegates to another, but the symbol still exists, so don't check + // the symbol. + // FIXME: still required? + "uname" => true, - cfg.type_name(move |ty, is_struct, is_union| match ty { - "FILE" | "fd_set" | "DIR" => ty.to_string(), - t if is_union => format!("union {}", t), - t if t.starts_with("__wasi") && t.ends_with("_u") => { - format!("union {}", t) + // FIXME: need to upgrade FreeBSD version; see https://github.com/rust-lang/libc/issues/938 + // FIXME: still required? + "setgrent" => true, + + // aio_waitcomplete's return type changed between FreeBSD 10 and 11. + // FIXME: still required? + "aio_waitcomplete" => true, + + // lio_listio confuses the checker, probably because one of its + // arguments is an array + // FIXME: still required? + "lio_listio" => true, + + // Definition of those functions as changed since unified headers from NDK r14b + // These changes imply some API breaking changes but are still ABI compatible. + // We can wait for the next major release to be compliant with the new API. + // FIXME: unskip these for next major release + // FIXME: still required ? + "strerror_r" | "madvise" | "msync" | "mprotect" | "recvfrom" | "getpriority" | + + _ => false, } - t if t.starts_with("__wasi") && is_struct => format!("struct {}", t), - t if t.ends_with("_t") => t.to_string(), - t if is_struct => format!("struct {}", t), - t => t.to_string(), }); - cfg.field_name(move |_struct, field| { - match field { - // deal with fields as rust keywords - "type_" => "type".to_string(), - s => s.to_string(), - } + cfg.skip_field_type(move |struct_, field| { + // This is a weird union, don't check the type. + // FIXME: still required? + (struct_ == "ifaddrs" && field == "ifa_ifu") || + // FIXME: still required? + // sighandler_t type is super weird + (struct_ == "sigaction" && field == "sa_sigaction") || + // FIXME: still required? + // sigval is actually a union, but we pretend it's a struct + (struct_ == "sigevent" && field == "sigev_value") || + // aio_buf is "volatile void*" and Rust doesn't understand volatile + // FIXME: still required? + (struct_ == "aiocb" && field == "aio_buf") || + // stack_t.ss_sp's type changed from FreeBSD 10 to 11 in svn r294930 + // FIXME: still required? + (struct_ == "stack_t" && field == "ss_sp") }); - // Looks like LLD doesn't merge duplicate imports, so if the Rust - // code imports from a module and the C code also imports from a - // module we end up with two imports of function pointers which - // import the same thing but have different function pointers - cfg.skip_fn_ptrcheck(|f| f.starts_with("__wasi")); + cfg.skip_field(move |struct_, field| { + // this is actually a union on linux, so we can't represent it well and + // just insert some padding. + // FIXME: still required? + (struct_ == "siginfo_t" && field == "_pad") || + // sigev_notify_thread_id is actually part of a sigev_un union + // FIXME: still required? + (struct_ == "sigevent" && field == "sigev_notify_thread_id") || + // signalfd had SIGSYS fields added in Linux 4.18, but no libc release has them yet. + // FIXME: still required? + (struct_ == "signalfd_siginfo" && (field == "ssi_addr_lsb" || + field == "_pad2" || + field == "ssi_syscall" || + field == "ssi_call_addr" || + field == "ssi_arch")) + }); - // d_name is declared as a flexible array in WASI libc, so it - // doesn't support sizeof. - cfg.skip_field(|s, field| s == "dirent" && field == "d_name"); + // FIXME: remove + cfg.fn_cname(move |name, _cname| name.to_string()); cfg.generate("../src/lib.rs", "main.rs"); } -fn test_android(target: &str) { - assert!(target.contains("android")); - let target_pointer_width = match target { - t if t.contains("aarch64") || t.contains("x86_64") => 64, - t if t.contains("i686") || t.contains("arm") => 32, - t => panic!("unsupported target: {}", t), - }; - let x86 = target.contains("i686") || target.contains("x86_64"); +fn test_emscripten(target: &str) { + assert!(target.contains("emscripten")); let mut cfg = ctest::TestGenerator::new(); + // FIXME: still necessary? cfg.define("_GNU_SOURCE", None); // FIXME: still necessary? cfg.flag("-Wno-deprecated-declarations"); - // Android doesn't actually have in_port_t but it's much easier if we - // provide one for us to test against - // FIXME: still necessary? - cfg.define("in_port_t", Some("uint16_t")); - headers! { cfg: - "arpa/inet.h", - "asm/mman.h", + "aio.h", "ctype.h", "dirent.h", "dlfcn.h", "errno.h", + "execinfo.h", "fcntl.h", + "glob.h", "grp.h", "ifaddrs.h", + "langinfo.h", "limits.h", - "linux/dccp.h", - "linux/fs.h", - "linux/genetlink.h", - "linux/if_alg.h", - "linux/if_ether.h", - "linux/if_tun.h", - "linux/magic.h", - "linux/memfd.h", - "linux/module.h", - "linux/net_tstamp.h", - "linux/netfilter/nf_tables.h", - "linux/netfilter_ipv4.h", - "linux/netfilter_ipv6.h", - "linux/netlink.h", - "linux/quota.h", - "linux/reboot.h", - "linux/seccomp.h", - "linux/sockios.h", "locale.h", "malloc.h", + "mntent.h", + "mqueue.h", "net/ethernet.h", "net/if.h", "net/if_arp.h", @@ -1829,7 +1927,9 @@ fn test_android(target: &str) { "pwd.h", "resolv.h", "sched.h", + "sched.h", "semaphore.h", + "shadow.h", "signal.h", "stddef.h", "stdint.h", @@ -1839,55 +1939,54 @@ fn test_android(target: &str) { "sys/epoll.h", "sys/eventfd.h", "sys/file.h", - "sys/fsuid.h", - "sys/inotify.h", "sys/ioctl.h", + "sys/ipc.h", "sys/mman.h", "sys/mount.h", + "sys/msg.h", "sys/personality.h", "sys/prctl.h", "sys/ptrace.h", + "sys/quota.h", "sys/reboot.h", "sys/resource.h", + "sys/sem.h", "sys/sendfile.h", + "sys/shm.h", "sys/signalfd.h", "sys/socket.h", "sys/stat.h", "sys/statvfs.h", "sys/swap.h", "sys/syscall.h", + "sys/sysctl.h", "sys/sysinfo.h", "sys/time.h", + "sys/timerfd.h", "sys/times.h", "sys/types.h", "sys/uio.h", "sys/un.h", + "sys/user.h", "sys/utsname.h", "sys/vfs.h", "sys/wait.h", + "sys/xattr.h", "syslog.h", "termios.h", "time.h", + "ucontext.h", "unistd.h", "utime.h", "utmp.h", + "utmpx.h", "wchar.h", - "xlocale.h", - } - - if target_pointer_width == 32 { - // time64_t is not defined for 64-bit targets If included it will - // generate the error 'Your time_t is already 64-bit' - cfg.header("time64.h"); - } - if x86 { - cfg.header("sys/reg.h"); } cfg.type_name(move |ty, is_struct, is_union| { match ty { // Just pass all these through, no need for a "struct" prefix - // FIXME: still required ? + // FIXME: is this necessary? "FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" | "Elf64_Phdr" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym" | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr" @@ -1909,9 +2008,9 @@ fn test_android(target: &str) { // Our stat *_nsec fields normally don't actually exist but are part // of a timeval struct s if s.ends_with("_nsec") && struct_.starts_with("stat") => { - s.to_string() + s.replace("e_nsec", ".tv_nsec") } - // FIXME: still necessary? + // FIXME: is this necessary? "u64" if struct_ == "epoll_event" => "data.u64".to_string(), s => s.to_string(), } @@ -1920,78 +2019,129 @@ fn test_android(target: &str) { cfg.skip_type(move |ty| { match ty { // sighandler_t is crazy across platforms - // FIXME: still necessary? + // FIXME: is this necessary? "sighandler_t" => true, + _ => false, } }); cfg.skip_struct(move |ty| { match ty { + // FIXME: is this necessary? + "sockaddr_nl" => true, + // This is actually a union, not a struct - // FIXME: still necessary + // FIXME: is this necessary? "sigval" => true, - // These structs have changed since unified headers in NDK r14b. - // `st_atime` and `st_atime_nsec` have changed sign. - // FIXME: unskip it for next major release - "stat" | "stat64" => true, + // Linux kernel headers used on musl are too old to have this + // definition. Because it's tested on other Linux targets, skip it. + // FIXME: is this necessary? + "input_mask" => true, // These are tested as part of the linux_fcntl tests since there are // header conflicts when including them with all the other structs. - // FIXME: still necessary + // FIXME: is this necessary? "termios2" => true, _ => false, } }); - cfg.skip_signededness(move |c| { - match c { - // FIXME: still necessary? - "LARGE_INTEGER" | "float" | "double" => true, - // FIXME: still necessary? - n if n.starts_with("pthread") => true, - _ => false, - } + cfg.skip_signededness(move |c| match c { + // FIXME: is this necessary? + "LARGE_INTEGER" | "float" | "double" => true, + // FIXME: is this necessary? + n if n.starts_with("pthread") => true, + _ => false, }); cfg.skip_const(move |name| { match name { - // FIXME: still necessary? + // FIXME: is this necessary? "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness - // FIXME: still necessary? - "SIGUNUSED" => true, // removed in glibc 2.26 + // FIXME: is this necessary? + "SIGUNUSED" => true, // removed in glibc 2.26 + + // types on musl are defined a little differently + // FIXME: is this necessary? + n if n.contains("__SIZEOF_PTHREAD") => true, + + // Skip constants not defined in MUSL but just passed down to the + // kernel regardless + // FIXME: is this necessary? + "RLIMIT_NLIMITS" + | "TCP_COOKIE_TRANSACTIONS" + | "RLIMIT_RTTIME" + | "MSG_COPY" + => + { + true + } // weird signed extension or something like that? - // FIXME: still necessary? + // FIXME: is this necessary? "MS_NOUSER" => true, - // FIXME: still necessary? + // FIXME: is this necessary? "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13 - // Android uses old kernel headers + // Musl uses old, patched kernel headers + // FIXME: is this necessary? + "FALLOC_FL_COLLAPSE_RANGE" + | "FALLOC_FL_ZERO_RANGE" + | "FALLOC_FL_INSERT_RANGE" + | "FALLOC_FL_UNSHARE_RANGE" + | "RENAME_NOREPLACE" + | "RENAME_EXCHANGE" + | "RENAME_WHITEOUT" + // ALG_SET_AEAD_* constants are available starting from kernel 3.19 + | "ALG_SET_AEAD_ASSOCLEN" + | "ALG_SET_AEAD_AUTHSIZE" + => + { + true + } + + // musl uses old kernel headers // These are constants used in getrandom syscall - // FIXME: still necessary? + // FIXME: is this necessary? "GRND_NONBLOCK" | "GRND_RANDOM" => true, - // Defined by libattr not libc on linux (hard to test). - // See constant definition for more details. - // FIXME: still necessary? - "ENOATTR" => true, - // FIXME: still necessary? + // These constants are tested in a separate test program generated below because there + // are header conflicts if we try to include the headers that define them here. + // FIXME: is this necessary? + "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => true, + // FIXME: is this necessary? + "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" + | "F_SEAL_WRITE" => true, + // FIXME: is this necessary? "BOTHER" => true, + // FIXME: is this necessary? + "MFD_CLOEXEC" | "MFD_ALLOW_SEALING" => true, // MFD_HUGETLB is not available in some older libc versions on the CI builders. On the // x86_64 and i686 builders it seems to be available for all targets, so at least test // it there. - // FIXME: still necessary? - "MFD_HUGETLB" => true, + // FIXME: is this necessary? + "MFD_HUGETLB" => + { + true + } + + // These are defined for Solaris 11, but the crate is tested on + // illumos, where they are currently not defined + // FIXME: is this necessary? + "EADI" + | "PORT_SOURCE_POSTWAIT" + | "PORT_SOURCE_SIGNAL" + | "PTHREAD_STACK_MIN" => true, // These change all the time from release to release of linux // distros, let's just not bother trying to verify them. They // shouldn't be used in code anyway... - // FIXME: still necessary? + // FIXME: is this necessary? "AF_MAX" | "PF_MAX" => true, _ => false, @@ -2001,75 +2151,65 @@ fn test_android(target: &str) { cfg.skip_fn(move |name| { // skip those that are manually verified match name { - // FIXME: still necessary? + // FIXME: is this necessary? "execv" | // crazy stuff with const/mut "execve" | "execvp" | "execvpe" | "fexecve" => true, - // typed 2nd arg on android - // FIXME: still necessary? - "gettimeofday" => true, - - // not declared in newer android toolchains - // FIXME: still necessary? - "getdtablesize" => true, + "getrlimit" | "getrlimit64" | // non-int in 1st arg + "setrlimit" | "setrlimit64" | // non-int in 1st arg + "prlimit" | "prlimit64" | // non-int in 2nd arg - // FIXME: still necessary? - "dlerror" => true, // const-ness is added + // int vs uint. Sorry musl, your prototype declarations are "correct" in the sense that + // they match the interface defined by Linux verbatim, but they conflict with other + // send*/recv* syscalls + // FIXME: is this necessary? + "sendmmsg" | "recvmmsg" => true, - // Apparently the NDK doesn't have this defined on android, but - // it's in a header file? - // FIXME: still necessary? - "endpwent" => true, + // FIXME: is this necessary? + "dladdr" => true, // const-ness only added recently - // Apparently res_init exists on Android, but isn't defined in a header: - // https://mail.gnome.org/archives/commits-list/2013-May/msg01329.html - // FIXME: still necessary? - "res_init" => true, + // FIXME: is this necessary? + "lio_listio" => true, // Definition of those functions as changed since unified headers from NDK r14b // These changes imply some API breaking changes but are still ABI compatible. - // We can wait for the next major release to be compliant with the new API. - // FIXME: unskip these for next major release - "strerror_r" | "madvise" | "msync" | "mprotect" | "recvfrom" | "getpriority" | - "setpriority" | "personality" => true, - // In Android 64 bits, these functions have been fixed since unified headers. - // Ignore these until next major version. - "bind" | "writev" | "readv" | "sendmsg" | "recvmsg" - if target_pointer_width == 64 => true, - - _ => false, - } - }); - - cfg.skip_static(move |name| { - match name { - // Internal constant, not declared in any headers. - // FIXME: still necessary - "__progname" => true, + // We can wait for the next major release to be compliant with the new API. + // FIXME: unskip these for next major release + "strerror_r" | "madvise" | "msync" | "mprotect" | "recvfrom" | "getpriority" | + _ => false, } }); - // FIXME: still necessary? cfg.skip_field_type(move |struct_, field| { // This is a weird union, don't check the type. + // FIXME: is this necessary? (struct_ == "ifaddrs" && field == "ifa_ifu") || // sighandler_t type is super weird + // FIXME: is this necessary? (struct_ == "sigaction" && field == "sa_sigaction") || // sigval is actually a union, but we pretend it's a struct + // FIXME: is this necessary? (struct_ == "sigevent" && field == "sigev_value") || // aio_buf is "volatile void*" and Rust doesn't understand volatile + // FIXME: is this necessary? (struct_ == "aiocb" && field == "aio_buf") }); - // FIXME: still necessary? cfg.skip_field(move |struct_, field| { // this is actually a union on linux, so we can't represent it well and // just insert some padding. + // FIXME: is this necessary? (struct_ == "siginfo_t" && field == "_pad") || + // musl names this __dummy1 but it's still there + // FIXME: is this necessary? + (struct_ == "glob_t" && field == "gl_flags") || + // musl seems to define this as an *anonymous* bitfield + // FIXME: is this necessary? + (struct_ == "statvfs" && field == "__f_unused") || // sigev_notify_thread_id is actually part of a sigev_un union (struct_ == "sigevent" && field == "sigev_notify_thread_id") || // signalfd had SIGSYS fields added in Linux 4.18, but no libc release has them yet. @@ -2084,133 +2224,204 @@ fn test_android(target: &str) { cfg.fn_cname(move |name, _cname| name.to_string()); cfg.generate("../src/lib.rs", "main.rs"); - - // On Android also generate another script for testing linux/fcntl - // declarations. These cannot be tested normally because including both - // `linux/fcntl.h` and `fcntl.h` fails. - // - // FIXME: is still necessary? - let mut cfg = ctest::TestGenerator::new(); - cfg.skip_type(|_| true) - .skip_fn(|_| true) - .skip_static(|_| true); - cfg.header("linux/fcntl.h"); - cfg.header("net/if.h"); - cfg.header("linux/if.h"); - cfg.header("linux/quota.h"); - cfg.header("asm/termbits.h"); - cfg.skip_const(move |name| match name { - "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => false, - "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => { - false - } - "BOTHER" => false, - _ => true, - }); - cfg.skip_struct(|s| s != "termios2"); - cfg.type_name(move |ty, is_struct, is_union| match ty { - t if is_struct => format!("struct {}", t), - t if is_union => format!("union {}", t), - t => t.to_string(), - }); - cfg.generate("../src/lib.rs", "linux_fcntl.rs"); } -fn test_freebsd(target: &str) { - assert!(target.contains("freebsd")); - let x86 = target.contains("i686") || target.contains("x86_64"); +fn test_linux(target: &str) { + assert!(target.contains("linux")); + + // target_env + let gnu = target.contains("gnu"); + let musl = target.contains("musl"); + let uclibc = target.contains("uclibc"); + + match (gnu, musl, uclibc) { + (true, false, false) => (), + (false, true, false) => (), + (false, false, true) => (), + (_, _, _) => panic!( + "linux target lib is gnu: {}, musl: {}, uclibc: {}", + gnu, musl, uclibc + ), + } + + let mips = target.contains("mips"); + let i686 = target.contains("i686"); + let x86_64 = target.contains("x86_64"); + let x32 = target.ends_with("gnux32"); let mut cfg = ctest::TestGenerator::new(); // FIXME: still necessary? - cfg.define("_WITH_GETLINE", None); + cfg.define("_GNU_SOURCE", None); // FIXME: still necessary? cfg.flag("-Wno-deprecated-declarations"); headers! { cfg: - "aio.h", - "arpa/inet.h", - "ctype.h", - "dirent.h", - "dlfcn.h", - "errno.h", - "fcntl.h", - "glob.h", - "grp.h", - "ifaddrs.h", - "langinfo.h", - "libutil.h", - "limits.h", - "locale.h", - "mqueue.h", - "net/bpf.h", - "net/if.h", - "net/if_arp.h", - "net/if_dl.h", - "net/route.h", - "netdb.h", - "netinet/in.h", - "netinet/tcp.h", - "netinet/udp.h", - "poll.h", - "pthread.h", - "pthread_np.h", - "pwd.h", - "resolv.h", - "sched.h", - "semaphore.h", - "signal.h", - "spawn.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "sys/event.h", - "sys/extattr.h", - "sys/file.h", - "sys/ioctl.h", - "sys/ipc.h", - "sys/jail.h", - "sys/mman.h", - "sys/mount.h", - "sys/msg.h", - "sys/procdesc.h", - "sys/ptrace.h", - "sys/resource.h", - "sys/rtprio.h", - "sys/shm.h", - "sys/socket.h", - "sys/stat.h", - "sys/statvfs.h", - "sys/time.h", - "sys/times.h", - "sys/types.h", - "sys/uio.h", - "sys/un.h", - "sys/utsname.h", - "sys/wait.h", - "syslog.h", - "termios.h", - "time.h", - "ufs/ufs/quota.h", - "unistd.h", - "utime.h", - "wchar.h", + "ctype.h", + "dirent.h", + "dlfcn.h", + "elf.h", + "fcntl.h", + "glob.h", + "grp.h", + "ifaddrs.h", + "langinfo.h", + "limits.h", + "link.h", + "linux/falloc.h", + "linux/fs.h", + "linux/genetlink.h", + "linux/if_alg.h", + "linux/if_ether.h", + "linux/if_tun.h", + "linux/input.h", + "linux/module.h", + "linux/net_tstamp.h", + "linux/netfilter_ipv4.h", + "linux/netfilter_ipv6.h", + "linux/netlink.h", + "linux/random.h", + "linux/seccomp.h", + "linux/sockios.h", + "locale.h", + "malloc.h", + "mntent.h", + "mqueue.h", + "net/ethernet.h", + "net/if.h", + "net/if_arp.h", + "net/route.h", + "netdb.h", + "netinet/in.h", + "netinet/ip.h", + "netinet/tcp.h", + "netinet/udp.h", + "netpacket/packet.h", + "poll.h", + "pthread.h", + "pty.h", + "pwd.h", + "resolv.h", + "sched.h", + "semaphore.h", + "shadow.h", + "signal.h", + "spawn.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/epoll.h", + "sys/eventfd.h", + "sys/file.h", + "sys/fsuid.h", + "sys/inotify.h", + "sys/ioctl.h", + "sys/ipc.h", + "sys/mman.h", + "sys/mount.h", + "sys/msg.h", + "sys/personality.h", + "sys/prctl.h", + "sys/ptrace.h", + "sys/quota.h", + "sys/reboot.h", + "sys/resource.h", + "sys/sem.h", + "sys/sendfile.h", + "sys/shm.h", + "sys/signalfd.h", + "sys/socket.h", + "sys/stat.h", + "sys/statvfs.h", + "sys/swap.h", + "sys/syscall.h", + "sys/time.h", + "sys/timerfd.h", + "sys/times.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/user.h", + "sys/utsname.h", + "sys/vfs.h", + "sys/wait.h", + "syslog.h", + "termios.h", + "time.h", + "ucontext.h", + "unistd.h", + "utime.h", + "utmp.h", + "wchar.h", + "errno.h", + } + + if x86_64 { + headers! { cfg: "sys/io.h" }; + } + if i686 || x86_64 { + headers! { cfg: "sys/reg.h" }; + } + + if !musl { + assert!(uclibc || gnu); + headers! { cfg: + "asm/mman.h", + "linux/if.h", + "linux/magic.h", + "linux/netfilter/nf_tables.h", + "linux/reboot.h", + "sys/auxv.h", + }; + + if !x32 { + assert!((gnu || uclibc) && !x32); + headers! { cfg: "sys/sysctl.h", } + } + if !uclibc { + assert!(gnu); + headers! { cfg: + "execinfo.h", + "utmpx.h", + } + } + if !mips { + assert!((gnu || uclibc) && !mips); + headers! { cfg: "linux/quota.h" }; + } + } + + if !uclibc { + assert!(gnu || musl); + // optionally included in uclibc + headers! { cfg: + "sys/xattr.h", + "sys/sysinfo.h", + "aio.h", + } + } + + // DCCP support + if !uclibc && !musl { + assert!(gnu); + headers! { cfg: "linux/dccp.h" }; + } + + if !musl || mips { + assert!(gnu || uclibc || (mips && !musl)); + headers! { cfg: "linux/memfd.h" }; } cfg.type_name(move |ty, is_struct, is_union| { match ty { // Just pass all these through, no need for a "struct" prefix - // FIXME: still required? "FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" | "Elf64_Phdr" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym" | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr" | "Elf64_Chdr" => ty.to_string(), - // FIXME: still required? - "sighandler_t" => "sig_t".to_string(), - t if is_union => format!("union {}", t), t if t.ends_with("_t") => t.to_string(), @@ -2229,9 +2440,9 @@ fn test_freebsd(target: &str) { s if s.ends_with("_nsec") && struct_.starts_with("stat") => { s.replace("e_nsec", ".tv_nsec") } - // FIXME: still required? + // FIXME: is this necessary? "u64" if struct_ == "epoll_event" => "data.u64".to_string(), - // FIXME: still required? + // FIXME: is this necessary? "type_" if struct_ == "input_event" || struct_ == "input_mask" @@ -2247,7 +2458,7 @@ fn test_freebsd(target: &str) { cfg.skip_type(move |ty| { match ty { // sighandler_t is crazy across platforms - // FIXME: still required? + // FIXME: is this necessary? "sighandler_t" => true, _ => false, @@ -2256,97 +2467,192 @@ fn test_freebsd(target: &str) { cfg.skip_struct(move |ty| { match ty { + // FIXME: is this necessary? + "sockaddr_nl" if musl => true, + + // On Linux, the type of `ut_tv` field of `struct utmpx` + // can be an anonymous struct, so an extra struct, + // which is absent in glibc, has to be defined. + "__timeval" => true, + // This is actually a union, not a struct - // FIXME: still required? "sigval" => true, + // Linux kernel headers used on musl are too old to have this + // definition. Because it's tested on other Linux targets, skip it. + // FIXME: is this necessary? + "input_mask" if musl => true, + // These are tested as part of the linux_fcntl tests since there are // header conflicts when including them with all the other structs. - // FIXME: still required? - "termios2" => true, - - _ => false, - } - }); - - cfg.skip_signededness(move |c| { - match c { - // FIXME: still required? - "LARGE_INTEGER" | "float" | "double" => true, - // FIXME: still required? - n if n.starts_with("pthread") => true, - // sem_t is a struct or pointer - // FIXME: still required? - "sem_t" => true, - // mqd_t is a pointer on FreeBSD - // FIXME: still required? - "mqd_t" => true, + // FIXME: is this necessary? + "termios2" => true, _ => false, } }); + cfg.skip_signededness(move |c| match c { + // FIXME: is this necessary? + "LARGE_INTEGER" | "float" | "double" => true, + // FIXME: is this necessary? + n if n.starts_with("pthread") => true, + _ => false, + }); + cfg.skip_const(move |name| { match name { - // FIXME: still required? + // FIXME: is this necessary? "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness - // FIXME: still required? - "SIGUNUSED" => true, // removed in glibc 2.26 + // FIXME: is this necessary? + "SIGUNUSED" => true, // removed in glibc 2.26 + + // types on musl are defined a little differently + // FIXME: is this necessary? + n if musl && n.contains("__SIZEOF_PTHREAD") => true, + + // Skip constants not defined in MUSL but just passed down to the + // kernel regardless + // FIXME: is this necessary? + "RLIMIT_NLIMITS" + | "TCP_COOKIE_TRANSACTIONS" + | "RLIMIT_RTTIME" + | "MSG_COPY" + if musl => + { + true + } + // work around super old mips toolchain + // FIXME: is this necessary? + "SCHED_IDLE" | "SHM_NORESERVE" => mips, // weird signed extension or something like that? - // FIXME: still required? + // FIXME: is this necessary? "MS_NOUSER" => true, - // FIXME: still required? + // FIXME: is this necessary? "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13 - // These constants were removed in FreeBSD 11 (svn r273250) but will - // still be accepted and ignored at runtime. - "MAP_RENAME" | "MAP_NORESERVE" => true, + // These are either unimplemented or optionally built into uClibc + // FIXME: is this necessary? + "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" + | "RTLD_DEEPBIND" + | "SOL_IPV6" + | "SOL_ICMPV6" + if uclibc => + { + true + } - // These constants were removed in FreeBSD 11 (svn r262489), - // and they've never had any legitimate use outside of the - // base system anyway. - "CTL_MAXID" | "KERN_MAXID" | "HW_MAXID" | "NET_MAXID" - | "USER_MAXID" => true, + // Musl uses old, patched kernel headers + // FIXME: is this necessary? + "FALLOC_FL_COLLAPSE_RANGE" + | "FALLOC_FL_ZERO_RANGE" + | "FALLOC_FL_INSERT_RANGE" + | "FALLOC_FL_UNSHARE_RANGE" + | "RENAME_NOREPLACE" + | "RENAME_EXCHANGE" + | "RENAME_WHITEOUT" + // ALG_SET_AEAD_* constants are available starting from kernel 3.19 + | "ALG_SET_AEAD_ASSOCLEN" + | "ALG_SET_AEAD_AUTHSIZE" + if musl => + { + true + } - // These constants were added in FreeBSD 11 - // FIXME: still required? - "EVFILT_PROCDESC" | "EVFILT_SENDFILE" | "EVFILT_EMPTY" - | "PD_CLOEXEC" | "PD_ALLOWED_AT_FORK" => true, + // musl uses old kernel headers + // These are constants used in getrandom syscall + // FIXME: is this necessary? + "GRND_NONBLOCK" | "GRND_RANDOM" if musl => true, - // These constants were added in FreeBSD 12 - // FIXME: still required? - "SF_USER_READAHEAD" | "SO_REUSEPORT_LB" => true, + // Defined by libattr not libc on linux (hard to test). + // See constant definition for more details. + // FIXME: is this necessary? + "ENOATTR" => true, - // These constants are tested in a separate test program generated - // below because there are header conflicts if we try to include the - // headers that define them here. - // FIXME: still required? + // On mips*-unknown-linux-gnu* CMSPAR cannot be included with the set of headers we + // want to use here for testing. It's originally defined in asm/termbits.h, which is + // also included by asm/termios.h, but not the standard termios.h. There's no way to + // include both asm/termbits.h and termios.h and there's no way to include both + // asm/termios.h and ioctl.h (+ some other headers) because of redeclared types. + // FIXME: is this necessary? + "CMSPAR" if mips && !musl => true, + + // On mips Linux targets, MADV_SOFT_OFFLINE is currently missing, though it's been added but CI has too old + // of a Linux version. Since it exists on all other Linux targets, just ignore this for now and remove once + // it's been fixed in CI. + // FIXME: is this necessary? + "MADV_SOFT_OFFLINE" if mips => true, + + // These constants are tested in a separate test program generated below because there + // are header conflicts if we try to include the headers that define them here. + // FIXME: is this necessary? "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => true, - // FIXME: still required? + // FIXME: is this necessary? "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" - | "F_SEAL_WRITE" => true, - // FIXME: still required? + | "F_SEAL_WRITE" => true, + // FIXME: is this necessary? + "QFMT_VFS_OLD" | "QFMT_VFS_V0" | "QFMT_VFS_V1" + if mips => + { + true + } // Only on MIPS + // FIXME: is this necessary? "BOTHER" => true, - // MFD_HUGETLB is not available in some older libc versions on the - // CI builders. On the x86_64 and i686 builders it seems to be - // available for all targets, so at least test it there. - // FIXME: still required? - "MFD_HUGETLB" if !x86 => true, + // FIXME: is this necessary? + "MFD_CLOEXEC" | "MFD_ALLOW_SEALING" if !mips && musl => true, + // MFD_HUGETLB is not available in some older libc versions on the CI builders. On the + // x86_64 and i686 builders it seems to be available for all targets, so at least test + // it there. + // FIXME: is this necessary? + "MFD_HUGETLB" + if !(x86_64 || i686) || musl => + { + true + } + + // These are defined for Solaris 11, but the crate is tested on + // illumos, where they are currently not defined + // FIXME: is this necessary? + "EADI" + | "PORT_SOURCE_POSTWAIT" + | "PORT_SOURCE_SIGNAL" + | "PTHREAD_STACK_MIN" => true, // These change all the time from release to release of linux // distros, let's just not bother trying to verify them. They // shouldn't be used in code anyway... - // FIXME: still required? + // FIXME: is this necessary? "AF_MAX" | "PF_MAX" => true, - // FreeBSD 12 required, but CI has FreeBSD 11. - // FIXME: still required? - "IP_ORIGDSTADDR" - | "IP_RECVORIGDSTADDR" - | "IPV6_ORIGDSTADDR" - | "IPV6_RECVORIGDSTADDR" => true, + // These are not in a glibc release yet, only in kernel headers. + // FIXME: is this necessary? + "AF_XDP" + | "PF_XDP" + | "SOL_XDP" + | "IPV6_FLOWINFO" + | "IPV6_FLOWLABEL_MGR" + | "IPV6_FLOWINFO_SEND" + | "IPV6_FLOWINFO_FLOWLABEL" + | "IPV6_FLOWINFO_PRIORITY" + => + { + true + } _ => false, } @@ -2355,71 +2661,95 @@ fn test_freebsd(target: &str) { cfg.skip_fn(move |name| { // skip those that are manually verified match name { - // FIXME: still required? "execv" | // crazy stuff with const/mut "execve" | "execvp" | "execvpe" | "fexecve" => true, - // The `uname` function in freebsd is now an inline wrapper that - // delegates to another, but the symbol still exists, so don't check - // the symbol. - // FIXME: still required? - "uname" => true, + "getrlimit" | "getrlimit64" | // non-int in 1st arg + "setrlimit" | "setrlimit64" | // non-int in 1st arg + "prlimit" | "prlimit64" | // non-int in 2nd arg - // FIXME: need to upgrade FreeBSD version; see https://github.com/rust-lang/libc/issues/938 - // FIXME: still required? - "setgrent" => true, + // int vs uint. Sorry musl, your prototype declarations are "correct" in the sense that + // they match the interface defined by Linux verbatim, but they conflict with other + // send*/recv* syscalls + // FIXME: is this necessary? + "sendmmsg" | "recvmmsg" if musl => true, - // aio_waitcomplete's return type changed between FreeBSD 10 and 11. - // FIXME: still required? - "aio_waitcomplete" => true, + // typed 2nd arg on linux + // FIXME: is this necessary? + "gettimeofday" => true, - // lio_listio confuses the checker, probably because one of its - // arguments is an array - // FIXME: still required? - "lio_listio" => true, + // FIXME: is this necessary? + "dladdr" if musl => true, // const-ness only added recently + + // There seems to be a small error in EGLIBC's eventfd.h header. The + // [underlying system call][1] always takes its first `count` + // argument as an `unsigned int`, but [EGLIBC's + // header][2] declares it to take an `int`. [GLIBC's header][3] + // matches the kernel. + // + // EGLIBC is no longer actively developed, and Debian, the largest + // distribution that had been using it, switched back to GLIBC in + // April 2015. So effectively all Linux headers will + // be using `unsigned int` soon. + // + // [1]: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/fs/eventfd.c?id=refs/tags/v3.12.51#n397 + // [2]: http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/trusty/eglibc/trusty/view/head:/sysdeps/unix/sysv/linux/sys/eventfd.h + // [3]: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/sys/eventfd.h;h=6295f32e937e779e74318eb9d3bdbe76aef8a8f3;hb=4e42b5b8f89f0e288e68be7ad70f9525aebc2cff#l34 + // FIXME: is this necessary? + "eventfd" => true, + + "lio_listio" if musl => true, + + // 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 + "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 => true, // Definition of those functions as changed since unified headers from NDK r14b // These changes imply some API breaking changes but are still ABI compatible. // We can wait for the next major release to be compliant with the new API. // FIXME: unskip these for next major release - // FIXME: still required ? - "strerror_r" | "madvise" | "msync" | "mprotect" | "recvfrom" | "getpriority" | + "strerror_r" | "madvise" | "msync" | "mprotect" | "recvfrom" | "getpriority" => true, _ => false, } }); + // FIXME: is this necessary? cfg.skip_field_type(move |struct_, field| { // This is a weird union, don't check the type. - // FIXME: still required? (struct_ == "ifaddrs" && field == "ifa_ifu") || - // FIXME: still required? // sighandler_t type is super weird - (struct_ == "sigaction" && field == "sa_sigaction") || - // FIXME: still required? + (struct_ == "sigaction" && field == "sa_sigaction") || + // __timeval type is a patch which doesn't exist in glibc + (struct_ == "utmpx" && field == "ut_tv") || // sigval is actually a union, but we pretend it's a struct - (struct_ == "sigevent" && field == "sigev_value") || + (struct_ == "sigevent" && field == "sigev_value") || // aio_buf is "volatile void*" and Rust doesn't understand volatile - // FIXME: still required? - (struct_ == "aiocb" && field == "aio_buf") || - // stack_t.ss_sp's type changed from FreeBSD 10 to 11 in svn r294930 - // FIXME: still required? - (struct_ == "stack_t" && field == "ss_sp") + (struct_ == "aiocb" && field == "aio_buf") || + // this one is an anonymous union + (struct_ == "ff_effect" && field == "u") }); cfg.skip_field(move |struct_, field| { // this is actually a union on linux, so we can't represent it well and // just insert some padding. - // FIXME: still required? (struct_ == "siginfo_t" && field == "_pad") || + // musl names this __dummy1 but it's still there + (musl && struct_ == "glob_t" && field == "gl_flags") || + // 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 - // FIXME: still required? (struct_ == "sigevent" && field == "sigev_notify_thread_id") || // signalfd had SIGSYS fields added in Linux 4.18, but no libc release has them yet. - // FIXME: still required? (struct_ == "signalfd_siginfo" && (field == "ssi_addr_lsb" || field == "_pad2" || field == "ssi_syscall" || @@ -2431,4 +2761,40 @@ fn test_freebsd(target: &str) { cfg.fn_cname(move |name, _cname| name.to_string()); cfg.generate("../src/lib.rs", "main.rs"); + + // On Linux also generate another script for testing linux/fcntl declarations. + // These cannot be tested normally because including both `linux/fcntl.h` and `fcntl.h` + // fails on a lot of platforms. + let mut cfg = ctest::TestGenerator::new(); + cfg.skip_type(|_| true) + .skip_fn(|_| true) + .skip_static(|_| true); + // musl defines these directly in `fcntl.h` + if musl { + cfg.header("fcntl.h"); + } else { + cfg.header("linux/fcntl.h"); + } + if !musl { + cfg.header("net/if.h"); + cfg.header("linux/if.h"); + } + cfg.header("linux/quota.h"); + cfg.header("asm/termbits.h"); + cfg.skip_const(move |name| match name { + "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => false, + "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => { + false + } + "QFMT_VFS_OLD" | "QFMT_VFS_V0" | "QFMT_VFS_V1" if mips => false, + "BOTHER" => false, + _ => true, + }); + cfg.skip_struct(|s| s != "termios2"); + cfg.type_name(move |ty, is_struct, is_union| match ty { + t if is_struct => format!("struct {}", t), + t if is_union => format!("union {}", t), + t => t.to_string(), + }); + cfg.generate("../src/lib.rs", "linux_fcntl.rs"); } From 18bf94c6eb41991fb96990439873debed67265fd Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 14 May 2019 12:00:16 +0200 Subject: [PATCH 06/50] Update all remaining targets to Ubuntu 18.04 --- ci/docker/aarch64-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/arm-unknown-linux-gnueabihf/Dockerfile | 2 +- ci/docker/asmjs-unknown-emscripten/Dockerfile | 2 +- ci/docker/mips-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile | 2 +- ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile | 2 +- ci/docker/s390x-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/wasm32-unknown-emscripten/Dockerfile | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ci/docker/aarch64-unknown-linux-gnu/Dockerfile b/ci/docker/aarch64-unknown-linux-gnu/Dockerfile index 18214a3e646f9..a137e03e69a79 100644 --- a/ci/docker/aarch64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/aarch64-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:17.10 +FROM ubuntu:18.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev ca-certificates \ gcc-aarch64-linux-gnu libc6-dev-arm64-cross qemu-user diff --git a/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile b/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile index 9fe71dcf87cb0..5a75d29a89006 100644 --- a/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile +++ b/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:17.10 +FROM ubuntu:18.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev ca-certificates \ gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user diff --git a/ci/docker/asmjs-unknown-emscripten/Dockerfile b/ci/docker/asmjs-unknown-emscripten/Dockerfile index 3088fc53c442f..b8fdd1c18a7ef 100644 --- a/ci/docker/asmjs-unknown-emscripten/Dockerfile +++ b/ci/docker/asmjs-unknown-emscripten/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:16.04 +FROM ubuntu:18.04 RUN apt-get update && \ apt-get install -y --no-install-recommends \ diff --git a/ci/docker/mips-unknown-linux-gnu/Dockerfile b/ci/docker/mips-unknown-linux-gnu/Dockerfile index c66abd471b0f8..72eff78fcb6bd 100644 --- a/ci/docker/mips-unknown-linux-gnu/Dockerfile +++ b/ci/docker/mips-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:17.10 +FROM ubuntu:18.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ diff --git a/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile b/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile index b9921fcc50d22..246a9bf684d24 100644 --- a/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile +++ b/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:17.10 +FROM ubuntu:18.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ diff --git a/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile b/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile index 434c90819eb57..8b2f9f727a303 100644 --- a/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile +++ b/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:17.10 +FROM ubuntu:18.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ diff --git a/ci/docker/s390x-unknown-linux-gnu/Dockerfile b/ci/docker/s390x-unknown-linux-gnu/Dockerfile index 861f4f9b00ee0..0f58b76e2439f 100644 --- a/ci/docker/s390x-unknown-linux-gnu/Dockerfile +++ b/ci/docker/s390x-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:17.10 +FROM ubuntu:18.04 RUN apt-get update && apt-get install -y --no-install-recommends \ curl ca-certificates \ diff --git a/ci/docker/wasm32-unknown-emscripten/Dockerfile b/ci/docker/wasm32-unknown-emscripten/Dockerfile index 59bf7d9a23a45..1062717c4d8e8 100644 --- a/ci/docker/wasm32-unknown-emscripten/Dockerfile +++ b/ci/docker/wasm32-unknown-emscripten/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:16.04 +FROM ubuntu:18.04 RUN apt-get update && \ apt-get install -y --no-install-recommends \ From 3956bf056befd69f4790cc447500278a93f15840 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 14 May 2019 12:16:00 +0200 Subject: [PATCH 07/50] Skip verification of gettimeofday on FreeBSD --- libc-test/build.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 567fa975612b1..311a0f99576d0 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1813,6 +1813,9 @@ fn test_freebsd(target: &str) { "execvpe" | "fexecve" => true, + // FIXME: for some reason, our signature is wrong + "gettimeofday" => true, + // The `uname` function in freebsd is now an inline wrapper that // delegates to another, but the symbol still exists, so don't check // the symbol. From 26d919382c489a5ee138e5c885ce9c57b5bb0676 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 14 May 2019 12:20:05 +0200 Subject: [PATCH 08/50] Warn users of gettimeofday of potential breaking change --- src/unix/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 1be0095343635..cfd2246b44010 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -837,6 +837,14 @@ extern { pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__gettimeofday50")] + #[deprecated( + since="0.2.54", + note= + "The signature of this function is incorrect. \ + If you are using it, please report that in the following issue \ + so that we can evaluate the impact of fixing it: \ + https://github.com/rust-lang/libc/issues/1338" + )] pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__times13")] From bee261136851af91279c7dde6286762055aee773 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 14 May 2019 12:25:22 +0200 Subject: [PATCH 09/50] Remove conflicting linux/netfilter_ipv4.h header file due to conflicting definitions --- libc-test/build.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 311a0f99576d0..878feabf4e27d 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2280,7 +2280,6 @@ fn test_linux(target: &str) { "linux/input.h", "linux/module.h", "linux/net_tstamp.h", - "linux/netfilter_ipv4.h", "linux/netfilter_ipv6.h", "linux/netlink.h", "linux/random.h", From 0f96e543b1f5e81bfcbc3766e07c0e6c58238e72 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 14 May 2019 12:40:30 +0200 Subject: [PATCH 10/50] Remove conflicting linux/netfilter_ipv6.h header file due to conflicting definitions --- libc-test/build.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 878feabf4e27d..07ea556da5e45 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2280,7 +2280,6 @@ fn test_linux(target: &str) { "linux/input.h", "linux/module.h", "linux/net_tstamp.h", - "linux/netfilter_ipv6.h", "linux/netlink.h", "linux/random.h", "linux/seccomp.h", From bb2f29641ab6640ebe4f73624e1a050cd6540f99 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 14 May 2019 13:25:26 +0200 Subject: [PATCH 11/50] Add missing netinet/ip.h header --- libc-test/build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 07ea556da5e45..d28fbbc5488b4 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1600,6 +1600,7 @@ fn test_freebsd(target: &str) { "net/if_dl.h", "net/route.h", "netdb.h", + "netinet/ip.h", "netinet/in.h", "netinet/tcp.h", "netinet/udp.h", From 426f91bd251ebfc6cca7a79bba1ba4f7913fb375 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 14 May 2019 13:49:31 +0200 Subject: [PATCH 12/50] Fix typo in Linux checking --- libc-test/build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index d28fbbc5488b4..680136170f83f 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2671,7 +2671,8 @@ fn test_linux(target: &str) { "getrlimit" | "getrlimit64" | // non-int in 1st arg "setrlimit" | "setrlimit64" | // non-int in 1st arg - "prlimit" | "prlimit64" | // non-int in 2nd arg + "prlimit" | "prlimit64" // non-int in 2nd arg + => true, // int vs uint. Sorry musl, your prototype declarations are "correct" in the sense that // they match the interface defined by Linux verbatim, but they conflict with other From dc7311bec7fd58f29ee7af16ddb25dca6a9cc827 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 14 May 2019 14:01:40 +0200 Subject: [PATCH 13/50] Include aio.h before sys/mount.h on linux --- libc-test/build.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 680136170f83f..50082d8e2f68a 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2260,6 +2260,17 @@ fn test_linux(target: &str) { // FIXME: still necessary? cfg.flag("-Wno-deprecated-declarations"); + // note: aio.h must be included before sys/mount.h + if !uclibc { + assert!(gnu || musl); + // optionally included in uclibc + headers! { cfg: + "sys/xattr.h", + "sys/sysinfo.h", + "aio.h", + } + } + headers! { cfg: "ctype.h", "dirent.h", @@ -2395,16 +2406,6 @@ fn test_linux(target: &str) { } } - if !uclibc { - assert!(gnu || musl); - // optionally included in uclibc - headers! { cfg: - "sys/xattr.h", - "sys/sysinfo.h", - "aio.h", - } - } - // DCCP support if !uclibc && !musl { assert!(gnu); From 9da2fd5ace0a597a42d16425c1ab2ab704997f0f Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 14 May 2019 14:07:41 +0200 Subject: [PATCH 14/50] Add missing utmpx.h header to freebsd tests --- libc-test/build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 50082d8e2f68a..84f4ab825b5b4 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1648,6 +1648,7 @@ fn test_freebsd(target: &str) { "ufs/ufs/quota.h", "unistd.h", "utime.h", + "utmpx.h", "wchar.h", } From 54fcb89354cd9422f3a2691bcfa7935b91fb6518 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 14 May 2019 16:49:43 +0200 Subject: [PATCH 15/50] Add missing sysctl header to freebsd tests --- libc-test/build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 84f4ab825b5b4..e1472fd6b96c2 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1635,6 +1635,7 @@ fn test_freebsd(target: &str) { "sys/socket.h", "sys/stat.h", "sys/statvfs.h", + "sys/sysctl.h", "sys/time.h", "sys/times.h", "sys/types.h", From cb3a9db37887696d5d2426e325d554ae1a354139 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 14 May 2019 16:54:10 +0200 Subject: [PATCH 16/50] Include aio.h as the last header --- libc-test/build.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index e1472fd6b96c2..c4595ebd8f539 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2262,17 +2262,6 @@ fn test_linux(target: &str) { // FIXME: still necessary? cfg.flag("-Wno-deprecated-declarations"); - // note: aio.h must be included before sys/mount.h - if !uclibc { - assert!(gnu || musl); - // optionally included in uclibc - headers! { cfg: - "sys/xattr.h", - "sys/sysinfo.h", - "aio.h", - } - } - headers! { cfg: "ctype.h", "dirent.h", @@ -2419,6 +2408,17 @@ fn test_linux(target: &str) { headers! { cfg: "linux/memfd.h" }; } + // note: aio.h must be included before sys/mount.h + if !uclibc { + assert!(gnu || musl); + // optionally included in uclibc + headers! { cfg: + "sys/xattr.h", + "sys/sysinfo.h", + "aio.h", + } + } + cfg.type_name(move |ty, is_struct, is_union| { match ty { // Just pass all these through, no need for a "struct" prefix From 352ee1c37d04efd59dd067bbf151e3af33fe5cc6 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 14 May 2019 16:55:23 +0200 Subject: [PATCH 17/50] Include Linux headers after sys headers --- libc-test/build.rs | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index c4595ebd8f539..94735f0d22a2d 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2274,19 +2274,6 @@ fn test_linux(target: &str) { "langinfo.h", "limits.h", "link.h", - "linux/falloc.h", - "linux/fs.h", - "linux/genetlink.h", - "linux/if_alg.h", - "linux/if_ether.h", - "linux/if_tun.h", - "linux/input.h", - "linux/module.h", - "linux/net_tstamp.h", - "linux/netlink.h", - "linux/random.h", - "linux/seccomp.h", - "linux/sockios.h", "locale.h", "malloc.h", "mntent.h", @@ -2362,6 +2349,24 @@ fn test_linux(target: &str) { "errno.h", } + // Include linux headers at the end: + headers! { + cfg: + "linux/falloc.h", + "linux/fs.h", + "linux/genetlink.h", + "linux/if_alg.h", + "linux/if_ether.h", + "linux/if_tun.h", + "linux/input.h", + "linux/module.h", + "linux/net_tstamp.h", + "linux/netlink.h", + "linux/random.h", + "linux/seccomp.h", + "linux/sockios.h", + } + if x86_64 { headers! { cfg: "sys/io.h" }; } From f67f831aadb73f62095d70986dfccffdea36f84b Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 14 May 2019 17:41:32 +0200 Subject: [PATCH 18/50] readd netfilter headers --- libc-test/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 94735f0d22a2d..153783aad1265 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2361,6 +2361,8 @@ fn test_linux(target: &str) { "linux/input.h", "linux/module.h", "linux/net_tstamp.h", + "linux/netfilter_ipv4.h", + "linux/netfilter_ipv6.h", "linux/netlink.h", "linux/random.h", "linux/seccomp.h", From bf76ded067755d9a27caed357d30dba70652454d Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 07:59:38 +0200 Subject: [PATCH 19/50] Test the Elf32/64 types sperately These types have a p_types field, but the resolv.h header defines p_types __p_types macro that breaks them. --- libc-test/build.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 153783aad1265..9653de8701121 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2473,6 +2473,10 @@ fn test_linux(target: &str) { // FIXME: is this necessary? "sighandler_t" => true, + // These cannot be tested when "resolv.h" is included and are tested + // below. + "Elf64_Phdr" | "Elf32_Phdr" => true, + _ => false, } }); @@ -2482,6 +2486,10 @@ fn test_linux(target: &str) { // FIXME: is this necessary? "sockaddr_nl" if musl => true, + // These cannot be tested when "resolv.h" is included and are tested + // below. + "Elf64_Phdr" | "Elf32_Phdr" => true, + // On Linux, the type of `ut_tv` field of `struct utmpx` // can be an anonymous struct, so an extra struct, // which is absent in glibc, has to be defined. @@ -2810,4 +2818,30 @@ fn test_linux(target: &str) { t => t.to_string(), }); cfg.generate("../src/lib.rs", "linux_fcntl.rs"); + + // Test Elf64_Phdr and Elf32_Phdr + // These types have a field called `p_type`, but including + // "resolve.h" defines a `p_type` macro that expands to `__p_type` + // making the tests for these fails when both are included. + let mut cfg = ctest::TestGenerator::new(); + cfg.skip_fn(|_| true) + .skip_const(|_| true) + .skip_static(|_| true) + .type_name(move |ty, _is_struct, _is_union| { + ty.to_string() + }); + cfg.skip_struct(move |ty| { + match ty { + "Elf64_Phdr" | "Elf32_Phdr" => false, + _ => true, + } + }); + cfg.skip_type(move |ty| { + match ty { + "Elf64_Phdr" | "Elf32_Phdr" => false, + _ => true, + } + }); + cfg.header("elf.h"); + cfg.generate("../src/lib.rs", "linux_elf.rs"); } From d2695436ba5072078796c76f727a296e0f43caa6 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 09:49:06 +0200 Subject: [PATCH 20/50] [breaking change] PTRACE_GETFPXREGS and PTRACE_SETFPXREGS were incorrectly re-exported on arm but they are x86 specific --- src/unix/notbsd/linux/other/b32/arm.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/unix/notbsd/linux/other/b32/arm.rs b/src/unix/notbsd/linux/other/b32/arm.rs index a70af4331f315..7f00d9a1139a7 100644 --- a/src/unix/notbsd/linux/other/b32/arm.rs +++ b/src/unix/notbsd/linux/other/b32/arm.rs @@ -136,9 +136,6 @@ pub const SO_RCVBUFFORCE: ::c_int = 33; pub const FIOCLEX: ::c_ulong = 0x5451; pub const FIONBIO: ::c_ulong = 0x5421; -pub const PTRACE_GETFPXREGS: ::c_uint = 18; -pub const PTRACE_SETFPXREGS: ::c_uint = 19; - pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; From 5bdb28fd6a8ec32384e636a63b1b5130f03e4bd5 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 12:16:48 +0200 Subject: [PATCH 21/50] [breaking change] remove SYS_reserved and SYS_unused constants --- src/unix/notbsd/linux/mips/mips32.rs | 8 -------- src/unix/notbsd/linux/mips/mips64.rs | 2 -- src/unix/notbsd/linux/musl/b32/mips.rs | 8 -------- src/unix/uclibc/mips/mips32/mod.rs | 8 -------- 4 files changed, 26 deletions(-) diff --git a/src/unix/notbsd/linux/mips/mips32.rs b/src/unix/notbsd/linux/mips/mips32.rs index 991161395444a..d9d55891309d7 100644 --- a/src/unix/notbsd/linux/mips/mips32.rs +++ b/src/unix/notbsd/linux/mips/mips32.rs @@ -353,7 +353,6 @@ pub const SYS_mknod: ::c_long = 4000 + 14; pub const SYS_chmod: ::c_long = 4000 + 15; pub const SYS_lchown: ::c_long = 4000 + 16; pub const SYS_break: ::c_long = 4000 + 17; -pub const SYS_unused18: ::c_long = 4000 + 18; pub const SYS_lseek: ::c_long = 4000 + 19; pub const SYS_getpid: ::c_long = 4000 + 20; pub const SYS_mount: ::c_long = 4000 + 21; @@ -363,7 +362,6 @@ pub const SYS_getuid: ::c_long = 4000 + 24; pub const SYS_stime: ::c_long = 4000 + 25; pub const SYS_ptrace: ::c_long = 4000 + 26; pub const SYS_alarm: ::c_long = 4000 + 27; -pub const SYS_unused28: ::c_long = 4000 + 28; pub const SYS_pause: ::c_long = 4000 + 29; pub const SYS_utime: ::c_long = 4000 + 30; pub const SYS_stty: ::c_long = 4000 + 31; @@ -394,7 +392,6 @@ pub const SYS_fcntl: ::c_long = 4000 + 55; pub const SYS_mpx: ::c_long = 4000 + 56; pub const SYS_setpgid: ::c_long = 4000 + 57; pub const SYS_ulimit: ::c_long = 4000 + 58; -pub const SYS_unused59: ::c_long = 4000 + 59; pub const SYS_umask: ::c_long = 4000 + 60; pub const SYS_chroot: ::c_long = 4000 + 61; pub const SYS_ustat: ::c_long = 4000 + 62; @@ -417,9 +414,7 @@ pub const SYS_gettimeofday: ::c_long = 4000 + 78; pub const SYS_settimeofday: ::c_long = 4000 + 79; pub const SYS_getgroups: ::c_long = 4000 + 80; pub const SYS_setgroups: ::c_long = 4000 + 81; -pub const SYS_reserved82: ::c_long = 4000 + 82; pub const SYS_symlink: ::c_long = 4000 + 83; -pub const SYS_unused84: ::c_long = 4000 + 84; pub const SYS_readlink: ::c_long = 4000 + 85; pub const SYS_uselib: ::c_long = 4000 + 86; pub const SYS_swapon: ::c_long = 4000 + 87; @@ -444,7 +439,6 @@ pub const SYS_getitimer: ::c_long = 4000 + 105; pub const SYS_stat: ::c_long = 4000 + 106; pub const SYS_lstat: ::c_long = 4000 + 107; pub const SYS_fstat: ::c_long = 4000 + 108; -pub const SYS_unused109: ::c_long = 4000 + 109; pub const SYS_iopl: ::c_long = 4000 + 110; pub const SYS_vhangup: ::c_long = 4000 + 111; pub const SYS_idle: ::c_long = 4000 + 112; @@ -485,7 +479,6 @@ pub const SYS_writev: ::c_long = 4000 + 146; pub const SYS_cacheflush: ::c_long = 4000 + 147; pub const SYS_cachectl: ::c_long = 4000 + 148; pub const SYS_sysmips: ::c_long = 4000 + 149; -pub const SYS_unused150: ::c_long = 4000 + 150; pub const SYS_getsid: ::c_long = 4000 + 151; pub const SYS_fdatasync: ::c_long = 4000 + 152; pub const SYS__sysctl: ::c_long = 4000 + 153; @@ -556,7 +549,6 @@ pub const SYS_mincore: ::c_long = 4000 + 217; pub const SYS_madvise: ::c_long = 4000 + 218; pub const SYS_getdents64: ::c_long = 4000 + 219; pub const SYS_fcntl64: ::c_long = 4000 + 220; -pub const SYS_reserved221: ::c_long = 4000 + 221; pub const SYS_gettid: ::c_long = 4000 + 222; pub const SYS_readahead: ::c_long = 4000 + 223; pub const SYS_setxattr: ::c_long = 4000 + 224; diff --git a/src/unix/notbsd/linux/mips/mips64.rs b/src/unix/notbsd/linux/mips/mips64.rs index c4247c976c9bd..f480e50a848ef 100644 --- a/src/unix/notbsd/linux/mips/mips64.rs +++ b/src/unix/notbsd/linux/mips/mips64.rs @@ -496,7 +496,6 @@ pub const SYS_nfsservctl: ::c_long = 5000 + 173; pub const SYS_getpmsg: ::c_long = 5000 + 174; pub const SYS_putpmsg: ::c_long = 5000 + 175; pub const SYS_afs_syscall: ::c_long = 5000 + 176; -pub const SYS_reserved177: ::c_long = 5000 + 177; pub const SYS_gettid: ::c_long = 5000 + 178; pub const SYS_readahead: ::c_long = 5000 + 179; pub const SYS_setxattr: ::c_long = 5000 + 180; @@ -512,7 +511,6 @@ pub const SYS_removexattr: ::c_long = 5000 + 189; pub const SYS_lremovexattr: ::c_long = 5000 + 190; pub const SYS_fremovexattr: ::c_long = 5000 + 191; pub const SYS_tkill: ::c_long = 5000 + 192; -pub const SYS_reserved193: ::c_long = 5000 + 193; pub const SYS_futex: ::c_long = 5000 + 194; pub const SYS_sched_setaffinity: ::c_long = 5000 + 195; pub const SYS_sched_getaffinity: ::c_long = 5000 + 196; diff --git a/src/unix/notbsd/linux/musl/b32/mips.rs b/src/unix/notbsd/linux/musl/b32/mips.rs index b0694d1ea8230..37430af5f90d7 100644 --- a/src/unix/notbsd/linux/musl/b32/mips.rs +++ b/src/unix/notbsd/linux/musl/b32/mips.rs @@ -514,7 +514,6 @@ pub const SYS_mknod: ::c_long = 4000 + 14; pub const SYS_chmod: ::c_long = 4000 + 15; pub const SYS_lchown: ::c_long = 4000 + 16; pub const SYS_break: ::c_long = 4000 + 17; -pub const SYS_unused18: ::c_long = 4000 + 18; pub const SYS_lseek: ::c_long = 4000 + 19; pub const SYS_getpid: ::c_long = 4000 + 20; pub const SYS_mount: ::c_long = 4000 + 21; @@ -524,7 +523,6 @@ pub const SYS_getuid: ::c_long = 4000 + 24; pub const SYS_stime: ::c_long = 4000 + 25; pub const SYS_ptrace: ::c_long = 4000 + 26; pub const SYS_alarm: ::c_long = 4000 + 27; -pub const SYS_unused28: ::c_long = 4000 + 28; pub const SYS_pause: ::c_long = 4000 + 29; pub const SYS_utime: ::c_long = 4000 + 30; pub const SYS_stty: ::c_long = 4000 + 31; @@ -555,7 +553,6 @@ pub const SYS_fcntl: ::c_long = 4000 + 55; pub const SYS_mpx: ::c_long = 4000 + 56; pub const SYS_setpgid: ::c_long = 4000 + 57; pub const SYS_ulimit: ::c_long = 4000 + 58; -pub const SYS_unused59: ::c_long = 4000 + 59; pub const SYS_umask: ::c_long = 4000 + 60; pub const SYS_chroot: ::c_long = 4000 + 61; pub const SYS_ustat: ::c_long = 4000 + 62; @@ -578,9 +575,7 @@ pub const SYS_gettimeofday: ::c_long = 4000 + 78; pub const SYS_settimeofday: ::c_long = 4000 + 79; pub const SYS_getgroups: ::c_long = 4000 + 80; pub const SYS_setgroups: ::c_long = 4000 + 81; -pub const SYS_reserved82: ::c_long = 4000 + 82; pub const SYS_symlink: ::c_long = 4000 + 83; -pub const SYS_unused84: ::c_long = 4000 + 84; pub const SYS_readlink: ::c_long = 4000 + 85; pub const SYS_uselib: ::c_long = 4000 + 86; pub const SYS_swapon: ::c_long = 4000 + 87; @@ -605,7 +600,6 @@ pub const SYS_getitimer: ::c_long = 4000 + 105; pub const SYS_stat: ::c_long = 4000 + 106; pub const SYS_lstat: ::c_long = 4000 + 107; pub const SYS_fstat: ::c_long = 4000 + 108; -pub const SYS_unused109: ::c_long = 4000 + 109; pub const SYS_iopl: ::c_long = 4000 + 110; pub const SYS_vhangup: ::c_long = 4000 + 111; pub const SYS_idle: ::c_long = 4000 + 112; @@ -645,7 +639,6 @@ pub const SYS_writev: ::c_long = 4000 + 146; pub const SYS_cacheflush: ::c_long = 4000 + 147; pub const SYS_cachectl: ::c_long = 4000 + 148; pub const SYS_sysmips: ::c_long = 4000 + 149; -pub const SYS_unused150: ::c_long = 4000 + 150; pub const SYS_getsid: ::c_long = 4000 + 151; pub const SYS_fdatasync: ::c_long = 4000 + 152; pub const SYS__sysctl: ::c_long = 4000 + 153; @@ -714,7 +707,6 @@ pub const SYS_mincore: ::c_long = 4000 + 217; pub const SYS_madvise: ::c_long = 4000 + 218; pub const SYS_getdents64: ::c_long = 4000 + 219; pub const SYS_fcntl64: ::c_long = 4000 + 220; -pub const SYS_reserved221: ::c_long = 4000 + 221; pub const SYS_gettid: ::c_long = 4000 + 222; pub const SYS_readahead: ::c_long = 4000 + 223; pub const SYS_setxattr: ::c_long = 4000 + 224; diff --git a/src/unix/uclibc/mips/mips32/mod.rs b/src/unix/uclibc/mips/mips32/mod.rs index 23b385424487e..410ab70c440a1 100644 --- a/src/unix/uclibc/mips/mips32/mod.rs +++ b/src/unix/uclibc/mips/mips32/mod.rs @@ -247,7 +247,6 @@ pub const SYS_mknod: ::c_long = 4000 + 14; pub const SYS_chmod: ::c_long = 4000 + 15; pub const SYS_lchown: ::c_long = 4000 + 16; pub const SYS_break: ::c_long = 4000 + 17; -pub const SYS_unused18: ::c_long = 4000 + 18; pub const SYS_lseek: ::c_long = 4000 + 19; pub const SYS_getpid: ::c_long = 4000 + 20; pub const SYS_mount: ::c_long = 4000 + 21; @@ -257,7 +256,6 @@ pub const SYS_getuid: ::c_long = 4000 + 24; pub const SYS_stime: ::c_long = 4000 + 25; pub const SYS_ptrace: ::c_long = 4000 + 26; pub const SYS_alarm: ::c_long = 4000 + 27; -pub const SYS_unused28: ::c_long = 4000 + 28; pub const SYS_pause: ::c_long = 4000 + 29; pub const SYS_utime: ::c_long = 4000 + 30; pub const SYS_stty: ::c_long = 4000 + 31; @@ -288,7 +286,6 @@ pub const SYS_fcntl: ::c_long = 4000 + 55; pub const SYS_mpx: ::c_long = 4000 + 56; pub const SYS_setpgid: ::c_long = 4000 + 57; pub const SYS_ulimit: ::c_long = 4000 + 58; -pub const SYS_unused59: ::c_long = 4000 + 59; pub const SYS_umask: ::c_long = 4000 + 60; pub const SYS_chroot: ::c_long = 4000 + 61; pub const SYS_ustat: ::c_long = 4000 + 62; @@ -311,9 +308,7 @@ pub const SYS_gettimeofday: ::c_long = 4000 + 78; pub const SYS_settimeofday: ::c_long = 4000 + 79; pub const SYS_getgroups: ::c_long = 4000 + 80; pub const SYS_setgroups: ::c_long = 4000 + 81; -pub const SYS_reserved82: ::c_long = 4000 + 82; pub const SYS_symlink: ::c_long = 4000 + 83; -pub const SYS_unused84: ::c_long = 4000 + 84; pub const SYS_readlink: ::c_long = 4000 + 85; pub const SYS_uselib: ::c_long = 4000 + 86; pub const SYS_swapon: ::c_long = 4000 + 87; @@ -338,7 +333,6 @@ pub const SYS_getitimer: ::c_long = 4000 + 105; pub const SYS_stat: ::c_long = 4000 + 106; pub const SYS_lstat: ::c_long = 4000 + 107; pub const SYS_fstat: ::c_long = 4000 + 108; -pub const SYS_unused109: ::c_long = 4000 + 109; pub const SYS_iopl: ::c_long = 4000 + 110; pub const SYS_vhangup: ::c_long = 4000 + 111; pub const SYS_idle: ::c_long = 4000 + 112; @@ -379,7 +373,6 @@ pub const SYS_writev: ::c_long = 4000 + 146; pub const SYS_cacheflush: ::c_long = 4000 + 147; pub const SYS_cachectl: ::c_long = 4000 + 148; pub const SYS_sysmips: ::c_long = 4000 + 149; -pub const SYS_unused150: ::c_long = 4000 + 150; pub const SYS_getsid: ::c_long = 4000 + 151; pub const SYS_fdatasync: ::c_long = 4000 + 152; pub const SYS__sysctl: ::c_long = 4000 + 153; @@ -450,7 +443,6 @@ pub const SYS_mincore: ::c_long = 4000 + 217; pub const SYS_madvise: ::c_long = 4000 + 218; pub const SYS_getdents64: ::c_long = 4000 + 219; pub const SYS_fcntl64: ::c_long = 4000 + 220; -pub const SYS_reserved221: ::c_long = 4000 + 221; pub const SYS_gettid: ::c_long = 4000 + 222; pub const SYS_readahead: ::c_long = 4000 + 223; pub const SYS_setxattr: ::c_long = 4000 + 224; From 6db4afabfd48f9f11c626983425a472254f42d6e Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 12:37:14 +0200 Subject: [PATCH 22/50] Correct value of some NFT_ constants --- src/unix/notbsd/linux/mips/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/unix/notbsd/linux/mips/mod.rs b/src/unix/notbsd/linux/mips/mod.rs index b7001866eba3a..9ee6d75871804 100644 --- a/src/unix/notbsd/linux/mips/mod.rs +++ b/src/unix/notbsd/linux/mips/mod.rs @@ -706,10 +706,10 @@ pub const GENL_UNS_ADMIN_PERM: ::c_int = 0x10; pub const GENL_ID_VFS_DQUOT: ::c_int = ::NLMSG_MIN_TYPE + 1; pub const GENL_ID_PMCRAID: ::c_int = ::NLMSG_MIN_TYPE + 2; -pub const NFT_TABLE_MAXNAMELEN: ::c_int = 32; -pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 32; -pub const NFT_SET_MAXNAMELEN: ::c_int = 32; -pub const NFT_OBJ_MAXNAMELEN: ::c_int = 32; +pub const NFT_TABLE_MAXNAMELEN: ::c_int = 256; +pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 256; +pub const NFT_SET_MAXNAMELEN: ::c_int = 256; +pub const NFT_OBJ_MAXNAMELEN: ::c_int = 256; pub const NFT_USERDATA_MAXLEN: ::c_int = 256; pub const NFT_REG_VERDICT: ::c_int = 0; From 9212a9cf148ba77e7bd611acb6fceeee5059ac32 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 12:41:25 +0200 Subject: [PATCH 23/50] Update openjdk to version 11 in Docker containers --- ci/docker/aarch64-linux-android/Dockerfile | 2 +- ci/docker/arm-linux-androideabi/Dockerfile | 2 +- ci/docker/i686-linux-android/Dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/docker/aarch64-linux-android/Dockerfile b/ci/docker/aarch64-linux-android/Dockerfile index d8e9ae638e13a..c4a753ca3d60a 100644 --- a/ci/docker/aarch64-linux-android/Dockerfile +++ b/ci/docker/aarch64-linux-android/Dockerfile @@ -9,7 +9,7 @@ RUN dpkg --add-architecture i386 && \ python \ unzip \ expect \ - openjdk-9-jre \ + openjdk-11-jre \ libstdc++6:i386 \ libpulse0 \ gcc \ diff --git a/ci/docker/arm-linux-androideabi/Dockerfile b/ci/docker/arm-linux-androideabi/Dockerfile index 2d9f4dbaa8d2b..02a392150268b 100644 --- a/ci/docker/arm-linux-androideabi/Dockerfile +++ b/ci/docker/arm-linux-androideabi/Dockerfile @@ -9,7 +9,7 @@ RUN dpkg --add-architecture i386 && \ python \ unzip \ expect \ - openjdk-9-jre \ + openjdk-11-jre \ libstdc++6:i386 \ libpulse0 \ gcc \ diff --git a/ci/docker/i686-linux-android/Dockerfile b/ci/docker/i686-linux-android/Dockerfile index e67e6e3e3cdaf..e900006a7e1c6 100644 --- a/ci/docker/i686-linux-android/Dockerfile +++ b/ci/docker/i686-linux-android/Dockerfile @@ -9,7 +9,7 @@ RUN dpkg --add-architecture i386 && \ python \ unzip \ expect \ - openjdk-9-jre \ + openjdk-11-jre \ libstdc++6:i386 \ libpulse0 \ gcc \ From be36f6859bc1b210a409d775e508e9cb6011b33a Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 12:42:37 +0200 Subject: [PATCH 24/50] execinfo not available in emscripten --- libc-test/build.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 9653de8701121..33fb1358e3b9d 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1906,7 +1906,6 @@ fn test_emscripten(target: &str) { "dirent.h", "dlfcn.h", "errno.h", - "execinfo.h", "fcntl.h", "glob.h", "grp.h", From 5d5ceeaf64c7b2ca84db0b9275d04af04ee0b198 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 13:03:00 +0200 Subject: [PATCH 25/50] Correct value of some NFT_ constants on ARM --- src/unix/notbsd/linux/other/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index 8a643768de0c8..6db8d9c382807 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -689,7 +689,7 @@ pub const NFPROTO_NETDEV: ::c_int = 5; // linux/netfilter/nf_tables.h cfg_if!{ - if #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] { + if #[cfg(target_arch = "aarch64")] { pub const NFT_TABLE_MAXNAMELEN: ::c_int = 32; pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 32; pub const NFT_SET_MAXNAMELEN: ::c_int = 32; From 4aa5a45af1a796d6f398b7f984c778bdc666fdbe Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 13:04:41 +0200 Subject: [PATCH 26/50] Correct assert for mips+musl --- libc-test/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 33fb1358e3b9d..25eb8e1f9b09b 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2410,7 +2410,7 @@ fn test_linux(target: &str) { } if !musl || mips { - assert!(gnu || uclibc || (mips && !musl)); + assert!(gnu || uclibc || (mips && musl)); headers! { cfg: "linux/memfd.h" }; } From 4c938e5b4b74e7d7f5b50099bb0af5c21e21caf8 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 13:48:52 +0200 Subject: [PATCH 27/50] Move sparc64 Docker image to Ubuntu --- ci/docker/sparc64-unknown-linux-gnu/Dockerfile | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile index d9edaab426356..f986bade3bb39 100644 --- a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile @@ -1,14 +1,11 @@ -FROM debian:stretch +FROM ubuntu:18.04 RUN apt-get update && apt-get install -y --no-install-recommends \ curl ca-certificates \ gcc libc6-dev \ gcc-sparc64-linux-gnu libc6-dev-sparc64-cross \ qemu-system-sparc64 openbios-sparc seabios ipxe-qemu \ - p7zip-full cpio linux-libc-dev-sparc64-cross linux-headers-4.9.0-3-common - -# Put linux/module.h into the right spot as it is not shipped by debian -RUN cp /usr/src/linux-headers-4.9.0-3-common/include/uapi/linux/module.h /usr/sparc64-linux-gnu/include/linux/ + p7zip-full cpio linux-libc-dev-sparc64-cross COPY linux-sparc64.sh / RUN bash /linux-sparc64.sh From bdb18160708aa85167c71c4a3f643e7a7d484869 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 13:50:55 +0200 Subject: [PATCH 28/50] [breaking change] Remove SYS_syscalls and SYS_arch_specific_syscall from aarch64 --- src/unix/notbsd/linux/other/b64/aarch64.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/unix/notbsd/linux/other/b64/aarch64.rs b/src/unix/notbsd/linux/other/b64/aarch64.rs index d6e37ff57bee5..3bd2e02eebe99 100644 --- a/src/unix/notbsd/linux/other/b64/aarch64.rs +++ b/src/unix/notbsd/linux/other/b64/aarch64.rs @@ -786,7 +786,6 @@ pub const SYS_rt_tgsigqueueinfo: ::c_long = 240; pub const SYS_perf_event_open: ::c_long = 241; pub const SYS_accept4: ::c_long = 242; pub const SYS_recvmmsg: ::c_long = 243; -pub const SYS_arch_specific_syscall: ::c_long = 244; pub const SYS_wait4: ::c_long = 260; pub const SYS_prlimit64: ::c_long = 261; pub const SYS_fanotify_init: ::c_long = 262; @@ -818,7 +817,6 @@ pub const SYS_pwritev2: ::c_long = 287; pub const SYS_pkey_mprotect: ::c_long = 288; pub const SYS_pkey_alloc: ::c_long = 289; pub const SYS_pkey_free: ::c_long = 290; -pub const SYS_syscalls: ::c_long = 291; #[link(name = "util")] extern { From 4a8fa6f1f0ba4f76709d129ffdfd2f2cb85d37cc Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 14:16:59 +0200 Subject: [PATCH 29/50] Correct value of some NFT_ constants on AArch64 --- src/unix/notbsd/linux/other/mod.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index 6db8d9c382807..12dec10d9560f 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -689,12 +689,7 @@ pub const NFPROTO_NETDEV: ::c_int = 5; // linux/netfilter/nf_tables.h cfg_if!{ - if #[cfg(target_arch = "aarch64")] { - pub const NFT_TABLE_MAXNAMELEN: ::c_int = 32; - pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 32; - pub const NFT_SET_MAXNAMELEN: ::c_int = 32; - pub const NFT_OBJ_MAXNAMELEN: ::c_int = 32; - } else if #[cfg(target_arch = "sparc64")] { + if #[cfg(target_arch = "sparc64")] { pub const NFT_TABLE_MAXNAMELEN: ::c_int = 32; pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 32; pub const NFT_SET_MAXNAMELEN: ::c_int = 32; From 24f8972b8d2d915b1687fc8197e1ed95e349a82e Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 14:37:13 +0200 Subject: [PATCH 30/50] [breaking change] remove PTRACE_GET/SET/FP/REGS from s390x --- src/unix/notbsd/linux/s390x/mod.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/unix/notbsd/linux/s390x/mod.rs b/src/unix/notbsd/linux/s390x/mod.rs index ebe9d41710e62..d4cf95678ed0a 100644 --- a/src/unix/notbsd/linux/s390x/mod.rs +++ b/src/unix/notbsd/linux/s390x/mod.rs @@ -782,10 +782,6 @@ pub const PTRACE_POKEUSER: ::c_uint = 6; pub const PTRACE_CONT: ::c_uint = 7; pub const PTRACE_KILL: ::c_uint = 8; pub const PTRACE_SINGLESTEP: ::c_uint = 9; -pub const PTRACE_GETREGS: ::c_uint = 12; -pub const PTRACE_SETREGS: ::c_uint = 13; -pub const PTRACE_GETFPREGS: ::c_uint = 14; -pub const PTRACE_SETFPREGS: ::c_uint = 15; pub const PTRACE_ATTACH: ::c_uint = 16; pub const PTRACE_DETACH: ::c_uint = 17; pub const PTRACE_SYSCALL: ::c_uint = 24; From 2a131d27078c12e13a99f45f2e6f6023097892b4 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 15:59:01 +0200 Subject: [PATCH 31/50] Update alignment of pthread_mutexattr_t --- src/unix/notbsd/linux/align.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/unix/notbsd/linux/align.rs b/src/unix/notbsd/linux/align.rs index a35e26913af7f..0ff4649b8cfcb 100644 --- a/src/unix/notbsd/linux/align.rs +++ b/src/unix/notbsd/linux/align.rs @@ -7,8 +7,7 @@ macro_rules! expand_align { target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64", - all(target_arch = "aarch64", - target_env = "musl")), + target_arch = "aarch64"), repr(align(4)))] #[cfg_attr(not(any(target_pointer_width = "32", target_arch = "x86_64", @@ -16,8 +15,7 @@ macro_rules! expand_align { target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64", - all(target_arch = "aarch64", - target_env = "musl"))), + target_arch = "aarch64")), repr(align(8)))] pub struct pthread_mutexattr_t { #[doc(hidden)] From 57e1e84dce865a465c4e49b2c6eff8289d9a36f7 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 16:24:29 +0200 Subject: [PATCH 32/50] Update Debian image used in sparc64 build job to Debian 10.0 --- ci/linux-sparc64.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ci/linux-sparc64.sh b/ci/linux-sparc64.sh index 7fb28d9e14861..5580a0e3c30ea 100644 --- a/ci/linux-sparc64.sh +++ b/ci/linux-sparc64.sh @@ -5,11 +5,11 @@ set -ex mkdir -m 777 /qemu cd /qemu -curl --retry 5 -LO https://cdimage.debian.org/cdimage/ports/9.0/sparc64/iso-cd/debian-9.0-sparc64-NETINST-1.iso -7z e debian-9.0-sparc64-NETINST-1.iso boot/initrd.gz -7z e debian-9.0-sparc64-NETINST-1.iso boot/sparc64 +curl --retry 5 -LO https://cdimage.debian.org/cdimage/ports/10.0/sparc64/iso-cd/debian-10.0-sparc64-NETINST-1.iso +7z e debian-10.0-sparc64-NETINST-1.iso boot/initrd.gz +7z e debian-10.0-sparc64-NETINST-1.iso boot/sparc64 mv sparc64 kernel -rm debian-9.0-sparc64-NETINST-1.iso +rm debian-10.0-sparc64-NETINST-1.iso mkdir init cd init From 0ae84518fe5edd62b01fe9169ac0f4470ab935ad Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 16:26:15 +0200 Subject: [PATCH 33/50] Update Debian image used in s390x build job --- ci/linux-s390x.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/linux-s390x.sh b/ci/linux-s390x.sh index a230cfe12fb6f..00a7f88180b72 100644 --- a/ci/linux-s390x.sh +++ b/ci/linux-s390x.sh @@ -6,8 +6,8 @@ mkdir -m 777 /qemu cd /qemu curl --retry 5 -LO https://github.com/qemu/qemu/raw/master/pc-bios/s390-ccw.img -curl --retry 5 -LO http://ftp.debian.org/debian/dists/testing/main/installer-s390x/20170828/images/generic/kernel.debian -curl --retry 5 -LO http://ftp.debian.org/debian/dists/testing/main/installer-s390x/20170828/images/generic/initrd.debian +curl --retry 5 -LO http://ftp.debian.org/debian/dists/testing/main/installer-s390x/20190410/images/generic/kernel.debian +curl --retry 5 -LO http://ftp.debian.org/debian/dists/testing/main/installer-s390x/20190410/images/generic/initrd.debian mv kernel.debian kernel mv initrd.debian initrd.gz From 1a7ee21aec68719df281300d77480eab4219e47a Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 16:44:07 +0200 Subject: [PATCH 34/50] Define DEPRECATED_SCANF macro to use older scanf,sscanf,fscanf symbols --- libc-test/build.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 25eb8e1f9b09b..e4cf8eb64acd8 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2257,6 +2257,10 @@ fn test_linux(target: &str) { let mut cfg = ctest::TestGenerator::new(); // FIXME: still necessary? cfg.define("_GNU_SOURCE", None); + // This macro re-deifnes fscanf,scanf,sscanf to link to the symbols that are + // deprecated since glibc >= 2.29. This allows Rust binaries to link against + // glibc versions older than 2.29. + cfg.define("DEPRECATED_SCANF", None); // FIXME: still necessary? cfg.flag("-Wno-deprecated-declarations"); From 9df115b67ff00b0698204e209a027193aa8e2bcb Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 16:46:06 +0200 Subject: [PATCH 35/50] Update Ubuntu images to 19.04 --- ci/docker/aarch64-linux-android/Dockerfile | 2 +- ci/docker/aarch64-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/aarch64-unknown-linux-musl/Dockerfile | 2 +- ci/docker/arm-linux-androideabi/Dockerfile | 2 +- ci/docker/arm-unknown-linux-gnueabihf/Dockerfile | 2 +- ci/docker/arm-unknown-linux-musleabihf/Dockerfile | 2 +- ci/docker/asmjs-unknown-emscripten/Dockerfile | 2 +- ci/docker/i686-linux-android/Dockerfile | 2 +- ci/docker/i686-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/i686-unknown-linux-musl/Dockerfile | 2 +- ci/docker/mips-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/mips-unknown-linux-musl/Dockerfile | 2 +- ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile | 2 +- ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile | 2 +- ci/docker/mipsel-unknown-linux-musl/Dockerfile | 2 +- ci/docker/powerpc-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/powerpc64-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/s390x-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/sparc64-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/wasm32-unknown-emscripten/Dockerfile | 2 +- ci/docker/wasm32-unknown-wasi/Dockerfile | 6 +++--- ci/docker/x86_64-linux-android/Dockerfile | 2 +- ci/docker/x86_64-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/x86_64-unknown-linux-gnux32/Dockerfile | 2 +- ci/docker/x86_64-unknown-linux-musl/Dockerfile | 2 +- libc-test/build.rs | 2 +- 27 files changed, 29 insertions(+), 29 deletions(-) diff --git a/ci/docker/aarch64-linux-android/Dockerfile b/ci/docker/aarch64-linux-android/Dockerfile index c4a753ca3d60a..1458423756759 100644 --- a/ci/docker/aarch64-linux-android/Dockerfile +++ b/ci/docker/aarch64-linux-android/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN dpkg --add-architecture i386 && \ apt-get update && \ diff --git a/ci/docker/aarch64-unknown-linux-gnu/Dockerfile b/ci/docker/aarch64-unknown-linux-gnu/Dockerfile index a137e03e69a79..716a445d346bf 100644 --- a/ci/docker/aarch64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/aarch64-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev ca-certificates \ gcc-aarch64-linux-gnu libc6-dev-arm64-cross qemu-user diff --git a/ci/docker/aarch64-unknown-linux-musl/Dockerfile b/ci/docker/aarch64-unknown-linux-musl/Dockerfile index 1fbf3f43f6315..143a960631ba2 100644 --- a/ci/docker/aarch64-unknown-linux-musl/Dockerfile +++ b/ci/docker/aarch64-unknown-linux-musl/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc make libc6-dev git curl ca-certificates \ diff --git a/ci/docker/arm-linux-androideabi/Dockerfile b/ci/docker/arm-linux-androideabi/Dockerfile index 02a392150268b..acc784e7d595f 100644 --- a/ci/docker/arm-linux-androideabi/Dockerfile +++ b/ci/docker/arm-linux-androideabi/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN dpkg --add-architecture i386 && \ apt-get update && \ diff --git a/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile b/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile index 5a75d29a89006..bcdbb227f25ac 100644 --- a/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile +++ b/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev ca-certificates \ gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user diff --git a/ci/docker/arm-unknown-linux-musleabihf/Dockerfile b/ci/docker/arm-unknown-linux-musleabihf/Dockerfile index 94e1651d63ec2..e29e854cc988b 100644 --- a/ci/docker/arm-unknown-linux-musleabihf/Dockerfile +++ b/ci/docker/arm-unknown-linux-musleabihf/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc make libc6-dev git curl ca-certificates \ diff --git a/ci/docker/asmjs-unknown-emscripten/Dockerfile b/ci/docker/asmjs-unknown-emscripten/Dockerfile index b8fdd1c18a7ef..6c08340eb98b3 100644 --- a/ci/docker/asmjs-unknown-emscripten/Dockerfile +++ b/ci/docker/asmjs-unknown-emscripten/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update && \ apt-get install -y --no-install-recommends \ diff --git a/ci/docker/i686-linux-android/Dockerfile b/ci/docker/i686-linux-android/Dockerfile index e900006a7e1c6..59ea2d79fc31b 100644 --- a/ci/docker/i686-linux-android/Dockerfile +++ b/ci/docker/i686-linux-android/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN dpkg --add-architecture i386 && \ apt-get update && \ diff --git a/ci/docker/i686-unknown-linux-gnu/Dockerfile b/ci/docker/i686-unknown-linux-gnu/Dockerfile index 03f3e8e690e32..5563a7b96b283 100644 --- a/ci/docker/i686-unknown-linux-gnu/Dockerfile +++ b/ci/docker/i686-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update RUN apt-get install -y --no-install-recommends \ gcc-multilib libc6-dev ca-certificates diff --git a/ci/docker/i686-unknown-linux-musl/Dockerfile b/ci/docker/i686-unknown-linux-musl/Dockerfile index dac574fce7d96..c085c10b1427f 100644 --- a/ci/docker/i686-unknown-linux-musl/Dockerfile +++ b/ci/docker/i686-unknown-linux-musl/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN dpkg --add-architecture i386 RUN apt-get update diff --git a/ci/docker/mips-unknown-linux-gnu/Dockerfile b/ci/docker/mips-unknown-linux-gnu/Dockerfile index 72eff78fcb6bd..9f1bcaf7a34d6 100644 --- a/ci/docker/mips-unknown-linux-gnu/Dockerfile +++ b/ci/docker/mips-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ diff --git a/ci/docker/mips-unknown-linux-musl/Dockerfile b/ci/docker/mips-unknown-linux-musl/Dockerfile index 1a87963a594bb..7f2764cf78217 100644 --- a/ci/docker/mips-unknown-linux-musl/Dockerfile +++ b/ci/docker/mips-unknown-linux-musl/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates qemu-system-mips curl \ diff --git a/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile b/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile index 246a9bf684d24..b97cdb4ce47e7 100644 --- a/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile +++ b/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ diff --git a/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile b/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile index 8b2f9f727a303..7f794525d9197 100644 --- a/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile +++ b/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ diff --git a/ci/docker/mipsel-unknown-linux-musl/Dockerfile b/ci/docker/mipsel-unknown-linux-musl/Dockerfile index 8fabf89ceba0c..03e83578ea90c 100644 --- a/ci/docker/mipsel-unknown-linux-musl/Dockerfile +++ b/ci/docker/mipsel-unknown-linux-musl/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates qemu-system-mips curl \ diff --git a/ci/docker/powerpc-unknown-linux-gnu/Dockerfile b/ci/docker/powerpc-unknown-linux-gnu/Dockerfile index 5630685b56b87..9fa05af12ed99 100644 --- a/ci/docker/powerpc-unknown-linux-gnu/Dockerfile +++ b/ci/docker/powerpc-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ diff --git a/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile b/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile index e4798538ae1ed..ab40789755749 100644 --- a/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ diff --git a/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile b/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile index 2afd41e825e4b..4dcd632edde38 100644 --- a/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile +++ b/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ diff --git a/ci/docker/s390x-unknown-linux-gnu/Dockerfile b/ci/docker/s390x-unknown-linux-gnu/Dockerfile index 0f58b76e2439f..75c11c11dca8d 100644 --- a/ci/docker/s390x-unknown-linux-gnu/Dockerfile +++ b/ci/docker/s390x-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update && apt-get install -y --no-install-recommends \ curl ca-certificates \ diff --git a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile index f986bade3bb39..d1f4503d52d5a 100644 --- a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update && apt-get install -y --no-install-recommends \ curl ca-certificates \ diff --git a/ci/docker/wasm32-unknown-emscripten/Dockerfile b/ci/docker/wasm32-unknown-emscripten/Dockerfile index 1062717c4d8e8..de8e35353b8e0 100644 --- a/ci/docker/wasm32-unknown-emscripten/Dockerfile +++ b/ci/docker/wasm32-unknown-emscripten/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update && \ apt-get install -y --no-install-recommends \ diff --git a/ci/docker/wasm32-unknown-wasi/Dockerfile b/ci/docker/wasm32-unknown-wasi/Dockerfile index deac87a69305e..8c6e2f3756c5a 100644 --- a/ci/docker/wasm32-unknown-wasi/Dockerfile +++ b/ci/docker/wasm32-unknown-wasi/Dockerfile @@ -1,7 +1,7 @@ # In the first container we want to assemble the `wasi-sysroot` by compiling it # from source. This requires a clang 8.0+ compiler with enough wasm support and # then we're just running a standard `make` inside of what we clone. -FROM ubuntu:18.04 as wasi-sysroot +FROM ubuntu:19.04 as wasi-sysroot RUN apt-get update && \ apt-get install -y --no-install-recommends \ @@ -40,7 +40,7 @@ COPY docker/wasm32-unknown-wasi/clang.sh /wasi-sysroot/bin/clang # used to execute wasi executables. This is a standard Rust project so we're # just checking out a known revision (which pairs with the sysroot one we # downlaoded above) and then we're building it with Cargo -FROM ubuntu:18.04 as wasmtime +FROM ubuntu:19.04 as wasmtime RUN apt-get update && \ apt-get install -y --no-install-recommends \ @@ -66,7 +66,7 @@ RUN cargo build --release --manifest-path wasmtime/Cargo.toml # And finally in the last image we're going to assemble everything together. # We'll install things needed at runtime for now and then copy over the # sysroot/wasmtime artifacts into their final location. -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update && \ apt-get install -y --no-install-recommends \ diff --git a/ci/docker/x86_64-linux-android/Dockerfile b/ci/docker/x86_64-linux-android/Dockerfile index 62e61b1e31eba..b0984c04585d8 100644 --- a/ci/docker/x86_64-linux-android/Dockerfile +++ b/ci/docker/x86_64-linux-android/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update && \ apt-get install -y --no-install-recommends \ diff --git a/ci/docker/x86_64-unknown-linux-gnu/Dockerfile b/ci/docker/x86_64-unknown-linux-gnu/Dockerfile index 6ab9c9231955a..0dbb191fbd940 100644 --- a/ci/docker/x86_64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update RUN apt-get install -y --no-install-recommends \ gcc libc6-dev ca-certificates diff --git a/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile b/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile index 03f3e8e690e32..5563a7b96b283 100644 --- a/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update RUN apt-get install -y --no-install-recommends \ gcc-multilib libc6-dev ca-certificates diff --git a/ci/docker/x86_64-unknown-linux-musl/Dockerfile b/ci/docker/x86_64-unknown-linux-musl/Dockerfile index d8036dc98ce45..59164d22ed641 100644 --- a/ci/docker/x86_64-unknown-linux-musl/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-musl/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:19.04 RUN apt-get update RUN apt-get install -y --no-install-recommends \ diff --git a/libc-test/build.rs b/libc-test/build.rs index e4cf8eb64acd8..696b60be94ea4 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2260,7 +2260,7 @@ fn test_linux(target: &str) { // This macro re-deifnes fscanf,scanf,sscanf to link to the symbols that are // deprecated since glibc >= 2.29. This allows Rust binaries to link against // glibc versions older than 2.29. - cfg.define("DEPRECATED_SCANF", None); + cfg.define("__GLIBC_USE_DEPRECATED_SCANF", None); // FIXME: still necessary? cfg.flag("-Wno-deprecated-declarations"); From e94f68c7d6196ac206f58dfa07fbf2a8a2db7e85 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 18:01:29 +0200 Subject: [PATCH 36/50] Link against correct scanf,fscanf,sscanf --- src/unix/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index cfd2246b44010..840769615dd1e 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -512,8 +512,11 @@ extern { pub fn snprintf(s: *mut ::c_char, n: ::size_t, format: *const ::c_char, ...) -> ::c_int; pub fn sprintf(s: *mut ::c_char, format: *const ::c_char, ...) -> ::c_int; + #[cfg_attr(target_os = "linux", link_name = "__isoc99_fscanf")] pub fn fscanf(stream: *mut ::FILE, format: *const ::c_char, ...) -> ::c_int; + #[cfg_attr(target_os = "linux", link_name = "__isoc99_scanf")] pub fn scanf(format: *const ::c_char, ...) -> ::c_int; + #[cfg_attr(target_os = "linux", link_name = "__isoc99_sscanf")] pub fn sscanf(s: *const ::c_char, format: *const ::c_char, ...) -> ::c_int; pub fn getchar_unlocked() -> ::c_int; pub fn putchar_unlocked(c: ::c_int) -> ::c_int; From 4497a7867d56ef61194e4cbb63ef4c4fe146e4c6 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 19:20:39 +0200 Subject: [PATCH 37/50] Fix ucontext_t and NFT_MSG_MAX on x86_64 --- src/unix/notbsd/linux/other/b64/x86_64.rs | 1 + src/unix/notbsd/linux/other/mod.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unix/notbsd/linux/other/b64/x86_64.rs b/src/unix/notbsd/linux/other/b64/x86_64.rs index d4f4ffc4da399..79f27e083f2d6 100644 --- a/src/unix/notbsd/linux/other/b64/x86_64.rs +++ b/src/unix/notbsd/linux/other/b64/x86_64.rs @@ -231,6 +231,7 @@ s_no_extra_traits! { pub uc_mcontext: mcontext_t, pub uc_sigmask: ::sigset_t, __private: [u8; 512], + __ssp: [::c_ulonglong; 4], } } diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index 12dec10d9560f..45b9cafb91178 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -758,7 +758,7 @@ cfg_if! { pub const NFT_MSG_GETOBJ: ::c_int = 19; pub const NFT_MSG_DELOBJ: ::c_int = 20; pub const NFT_MSG_GETOBJ_RESET: ::c_int = 21; - pub const NFT_MSG_MAX: ::c_int = 22; + pub const NFT_MSG_MAX: ::c_int = 25; } else { pub const NFT_MSG_MAX: ::c_int = 18; } From d80812372844ae34bb3302ed2c02fe0968c478ac Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 19:47:33 +0200 Subject: [PATCH 38/50] Fix ucontext_t on x86 --- src/unix/notbsd/linux/other/b32/x86.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/notbsd/linux/other/b32/x86.rs b/src/unix/notbsd/linux/other/b32/x86.rs index 563ac98ac3335..9080d17b3e6b5 100644 --- a/src/unix/notbsd/linux/other/b32/x86.rs +++ b/src/unix/notbsd/linux/other/b32/x86.rs @@ -212,6 +212,7 @@ s_no_extra_traits!{ pub uc_mcontext: mcontext_t, pub uc_sigmask: ::sigset_t, __private: [u8; 112], + __ssp: [::c_ulonglong; 4], } } From e7f62bc76aae83ce42a3c5308d65d9583b61d308 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 19:49:44 +0200 Subject: [PATCH 39/50] Fix utmpx.ut_session type on sparc64 --- src/unix/notbsd/linux/mips/mod.rs | 2 +- src/unix/notbsd/linux/other/mod.rs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/unix/notbsd/linux/mips/mod.rs b/src/unix/notbsd/linux/mips/mod.rs index 9ee6d75871804..35534b44d2ffd 100644 --- a/src/unix/notbsd/linux/mips/mod.rs +++ b/src/unix/notbsd/linux/mips/mod.rs @@ -766,7 +766,7 @@ pub const NFT_MSG_NEWOBJ: ::c_int = 18; pub const NFT_MSG_GETOBJ: ::c_int = 19; pub const NFT_MSG_DELOBJ: ::c_int = 20; pub const NFT_MSG_GETOBJ_RESET: ::c_int = 21; -pub const NFT_MSG_MAX: ::c_int = 22; +pub const NFT_MSG_MAX: ::c_int = 25; pub const NFT_SET_ANONYMOUS: ::c_int = 0x1; pub const NFT_SET_CONSTANT: ::c_int = 0x2; diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index 45b9cafb91178..27f1638290942 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -225,7 +225,6 @@ s_no_extra_traits! { pub ut_exit: __exit_status, #[cfg(any(target_arch = "aarch64", - target_arch = "sparc64", all(target_pointer_width = "32", not(target_arch = "x86_64"))))] pub ut_session: ::c_long, @@ -236,7 +235,6 @@ s_no_extra_traits! { pub ut_tv: ::timeval, #[cfg(not(any(target_arch = "aarch64", - target_arch = "sparc64", all(target_pointer_width = "32", not(target_arch = "x86_64")))))] pub ut_session: ::int32_t, From 3ac111c8d0f1ef467aa443b67ff4fd64376d80ec Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 19:55:16 +0200 Subject: [PATCH 40/50] Try to fix builds of the Android SDK --- ci/android-install-sdk.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci/android-install-sdk.sh b/ci/android-install-sdk.sh index 64cfbf1170770..e011cfc34bb4c 100644 --- a/ci/android-install-sdk.sh +++ b/ci/android-install-sdk.sh @@ -45,6 +45,9 @@ case "$1" in ;; esac; +# See: https://stackoverflow.com/a/51644855/1422197 +export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee' + # --no_https avoids # javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found yes | ./sdk/tools/bin/sdkmanager --licenses --no_https From 198ead7247fce8ffb6bdfeb1931ec85285a339ec Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 20:18:50 +0200 Subject: [PATCH 41/50] ucontext_t ssp field uses c_long and not c_longlog --- src/unix/notbsd/linux/other/b32/x86.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/notbsd/linux/other/b32/x86.rs b/src/unix/notbsd/linux/other/b32/x86.rs index 9080d17b3e6b5..e7c3b9a83adc9 100644 --- a/src/unix/notbsd/linux/other/b32/x86.rs +++ b/src/unix/notbsd/linux/other/b32/x86.rs @@ -212,7 +212,7 @@ s_no_extra_traits!{ pub uc_mcontext: mcontext_t, pub uc_sigmask: ::sigset_t, __private: [u8; 112], - __ssp: [::c_ulonglong; 4], + __ssp: [::c_ulong; 4], } } From 58091dfb5d1afc57367e1ef0d9a10a53bf408172 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 22:14:11 +0200 Subject: [PATCH 42/50] Fix FLUSHO value on Sparc64 --- src/unix/notbsd/linux/other/b64/sparc64.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/notbsd/linux/other/b64/sparc64.rs b/src/unix/notbsd/linux/other/b64/sparc64.rs index 325c7937fc8a4..5d268658cc155 100644 --- a/src/unix/notbsd/linux/other/b64/sparc64.rs +++ b/src/unix/notbsd/linux/other/b64/sparc64.rs @@ -495,7 +495,7 @@ pub const VEOL2: usize = 6; pub const VMIN: usize = 4; pub const IEXTEN: ::tcflag_t = 0x8000; pub const TOSTOP: ::tcflag_t = 0x100; -pub const FLUSHO: ::tcflag_t = 0x2000; +pub const FLUSHO: ::tcflag_t = 0x1000; pub const EXTPROC: ::tcflag_t = 0x10000; pub const TCGETS: ::c_ulong = 0x40245408; pub const TCSETS: ::c_ulong = 0x80245409; From b701d5c33ab55d43842cc7a1ac1df25d530866e4 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 22:15:34 +0200 Subject: [PATCH 43/50] Fix NFT tables on Sparc64 --- src/unix/notbsd/linux/other/mod.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index 27f1638290942..02f73bbc47bea 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -686,18 +686,10 @@ pub const NFPROTO_INET: ::c_int = 1; pub const NFPROTO_NETDEV: ::c_int = 5; // linux/netfilter/nf_tables.h -cfg_if!{ - if #[cfg(target_arch = "sparc64")] { - pub const NFT_TABLE_MAXNAMELEN: ::c_int = 32; - pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 32; - pub const NFT_SET_MAXNAMELEN: ::c_int = 32; - } else { - pub const NFT_TABLE_MAXNAMELEN: ::c_int = 256; - pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 256; - pub const NFT_SET_MAXNAMELEN: ::c_int = 256; - pub const NFT_OBJ_MAXNAMELEN: ::c_int = 256; - } -} +pub const NFT_TABLE_MAXNAMELEN: ::c_int = 256; +pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 256; +pub const NFT_SET_MAXNAMELEN: ::c_int = 256; +pub const NFT_OBJ_MAXNAMELEN: ::c_int = 256; pub const NFT_USERDATA_MAXLEN: ::c_int = 256; pub const NFT_REG_VERDICT: ::c_int = 0; From 7ed51c1c8b8774cc6bd2fce11833ed371e5dddce Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 22:17:40 +0200 Subject: [PATCH 44/50] Fix NFT_MSG_MAX on Sparc64 --- src/unix/notbsd/linux/other/mod.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index 02f73bbc47bea..ee652b1af53f0 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -748,11 +748,9 @@ cfg_if! { pub const NFT_MSG_GETOBJ: ::c_int = 19; pub const NFT_MSG_DELOBJ: ::c_int = 20; pub const NFT_MSG_GETOBJ_RESET: ::c_int = 21; - pub const NFT_MSG_MAX: ::c_int = 25; - } else { - pub const NFT_MSG_MAX: ::c_int = 18; } } +pub const NFT_MSG_MAX: ::c_int = 25; pub const NFT_SET_ANONYMOUS: ::c_int = 0x1; pub const NFT_SET_CONSTANT: ::c_int = 0x2; From e07c7bdc17ca727c4bd519743d777ca121893f59 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 15 May 2019 22:19:55 +0200 Subject: [PATCH 45/50] Fix utmpx on Sparc64 --- src/unix/notbsd/linux/other/mod.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index ee652b1af53f0..1a97d1c8d6df2 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -229,7 +229,6 @@ s_no_extra_traits! { not(target_arch = "x86_64"))))] pub ut_session: ::c_long, #[cfg(any(target_arch = "aarch64", - target_arch = "sparc64", all(target_pointer_width = "32", not(target_arch = "x86_64"))))] pub ut_tv: ::timeval, @@ -239,7 +238,6 @@ s_no_extra_traits! { not(target_arch = "x86_64")))))] pub ut_session: ::int32_t, #[cfg(not(any(target_arch = "aarch64", - target_arch = "sparc64", all(target_pointer_width = "32", not(target_arch = "x86_64")))))] pub ut_tv: __timeval, From 3ac67ebcf7289b6088db35dd1c508a3afe25dcfc Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 16 May 2019 09:25:10 +0200 Subject: [PATCH 46/50] Rename wasm32-unknown-wasi to wasm32-wasi --- .travis.yml | 2 +- ci/docker/wasm32-unknown-wasi/clang.sh | 2 -- .../Dockerfile | 20 +++++++++---------- ci/docker/wasm32-wasi/clang.sh | 2 ++ 4 files changed, 13 insertions(+), 13 deletions(-) delete mode 100755 ci/docker/wasm32-unknown-wasi/clang.sh rename ci/docker/{wasm32-unknown-wasi => wasm32-wasi}/Dockerfile (85%) create mode 100755 ci/docker/wasm32-wasi/clang.sh diff --git a/.travis.yml b/.travis.yml index 7175ae4aad836..ad8df0763713e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -204,7 +204,7 @@ matrix: stage: tier2 - env: TARGET=x86_64-unknown-linux-musl stage: tier2 - - env: TARGET=wasm32-unknown-wasi + - env: TARGET=wasm32-wasi rust: nightly stage: tier2 diff --git a/ci/docker/wasm32-unknown-wasi/clang.sh b/ci/docker/wasm32-unknown-wasi/clang.sh deleted file mode 100755 index a943e3782334e..0000000000000 --- a/ci/docker/wasm32-unknown-wasi/clang.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env sh -exec /wasmcc/bin/clang --target=wasm32-unknown-wasi --sysroot /wasi-sysroot "$@" diff --git a/ci/docker/wasm32-unknown-wasi/Dockerfile b/ci/docker/wasm32-wasi/Dockerfile similarity index 85% rename from ci/docker/wasm32-unknown-wasi/Dockerfile rename to ci/docker/wasm32-wasi/Dockerfile index 8c6e2f3756c5a..d963a442c86bb 100644 --- a/ci/docker/wasm32-unknown-wasi/Dockerfile +++ b/ci/docker/wasm32-wasi/Dockerfile @@ -1,7 +1,7 @@ # In the first container we want to assemble the `wasi-sysroot` by compiling it # from source. This requires a clang 8.0+ compiler with enough wasm support and # then we're just running a standard `make` inside of what we clone. -FROM ubuntu:19.04 as wasi-sysroot +FROM ubuntu:18.04 as wasi-sysroot RUN apt-get update && \ apt-get install -y --no-install-recommends \ @@ -28,19 +28,19 @@ RUN mv /clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04 /wasmcc # those breaking changes on `libc`'s own CI RUN git clone https://github.com/CraneStation/wasi-sysroot && \ cd wasi-sysroot && \ - git reset --hard 2201343c17b7149a75f543f523bea0c3243c6091 + git reset --hard eee6ee7566e26f2535eb6088c8494a112ff423b9 RUN make -C wasi-sysroot install -j $(nproc) WASM_CC=/wasmcc/bin/clang INSTALL_DIR=/wasi-sysroot # This is a small wrapper script which executes the actual clang binary in # `/wasmcc` and then is sure to pass the right `--sysroot` argument which we # just built above. -COPY docker/wasm32-unknown-wasi/clang.sh /wasi-sysroot/bin/clang +COPY docker/wasm32-wasi/clang.sh /wasi-sysroot/bin/clang # In the second container we're going to build the `wasmtime` binary which is # used to execute wasi executables. This is a standard Rust project so we're # just checking out a known revision (which pairs with the sysroot one we # downlaoded above) and then we're building it with Cargo -FROM ubuntu:19.04 as wasmtime +FROM ubuntu:18.04 as wasmtime RUN apt-get update && \ apt-get install -y --no-install-recommends \ @@ -58,15 +58,15 @@ RUN curl -sSf https://sh.rustup.rs | sh -s -- -y ENV PATH=/root/.cargo/bin:$PATH RUN apt-get install -y --no-install-recommends python -RUN git clone https://github.com/CraneStation/wasmtime wasmtime && \ +RUN git clone --recursive https://github.com/CraneStation/wasmtime wasmtime && \ cd wasmtime && \ - git reset --hard a1c123c3dd8f9766990efe0f1734a646f61ba8a0 + git reset --hard 67edb00f29b62864b00179fe4bfa99bc29973285 RUN cargo build --release --manifest-path wasmtime/Cargo.toml # And finally in the last image we're going to assemble everything together. # We'll install things needed at runtime for now and then copy over the # sysroot/wasmtime artifacts into their final location. -FROM ubuntu:19.04 +FROM ubuntu:18.04 RUN apt-get update && \ apt-get install -y --no-install-recommends \ @@ -86,8 +86,8 @@ COPY --from=wasmtime /wasmtime/target/release/wasmtime /usr/bin/ # executable with the right sysroot, and then we're sure to turn off the # crt-static feature to ensure that the CRT that we're specifying with `clang` # is used. -ENV CARGO_TARGET_WASM32_UNKNOWN_WASI_RUNNER=wasmtime \ - CARGO_TARGET_WASM32_UNKNOWN_WASI_LINKER=/wasi-sysroot/bin/clang \ - CC_wasm32_unknown_wasi=/wasi-sysroot/bin/clang \ +ENV CARGO_TARGET_WASM32_WASI_RUNNER=wasmtime \ + CARGO_TARGET_WASM32_WASI_LINKER=/wasi-sysroot/bin/clang \ + CC_wasm32_wasi=/wasi-sysroot/bin/clang \ PATH=$PATH:/rust/bin \ RUSTFLAGS=-Ctarget-feature=-crt-static diff --git a/ci/docker/wasm32-wasi/clang.sh b/ci/docker/wasm32-wasi/clang.sh new file mode 100755 index 0000000000000..6f298128ab8c3 --- /dev/null +++ b/ci/docker/wasm32-wasi/clang.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +exec /wasmcc/bin/clang --target=wasm32-wasi --sysroot /wasi-sysroot "$@" From 9183c00f7e01d6d3474ddd3eb7f1406cb1a0a577 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 16 May 2019 09:17:26 +0200 Subject: [PATCH 47/50] Remove unecessarily disabling a warning on FreeBSD --- libc-test/build.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 696b60be94ea4..4ff6b3a503f38 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1572,12 +1572,9 @@ fn test_freebsd(target: &str) { let x86 = target.contains("i686") || target.contains("x86_64"); let mut cfg = ctest::TestGenerator::new(); - // FIXME: still necessary? + // Required for `getline`: cfg.define("_WITH_GETLINE", None); - // FIXME: still necessary? - cfg.flag("-Wno-deprecated-declarations"); - headers! { cfg: "aio.h", "arpa/inet.h", From 77a4683aa1bceafb54c5a34c628f26fd746cb47f Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 16 May 2019 09:55:07 +0200 Subject: [PATCH 48/50] Remove bitrig support See https://github.com/rust-lang/rust/pull/60775 . --- ci/build.sh | 1 - src/unix/bsd/mod.rs | 3 +- src/unix/bsd/netbsdlike/mod.rs | 2 +- .../bsd/netbsdlike/openbsdlike/bitrig/mod.rs | 129 ------------------ .../bsd/netbsdlike/openbsdlike/bitrig/x86.rs | 2 - .../netbsdlike/openbsdlike/bitrig/x86_64.rs | 10 -- src/unix/bsd/netbsdlike/openbsdlike/mod.rs | 3 - src/unix/mod.rs | 6 +- 8 files changed, 4 insertions(+), 152 deletions(-) delete mode 100644 src/unix/bsd/netbsdlike/openbsdlike/bitrig/mod.rs delete mode 100644 src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86.rs delete mode 100644 src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs diff --git a/ci/build.sh b/ci/build.sh index 8bfc77136ac6e..6e6096603f2d2 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -199,7 +199,6 @@ thumbv7neon-linux-androideabi \ thumbv7neon-unknown-linux-gnueabihf \ thumbv8m.main-none-eabi \ x86_64-pc-windows-msvc -x86_64-unknown-bitrig \ x86_64-unknown-dragonfly \ x86_64-unknown-haiku \ x86_64-unknown-hermit \ diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 162be9d7f904c..03c987dd33741 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -663,8 +663,7 @@ cfg_if! { if #[cfg(any(target_os = "macos", target_os = "ios"))] { mod apple; pub use self::apple::*; - } else if #[cfg(any(target_os = "openbsd", target_os = "netbsd", - target_os = "bitrig"))] { + } else if #[cfg(any(target_os = "openbsd", target_os = "netbsd"))] { mod netbsdlike; pub use self::netbsdlike::*; } else if #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] { diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index c75e6de0a3e16..29b4dd7649891 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -676,7 +676,7 @@ cfg_if! { if #[cfg(target_os = "netbsd")] { mod netbsd; pub use self::netbsd::*; - } else if #[cfg(any(target_os = "openbsd", target_os = "bitrig"))] { + } else if #[cfg(target_os = "openbsd")] { mod openbsdlike; pub use self::openbsdlike::*; } else { diff --git a/src/unix/bsd/netbsdlike/openbsdlike/bitrig/mod.rs b/src/unix/bsd/netbsdlike/openbsdlike/bitrig/mod.rs deleted file mode 100644 index f73d7de7b2f04..0000000000000 --- a/src/unix/bsd/netbsdlike/openbsdlike/bitrig/mod.rs +++ /dev/null @@ -1,129 +0,0 @@ -pub type c_char = i8; - -s! { - pub struct glob_t { - pub gl_pathc: ::c_int, - pub gl_matchc: ::c_int, - pub gl_offs: ::c_int, - pub gl_flags: ::c_int, - pub gl_pathv: *mut *mut ::c_char, - __unused1: *mut ::c_void, - __unused2: *mut ::c_void, - __unused3: *mut ::c_void, - __unused4: *mut ::c_void, - __unused5: *mut ::c_void, - __unused6: *mut ::c_void, - __unused7: *mut ::c_void, - } - - pub struct lconv { - pub decimal_point: *mut ::c_char, - pub thousands_sep: *mut ::c_char, - pub grouping: *mut ::c_char, - pub int_curr_symbol: *mut ::c_char, - pub currency_symbol: *mut ::c_char, - pub mon_decimal_point: *mut ::c_char, - pub mon_thousands_sep: *mut ::c_char, - pub mon_grouping: *mut ::c_char, - pub positive_sign: *mut ::c_char, - pub negative_sign: *mut ::c_char, - pub int_frac_digits: ::c_char, - pub frac_digits: ::c_char, - pub p_cs_precedes: ::c_char, - pub p_sep_by_space: ::c_char, - pub n_cs_precedes: ::c_char, - pub n_sep_by_space: ::c_char, - pub p_sign_posn: ::c_char, - pub n_sign_posn: ::c_char, - pub int_p_cs_precedes: ::c_char, - pub int_n_cs_precedes: ::c_char, - pub int_p_sep_by_space: ::c_char, - pub int_n_sep_by_space: ::c_char, - pub int_p_sign_posn: ::c_char, - pub int_n_sign_posn: ::c_char, - } -} - -pub const LC_COLLATE_MASK: ::c_int = (1 << 0); -pub const LC_CTYPE_MASK: ::c_int = (1 << 1); -pub const LC_MESSAGES_MASK: ::c_int = (1 << 2); -pub const LC_MONETARY_MASK: ::c_int = (1 << 3); -pub const LC_NUMERIC_MASK: ::c_int = (1 << 4); -pub const LC_TIME_MASK: ::c_int = (1 << 5); -pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK - | LC_CTYPE_MASK - | LC_MESSAGES_MASK - | LC_MONETARY_MASK - | LC_NUMERIC_MASK - | LC_TIME_MASK; - -pub const ERA: ::nl_item = 52; -pub const ERA_D_FMT: ::nl_item = 53; -pub const ERA_D_T_FMT: ::nl_item = 54; -pub const ERA_T_FMT: ::nl_item = 55; -pub const ALT_DIGITS: ::nl_item = 56; - -pub const D_MD_ORDER: ::nl_item = 57; - -pub const ALTMON_1: ::nl_item = 58; -pub const ALTMON_2: ::nl_item = 59; -pub const ALTMON_3: ::nl_item = 60; -pub const ALTMON_4: ::nl_item = 61; -pub const ALTMON_5: ::nl_item = 62; -pub const ALTMON_6: ::nl_item = 63; -pub const ALTMON_7: ::nl_item = 64; -pub const ALTMON_8: ::nl_item = 65; -pub const ALTMON_9: ::nl_item = 66; -pub const ALTMON_10: ::nl_item = 67; -pub const ALTMON_11: ::nl_item = 68; -pub const ALTMON_12: ::nl_item = 69; - -pub const KERN_RND: ::c_int = 31; - -// https://github.com/bitrig/bitrig/blob/master/sys/net/if.h#L187 -pub const IFF_UP: ::c_int = 0x1; // interface is up -pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid -pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging -pub const IFF_LOOPBACK: ::c_int = 0x8; // is a loopback net -pub const IFF_POINTOPOINT: ::c_int = 0x10; // interface is point-to-point link -pub const IFF_NOTRAILERS: ::c_int = 0x20; // avoid use of trailers -pub const IFF_RUNNING: ::c_int = 0x40; // resources allocated -pub const IFF_NOARP: ::c_int = 0x80; // no address resolution protocol -pub const IFF_PROMISC: ::c_int = 0x100; // receive all packets -pub const IFF_ALLMULTI: ::c_int = 0x200; // receive all multicast packets -pub const IFF_OACTIVE: ::c_int = 0x400; // transmission in progress -pub const IFF_SIMPLEX: ::c_int = 0x800; // can't hear own transmissions -pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit -pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit -pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit -pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast - -pub const PTHREAD_STACK_MIN : ::size_t = 2048; -pub const SIGSTKSZ : ::size_t = 40960; - -pub const PT_FIRSTMACH: ::c_int = 32; - -extern { - pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char; - pub fn duplocale(base: ::locale_t) -> ::locale_t; - pub fn freelocale(loc: ::locale_t) -> ::c_int; - pub fn newlocale(mask: ::c_int, - locale: *const ::c_char, - base: ::locale_t) -> ::locale_t; - pub fn uselocale(loc: ::locale_t) -> ::locale_t; - pub fn pledge(promises: *const ::c_char, - paths: *mut *const ::c_char) -> ::c_int; - pub fn querylocale(mask: ::c_int, loc: ::locale_t) -> *const ::c_char; -} - -cfg_if! { - if #[cfg(target_arch = "x86")] { - mod x86; - pub use self::x86::*; - } else if #[cfg(target_arch = "x86_64")] { - mod x86_64; - pub use self::x86_64::*; - } else { - // Unknown target_arch - } -} diff --git a/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86.rs b/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86.rs deleted file mode 100644 index 9b0b338b91e5b..0000000000000 --- a/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub type c_long = i32; -pub type c_ulong = u32; diff --git a/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs b/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs deleted file mode 100644 index d3971aa35b87b..0000000000000 --- a/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs +++ /dev/null @@ -1,10 +0,0 @@ -use PT_FIRSTMACH; - -pub type c_long = i64; -pub type c_ulong = u64; - -pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0; -pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; -pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2; -pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 3; -pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 4; diff --git a/src/unix/bsd/netbsdlike/openbsdlike/mod.rs b/src/unix/bsd/netbsdlike/openbsdlike/mod.rs index cf9dc8f5517b1..223064b76eea4 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/mod.rs @@ -939,9 +939,6 @@ cfg_if! { if #[cfg(target_os = "openbsd")] { mod openbsd; pub use self::openbsd::*; - } else if #[cfg(target_os = "bitrig")] { - mod bitrig; - pub use self::bitrig::*; } else { // Unknown target_os } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 840769615dd1e..375acabbc35fa 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -327,8 +327,7 @@ cfg_if! { } else if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "android", - target_os = "openbsd", - target_os = "bitrig"))] { + target_os = "openbsd"))] { #[link(name = "c")] #[link(name = "m")] extern {} @@ -1158,8 +1157,7 @@ cfg_if! { target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", - target_os = "netbsd", - target_os = "bitrig"))] { + target_os = "netbsd"))] { mod bsd; pub use self::bsd::*; } else if #[cfg(any(target_os = "solaris", From 5a0e37ec376c4583b34d419eaa7676d7ee29f1ff Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 16 May 2019 09:56:07 +0200 Subject: [PATCH 49/50] Add wasm32-wasi to ci/build.sh --- ci/build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/build.sh b/ci/build.sh index 6e6096603f2d2..eb07c182ead6d 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -115,6 +115,7 @@ aarch64-fuchsia \ armv5te-unknown-linux-gnueabi \ armv5te-unknown-linux-musleabi \ i686-pc-windows-gnu \ +wasm32-wasi \ x86_64-fortanix-unknown-sgx \ x86_64-fuchsia \ x86_64-pc-windows-gnu \ From 8eceb62a3e200c42ea2d6bbc4be93a1c2227b37e Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 16 May 2019 11:01:05 +0200 Subject: [PATCH 50/50] Rename _wasi_rmfileat to _wasi_unlinkat --- src/wasi.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wasi.rs b/src/wasi.rs index a014e4c0fa330..345c85adb5042 100644 --- a/src/wasi.rs +++ b/src/wasi.rs @@ -1025,7 +1025,7 @@ extern { path: *const c_char, ) -> c_int; pub fn __wasilibc_fd_renumber(fd: c_int, newfd: c_int) -> c_int; - pub fn __wasilibc_rmfileat(fd: c_int, path: *const c_char) -> c_int; + pub fn __wasilibc_unlinkat(fd: c_int, path: *const c_char) -> c_int; pub fn __wasilibc_rmdirat(fd: c_int, path: *const c_char) -> c_int; pub fn __wasilibc_init_preopen(); pub fn __wasilibc_find_relpath(