Skip to content

Commit 70e0c4e

Browse files
committed
Cleanup DragonflyBSD in libc-test/build.rs
1 parent 87f10ab commit 70e0c4e

File tree

1 file changed

+224
-18
lines changed

1 file changed

+224
-18
lines changed

libc-test/build.rs

Lines changed: 224 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ fn do_ctest() {
2424
let musl = target.contains("musl") || emscripten;
2525
let uclibc = target.contains("uclibc");
2626
let freebsd = target.contains("freebsd");
27-
let dragonfly = target.contains("dragonfly");
2827
let mips = target.contains("mips");
2928
let openbsd = target.contains("openbsd");
30-
let bsdlike = freebsd || openbsd || dragonfly;
29+
let bsdlike = freebsd || openbsd;
3130
let mut cfg = ctest::TestGenerator::new();
3231

3332
match &target {
@@ -37,6 +36,7 @@ fn do_ctest() {
3736
t if t.contains("cloudabi") => return test_cloudabi(t),
3837
t if t.contains("solaris") => return test_solaris(t),
3938
t if t.contains("netbsd") => return test_netbsd(t),
39+
t if t.contains("dragonfly") => return test_dragonflybsd(t),
4040
_ => (),
4141
}
4242

@@ -132,7 +132,7 @@ fn do_ctest() {
132132
cfg.header("ifaddrs.h");
133133
cfg.header("langinfo.h");
134134

135-
if !openbsd && !freebsd && !dragonfly {
135+
if !openbsd && !freebsd {
136136
cfg.header("sys/quota.h");
137137
}
138138

@@ -277,14 +277,7 @@ fn do_ctest() {
277277
cfg.header("sys/syscall.h");
278278
}
279279

280-
if dragonfly {
281-
cfg.header("mqueue.h");
282-
cfg.header("ufs/ufs/quota.h");
283-
cfg.header("pthread_np.h");
284-
cfg.header("sys/rtprio.h");
285-
}
286-
287-
if linux || freebsd || dragonfly || emscripten {
280+
if linux || freebsd || emscripten {
288281
if !uclibc {
289282
cfg.header("aio.h");
290283
}
@@ -332,7 +325,7 @@ fn do_ctest() {
332325
}
333326
"u64" if struct_ == "epoll_event" => "data.u64".to_string(),
334327
"type_"
335-
if (linux || freebsd || dragonfly)
328+
if (linux || freebsd)
336329
&& (struct_ == "input_event"
337330
|| struct_ == "input_mask"
338331
|| struct_ == "ff_effect"
@@ -385,13 +378,11 @@ fn do_ctest() {
385378
cfg.skip_signededness(move |c| {
386379
match c {
387380
"LARGE_INTEGER" | "float" | "double" => true,
388-
// uuid_t is a struct, not an integer.
389-
"uuid_t" if dragonfly => true,
390381
n if n.starts_with("pthread") => true,
391382
// sem_t is a struct or pointer
392-
"sem_t" if openbsd || freebsd || dragonfly => true,
393-
// mqd_t is a pointer on FreeBSD and DragonFly
394-
"mqd_t" if freebsd || dragonfly => true,
383+
"sem_t" if openbsd || freebsd => true,
384+
// mqd_t is a pointer on FreeBSD
385+
"mqd_t" if freebsd => true,
395386

396387
_ => false,
397388
}
@@ -592,7 +583,7 @@ fn do_ctest() {
592583
"sendmmsg" | "recvmmsg" if musl => true,
593584

594585
// typed 2nd arg on linux and android
595-
"gettimeofday" if linux || android || freebsd || openbsd || dragonfly => true,
586+
"gettimeofday" if linux || android || freebsd || openbsd => true,
596587

597588
// not declared in newer android toolchains
598589
"getdtablesize" if android => true,
@@ -1522,3 +1513,218 @@ fn test_netbsd(target: &str) {
15221513

15231514
cfg.generate("../src/lib.rs", "main.rs");
15241515
}
1516+
1517+
fn test_dragonflybsd(target: &str) {
1518+
assert!(target.contains("dragonfly"));
1519+
let mut cfg = ctest::TestGenerator::new();
1520+
cfg.flag("-Wno-deprecated-declarations");
1521+
1522+
headers! {
1523+
cfg:
1524+
"aio.h",
1525+
"ctype.h",
1526+
"dirent.h",
1527+
"dlfcn.h",
1528+
"errno.h",
1529+
"execinfo.h",
1530+
"fcntl.h",
1531+
"glob.h",
1532+
"grp.h",
1533+
"ifaddrs.h",
1534+
"langinfo.h",
1535+
"limits.h",
1536+
"locale.h",
1537+
"mqueue.h",
1538+
"net/if.h",
1539+
"net/if_arp.h",
1540+
"net/if_dl.h",
1541+
"net/route.h",
1542+
"netdb.h",
1543+
"netinet/in.h",
1544+
"netinet/ip.h",
1545+
"netinet/tcp.h",
1546+
"netinet/udp.h",
1547+
"poll.h",
1548+
"pthread.h",
1549+
"pthread_np.h",
1550+
"pwd.h",
1551+
"resolv.h",
1552+
"sched.h",
1553+
"semaphore.h",
1554+
"signal.h",
1555+
"stddef.h",
1556+
"stdint.h",
1557+
"stdio.h",
1558+
"stdlib.h",
1559+
"string.h",
1560+
"sys/event.h",
1561+
"sys/file.h",
1562+
"sys/ioctl.h",
1563+
"sys/mman.h",
1564+
"sys/mount.h",
1565+
"sys/ptrace.h",
1566+
"sys/resource.h",
1567+
"sys/rtprio.h",
1568+
"sys/socket.h",
1569+
"sys/stat.h",
1570+
"sys/statvfs.h",
1571+
"sys/sysctl.h",
1572+
"sys/time.h",
1573+
"sys/times.h",
1574+
"sys/types.h",
1575+
"sys/uio.h",
1576+
"sys/un.h",
1577+
"sys/utsname.h",
1578+
"sys/wait.h",
1579+
"syslog.h",
1580+
"termios.h",
1581+
"time.h",
1582+
"ufs/ufs/quota.h",
1583+
"unistd.h",
1584+
"util.h",
1585+
"utime.h",
1586+
"utmpx.h",
1587+
"wchar.h",
1588+
}
1589+
1590+
cfg.type_name(move |ty, is_struct, is_union| {
1591+
match ty {
1592+
// Just pass all these through, no need for a "struct" prefix
1593+
"FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr"
1594+
| "Elf64_Phdr" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym"
1595+
| "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr"
1596+
| "Elf64_Chdr" => ty.to_string(),
1597+
1598+
// FIXME: OSX calls this something else
1599+
"sighandler_t" => "sig_t".to_string(),
1600+
1601+
t if is_union => format!("union {}", t),
1602+
1603+
t if t.ends_with("_t") => t.to_string(),
1604+
1605+
// put `struct` in front of all structs:.
1606+
t if is_struct => format!("struct {}", t),
1607+
1608+
t => t.to_string(),
1609+
}
1610+
});
1611+
1612+
cfg.field_name(move |struct_, field| {
1613+
match field {
1614+
// Our stat *_nsec fields normally don't actually exist but are part
1615+
// of a timeval struct
1616+
s if s.ends_with("_nsec") && struct_.starts_with("stat") => {
1617+
s.replace("e_nsec", ".tv_nsec")
1618+
}
1619+
"u64" if struct_ == "epoll_event" => "data.u64".to_string(),
1620+
"type_" if struct_ == "input_event"
1621+
|| struct_ == "input_mask"
1622+
|| struct_ == "ff_effect"
1623+
|| struct_ == "rtprio" =>
1624+
"type".to_string(),
1625+
s => s.to_string(),
1626+
}
1627+
});
1628+
1629+
cfg.skip_type(move |ty| {
1630+
match ty {
1631+
// sighandler_t is crazy across platforms
1632+
"sighandler_t" => true,
1633+
1634+
_ => false,
1635+
}
1636+
});
1637+
1638+
cfg.skip_struct(move |ty| {
1639+
match ty {
1640+
// This is actually a union, not a struct
1641+
"sigval" => true,
1642+
1643+
// FIXME: These are tested as part of the linux_fcntl tests since
1644+
// there are header conflicts when including them with all the other
1645+
// structs.
1646+
"termios2" => true,
1647+
1648+
_ => false,
1649+
}
1650+
});
1651+
1652+
cfg.skip_signededness(move |c| {
1653+
match c {
1654+
"LARGE_INTEGER" | "float" | "double" => true,
1655+
// uuid_t is a struct, not an integer.
1656+
"uuid_t" => true,
1657+
n if n.starts_with("pthread") => true,
1658+
// sem_t is a struct or pointer
1659+
"sem_t" => true,
1660+
// mqd_t is a pointer on DragonFly
1661+
"mqd_t" => true,
1662+
1663+
_ => false,
1664+
}
1665+
});
1666+
1667+
cfg.skip_const(move |name| {
1668+
match name {
1669+
"SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness
1670+
1671+
// weird signed extension or something like that?
1672+
"MS_NOUSER" => true,
1673+
"MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13
1674+
1675+
// These are defined for Solaris 11, but the crate is tested on
1676+
// illumos, where they are currently not defined
1677+
"EADI"
1678+
| "PORT_SOURCE_POSTWAIT"
1679+
| "PORT_SOURCE_SIGNAL"
1680+
| "PTHREAD_STACK_MIN" => true,
1681+
1682+
// These change all the time from release to release of linux
1683+
// distros, let's just not bother trying to verify them. They
1684+
// shouldn't be used in code anyway...
1685+
"AF_MAX" | "PF_MAX" => true,
1686+
1687+
_ => false,
1688+
}
1689+
});
1690+
1691+
cfg.skip_fn(move |name| {
1692+
// skip those that are manually verified
1693+
match name {
1694+
"execv" | // crazy stuff with const/mut
1695+
"execve" |
1696+
"execvp" |
1697+
"execvpe" |
1698+
"fexecve" => true,
1699+
1700+
"getrlimit" | "getrlimit64" | // non-int in 1st arg
1701+
"setrlimit" | "setrlimit64" | // non-int in 1st arg
1702+
"prlimit" | "prlimit64" | // non-int in 2nd arg
1703+
// typed 2nd arg on linux and android
1704+
"gettimeofday" => true,
1705+
1706+
_ => false,
1707+
}
1708+
});
1709+
1710+
cfg.skip_field_type(move |struct_, field| {
1711+
// This is a weird union, don't check the type.
1712+
(struct_ == "ifaddrs" && field == "ifa_ifu") ||
1713+
// sighandler_t type is super weird
1714+
(struct_ == "sigaction" && field == "sa_sigaction") ||
1715+
// sigval is actually a union, but we pretend it's a struct
1716+
(struct_ == "sigevent" && field == "sigev_value") ||
1717+
// aio_buf is "volatile void*" and Rust doesn't understand volatile
1718+
(struct_ == "aiocb" && field == "aio_buf")
1719+
});
1720+
1721+
cfg.skip_field(move |struct_, field| {
1722+
// this is actually a union on linux, so we can't represent it well and
1723+
// just insert some padding.
1724+
(struct_ == "siginfo_t" && field == "_pad") ||
1725+
// sigev_notify_thread_id is actually part of a sigev_un union
1726+
(struct_ == "sigevent" && field == "sigev_notify_thread_id")
1727+
});
1728+
1729+
cfg.generate("../src/lib.rs", "main.rs");
1730+
}

0 commit comments

Comments
 (0)