Cleanup DragonflyBSD in libc-test/build.rs

This commit is contained in:
gnzlbg 2019-02-24 15:13:47 +01:00
parent 87f10ab9ee
commit 70e0c4e877
1 changed files with 224 additions and 18 deletions

View File

@ -24,10 +24,9 @@ fn do_ctest() {
let musl = target.contains("musl") || emscripten;
let uclibc = target.contains("uclibc");
let freebsd = target.contains("freebsd");
let dragonfly = target.contains("dragonfly");
let mips = target.contains("mips");
let openbsd = target.contains("openbsd");
let bsdlike = freebsd || openbsd || dragonfly;
let bsdlike = freebsd || openbsd;
let mut cfg = ctest::TestGenerator::new();
match &target {
@ -37,6 +36,7 @@ fn do_ctest() {
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),
_ => (),
}
@ -132,7 +132,7 @@ fn do_ctest() {
cfg.header("ifaddrs.h");
cfg.header("langinfo.h");
if !openbsd && !freebsd && !dragonfly {
if !openbsd && !freebsd {
cfg.header("sys/quota.h");
}
@ -277,14 +277,7 @@ fn do_ctest() {
cfg.header("sys/syscall.h");
}
if dragonfly {
cfg.header("mqueue.h");
cfg.header("ufs/ufs/quota.h");
cfg.header("pthread_np.h");
cfg.header("sys/rtprio.h");
}
if linux || freebsd || dragonfly || emscripten {
if linux || freebsd || emscripten {
if !uclibc {
cfg.header("aio.h");
}
@ -332,7 +325,7 @@ fn do_ctest() {
}
"u64" if struct_ == "epoll_event" => "data.u64".to_string(),
"type_"
if (linux || freebsd || dragonfly)
if (linux || freebsd)
&& (struct_ == "input_event"
|| struct_ == "input_mask"
|| struct_ == "ff_effect"
@ -385,13 +378,11 @@ fn do_ctest() {
cfg.skip_signededness(move |c| {
match c {
"LARGE_INTEGER" | "float" | "double" => true,
// uuid_t is a struct, not an integer.
"uuid_t" if dragonfly => true,
n if n.starts_with("pthread") => true,
// sem_t is a struct or pointer
"sem_t" if openbsd || freebsd || dragonfly => true,
// mqd_t is a pointer on FreeBSD and DragonFly
"mqd_t" if freebsd || dragonfly => true,
"sem_t" if openbsd || freebsd => true,
// mqd_t is a pointer on FreeBSD
"mqd_t" if freebsd => true,
_ => false,
}
@ -592,7 +583,7 @@ fn do_ctest() {
"sendmmsg" | "recvmmsg" if musl => true,
// typed 2nd arg on linux and android
"gettimeofday" if linux || android || freebsd || openbsd || dragonfly => true,
"gettimeofday" if linux || android || freebsd || openbsd => true,
// not declared in newer android toolchains
"getdtablesize" if android => true,
@ -1522,3 +1513,218 @@ fn test_netbsd(target: &str) {
cfg.generate("../src/lib.rs", "main.rs");
}
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",
"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.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(),
// FIXME: 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")
}
"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 and android
"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");
}