2015-09-17 02:44:40 +02:00
|
|
|
#![deny(warnings)]
|
|
|
|
|
2015-09-16 08:28:52 +02:00
|
|
|
extern crate ctest;
|
2015-09-10 07:46:19 +02:00
|
|
|
|
|
|
|
use std::env;
|
|
|
|
|
2015-09-16 08:28:52 +02:00
|
|
|
fn main() {
|
|
|
|
let target = env::var("TARGET").unwrap();
|
2015-12-03 20:44:14 +01:00
|
|
|
let x86_64 = target.contains("x86_64");
|
2015-09-16 08:28:52 +02:00
|
|
|
let windows = target.contains("windows");
|
|
|
|
let mingw = target.contains("windows-gnu");
|
2015-09-17 23:47:40 +02:00
|
|
|
let linux = target.contains("unknown-linux");
|
2015-09-18 00:09:02 +02:00
|
|
|
let android = target.contains("android");
|
2015-09-20 08:20:53 +02:00
|
|
|
let apple = target.contains("apple");
|
2015-09-18 02:25:52 +02:00
|
|
|
let musl = target.contains("musl");
|
2015-09-18 20:54:32 +02:00
|
|
|
let freebsd = target.contains("freebsd");
|
2015-11-27 01:02:44 +01:00
|
|
|
let mips = target.contains("mips");
|
2015-11-27 18:40:37 +01:00
|
|
|
let netbsd = target.contains("netbsd");
|
2015-12-21 17:26:41 +01:00
|
|
|
let openbsd = target.contains("openbsd");
|
2015-11-27 18:40:37 +01:00
|
|
|
let rumprun = target.contains("rumprun");
|
2015-12-21 17:26:41 +01:00
|
|
|
let bsdlike = freebsd || apple || netbsd || openbsd;
|
2015-09-16 08:28:52 +02:00
|
|
|
let mut cfg = ctest::TestGenerator::new();
|
|
|
|
|
|
|
|
// Pull in extra goodies on linux/mingw
|
2015-12-03 20:44:14 +01:00
|
|
|
if linux || android {
|
2015-09-16 08:28:52 +02:00
|
|
|
cfg.define("_GNU_SOURCE", None);
|
2015-09-18 00:09:02 +02:00
|
|
|
} else if windows {
|
2015-09-16 08:28:52 +02:00
|
|
|
cfg.define("_WIN32_WINNT", Some("0x8000"));
|
|
|
|
}
|
|
|
|
|
2015-09-17 01:27:23 +02:00
|
|
|
// Android doesn't actually have in_port_t but it's much easier if we
|
|
|
|
// provide one for us to test against
|
2015-09-18 00:09:02 +02:00
|
|
|
if android {
|
2015-09-17 01:27:23 +02:00
|
|
|
cfg.define("in_port_t", Some("uint16_t"));
|
|
|
|
}
|
|
|
|
|
2015-09-16 08:28:52 +02:00
|
|
|
cfg.header("errno.h")
|
|
|
|
.header("fcntl.h")
|
|
|
|
.header("limits.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");
|
|
|
|
|
2015-09-18 00:09:02 +02:00
|
|
|
if windows {
|
2015-09-16 08:28:52 +02:00
|
|
|
cfg.header("winsock2.h"); // must be before windows.h
|
|
|
|
|
|
|
|
cfg.header("direct.h");
|
|
|
|
cfg.header("io.h");
|
|
|
|
cfg.header("sys/utime.h");
|
|
|
|
cfg.header("windows.h");
|
|
|
|
cfg.header("process.h");
|
|
|
|
cfg.header("ws2ipdef.h");
|
|
|
|
|
|
|
|
if target.contains("gnu") {
|
|
|
|
cfg.header("ws2tcpip.h");
|
2015-09-10 19:56:31 +02:00
|
|
|
}
|
2015-09-16 08:28:52 +02:00
|
|
|
} else {
|
|
|
|
cfg.header("ctype.h");
|
|
|
|
cfg.header("dirent.h");
|
2015-12-21 17:26:41 +01:00
|
|
|
if openbsd {
|
|
|
|
cfg.header("sys/socket.h");
|
|
|
|
}
|
2015-09-16 08:28:52 +02:00
|
|
|
cfg.header("net/if.h");
|
|
|
|
cfg.header("netdb.h");
|
|
|
|
cfg.header("netinet/in.h");
|
|
|
|
cfg.header("netinet/ip.h");
|
|
|
|
cfg.header("netinet/tcp.h");
|
|
|
|
cfg.header("pthread.h");
|
2015-09-18 00:09:02 +02:00
|
|
|
cfg.header("dlfcn.h");
|
2015-09-16 08:28:52 +02:00
|
|
|
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");
|
|
|
|
cfg.header("sys/time.h");
|
|
|
|
cfg.header("sys/un.h");
|
|
|
|
cfg.header("sys/wait.h");
|
|
|
|
cfg.header("unistd.h");
|
|
|
|
cfg.header("utime.h");
|
2015-09-17 23:47:40 +02:00
|
|
|
cfg.header("pwd.h");
|
|
|
|
cfg.header("grp.h");
|
2015-12-03 20:44:14 +01:00
|
|
|
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");
|
2015-12-25 22:06:44 +01:00
|
|
|
cfg.header("poll.h");
|
2015-09-18 20:54:32 +02:00
|
|
|
}
|
2015-09-16 08:28:52 +02:00
|
|
|
|
2015-09-18 20:54:32 +02:00
|
|
|
if android {
|
|
|
|
cfg.header("arpa/inet.h");
|
2015-11-03 23:18:52 +01:00
|
|
|
cfg.header("time64.h");
|
2015-09-18 20:54:32 +02:00
|
|
|
} else if !windows {
|
|
|
|
cfg.header("glob.h");
|
|
|
|
cfg.header("ifaddrs.h");
|
2016-01-18 20:18:22 +01:00
|
|
|
cfg.header("sys/statvfs.h");
|
|
|
|
|
|
|
|
if !openbsd && !freebsd {
|
2015-12-21 17:26:41 +01:00
|
|
|
cfg.header("sys/quota.h");
|
|
|
|
}
|
2015-09-18 20:54:32 +02:00
|
|
|
|
|
|
|
if !musl {
|
|
|
|
cfg.header("sys/sysctl.h");
|
2015-11-27 18:40:37 +01:00
|
|
|
|
2015-12-21 17:26:41 +01:00
|
|
|
if !netbsd && !openbsd {
|
2015-11-27 18:40:37 +01:00
|
|
|
cfg.header("execinfo.h");
|
|
|
|
}
|
2015-09-18 00:47:44 +02:00
|
|
|
}
|
2015-09-18 20:54:32 +02:00
|
|
|
}
|
2015-09-18 00:47:44 +02:00
|
|
|
|
2015-09-20 08:20:53 +02:00
|
|
|
if apple {
|
2015-09-18 20:54:32 +02:00
|
|
|
cfg.header("mach-o/dyld.h");
|
|
|
|
cfg.header("mach/mach_time.h");
|
|
|
|
cfg.header("malloc/malloc.h");
|
2015-09-20 08:20:53 +02:00
|
|
|
if target.starts_with("x86") {
|
|
|
|
cfg.header("crt_externs.h");
|
|
|
|
}
|
2015-09-17 23:47:40 +02:00
|
|
|
}
|
2015-09-18 20:54:32 +02:00
|
|
|
|
2015-12-03 20:44:14 +01:00
|
|
|
if bsdlike {
|
|
|
|
cfg.header("sys/event.h");
|
|
|
|
}
|
|
|
|
|
2015-12-01 13:29:05 +01:00
|
|
|
if linux {
|
2015-12-03 20:44:14 +01:00
|
|
|
cfg.header("mqueue.h");
|
|
|
|
cfg.header("sys/signalfd.h");
|
2015-12-01 13:29:05 +01:00
|
|
|
cfg.header("sys/xattr.h");
|
2015-12-14 00:09:45 +01:00
|
|
|
cfg.header("sys/ipc.h");
|
|
|
|
cfg.header("sys/shm.h");
|
2015-12-01 13:29:05 +01:00
|
|
|
}
|
|
|
|
|
2015-09-18 20:54:32 +02:00
|
|
|
if linux || android {
|
|
|
|
cfg.header("malloc.h");
|
2015-12-03 20:44:14 +01:00
|
|
|
cfg.header("net/ethernet.h");
|
|
|
|
cfg.header("netpacket/packet.h");
|
|
|
|
cfg.header("sched.h");
|
|
|
|
cfg.header("sys/epoll.h");
|
|
|
|
cfg.header("sys/eventfd.h");
|
2015-09-17 23:47:40 +02:00
|
|
|
cfg.header("sys/prctl.h");
|
2016-02-04 20:08:50 +01:00
|
|
|
cfg.header("sys/sendfile.h");
|
2015-12-03 20:44:14 +01:00
|
|
|
cfg.header("sys/vfs.h");
|
2015-12-01 18:04:13 +01:00
|
|
|
cfg.header("sys/syscall.h");
|
2015-11-10 23:53:39 +01:00
|
|
|
if !musl {
|
|
|
|
cfg.header("linux/netlink.h");
|
2015-12-03 20:44:14 +01:00
|
|
|
cfg.header("linux/magic.h");
|
|
|
|
|
|
|
|
if !mips {
|
|
|
|
cfg.header("linux/quota.h");
|
|
|
|
}
|
2015-11-10 23:53:39 +01:00
|
|
|
}
|
2015-09-10 19:56:31 +02:00
|
|
|
}
|
|
|
|
|
2015-09-18 20:54:32 +02:00
|
|
|
if freebsd {
|
|
|
|
cfg.header("pthread_np.h");
|
2015-11-27 01:02:44 +01:00
|
|
|
cfg.header("sched.h");
|
2016-01-18 20:18:22 +01:00
|
|
|
cfg.header("ufs/ufs/quota.h");
|
2015-09-18 20:54:32 +02:00
|
|
|
}
|
|
|
|
|
2015-12-03 20:44:14 +01:00
|
|
|
if netbsd {
|
|
|
|
cfg.header("ufs/ufs/quota.h");
|
|
|
|
cfg.header("ufs/ufs/quota1.h");
|
|
|
|
cfg.header("sys/ioctl_compat.h");
|
|
|
|
}
|
|
|
|
|
2015-12-21 17:26:41 +01:00
|
|
|
if openbsd {
|
|
|
|
cfg.header("ufs/ufs/quota.h");
|
|
|
|
cfg.header("rpcsvc/rex.h");
|
|
|
|
cfg.header("pthread_np.h");
|
|
|
|
cfg.header("sys/syscall.h");
|
|
|
|
}
|
|
|
|
|
2015-09-16 08:28:52 +02:00
|
|
|
cfg.type_name(move |ty, is_struct| {
|
2015-09-10 19:56:31 +02:00
|
|
|
match ty {
|
2015-09-11 08:43:41 +02:00
|
|
|
// Just pass all these through, no need for a "struct" prefix
|
2015-09-11 04:59:23 +02:00
|
|
|
"FILE" |
|
2015-10-30 18:21:32 +01:00
|
|
|
"fd_set" |
|
2015-11-03 02:03:19 +01:00
|
|
|
"Dl_info" |
|
2015-09-17 23:47:40 +02:00
|
|
|
"DIR" => ty.to_string(),
|
|
|
|
|
|
|
|
// Fixup a few types on windows that don't actually exist.
|
|
|
|
"time64_t" if windows => "__time64_t".to_string(),
|
|
|
|
"ssize_t" if windows => "SSIZE_T".to_string(),
|
|
|
|
|
2015-09-18 00:47:44 +02:00
|
|
|
// OSX calls this something else
|
2015-09-18 20:54:32 +02:00
|
|
|
"sighandler_t" if bsdlike => "sig_t".to_string(),
|
2015-09-18 00:47:44 +02:00
|
|
|
|
2015-09-17 23:47:40 +02:00
|
|
|
t if t.ends_with("_t") => t.to_string(),
|
2015-09-10 19:56:31 +02:00
|
|
|
|
2015-09-11 08:43:41 +02:00
|
|
|
// Windows uppercase structs don't have `struct` in front, there's a
|
|
|
|
// few special cases for windows, and then otherwise put `struct` in
|
|
|
|
// front of everything.
|
2015-09-16 08:28:52 +02:00
|
|
|
t if is_struct => {
|
2015-09-11 03:10:58 +02:00
|
|
|
if windows && ty.chars().next().unwrap().is_uppercase() {
|
|
|
|
t.to_string()
|
|
|
|
} else if windows && t == "stat" {
|
|
|
|
"struct __stat64".to_string()
|
2015-09-11 05:57:14 +02:00
|
|
|
} else if windows && t == "utimbuf" {
|
|
|
|
"struct __utimbuf64".to_string()
|
2015-09-11 03:10:58 +02:00
|
|
|
} else {
|
|
|
|
format!("struct {}", t)
|
|
|
|
}
|
|
|
|
}
|
2015-09-10 19:56:31 +02:00
|
|
|
|
|
|
|
t => t.to_string(),
|
|
|
|
}
|
2015-09-16 08:28:52 +02:00
|
|
|
});
|
2015-09-10 19:56:31 +02:00
|
|
|
|
2015-09-16 08:28:52 +02:00
|
|
|
let target2 = target.clone();
|
|
|
|
cfg.field_name(move |struct_, field| {
|
2015-09-10 19:56:31 +02:00
|
|
|
match field {
|
2015-12-23 18:54:25 +01:00
|
|
|
"st_birthtime" if openbsd && struct_ == "stat" => "__st_birthtime".to_string(),
|
2015-12-21 17:26:41 +01:00
|
|
|
"st_birthtime_nsec" if openbsd && struct_ == "stat" => "__st_birthtimensec".to_string(),
|
2015-09-11 08:43:41 +02:00
|
|
|
// Our stat *_nsec fields normally don't actually exist but are part
|
|
|
|
// of a timeval struct
|
2015-10-30 01:36:55 +01:00
|
|
|
s if s.ends_with("_nsec") && struct_.starts_with("stat") => {
|
2015-09-20 08:20:53 +02:00
|
|
|
if target2.contains("apple") {
|
2015-09-10 19:56:31 +02:00
|
|
|
s.replace("_nsec", "spec.tv_nsec")
|
2015-09-16 08:28:52 +02:00
|
|
|
} else if target2.contains("android") {
|
2015-09-12 02:03:39 +02:00
|
|
|
s.to_string()
|
2015-09-10 19:56:31 +02:00
|
|
|
} else {
|
|
|
|
s.replace("e_nsec", ".tv_nsec")
|
|
|
|
}
|
|
|
|
}
|
2015-12-03 20:44:14 +01:00
|
|
|
"u64" if struct_ == "epoll_event" => "data.u64".to_string(),
|
2015-09-10 19:56:31 +02:00
|
|
|
s => s.to_string(),
|
|
|
|
}
|
2015-09-16 08:28:52 +02:00
|
|
|
});
|
2015-09-11 08:43:41 +02:00
|
|
|
|
2015-09-16 08:28:52 +02:00
|
|
|
cfg.skip_type(move |ty| {
|
2015-09-10 19:56:31 +02:00
|
|
|
match ty {
|
2015-09-12 02:03:39 +02:00
|
|
|
// sighandler_t is crazy across platforms
|
2015-09-16 08:28:52 +02:00
|
|
|
"sighandler_t" => true,
|
2015-09-12 02:03:39 +02:00
|
|
|
|
2015-09-16 08:28:52 +02:00
|
|
|
_ => false
|
2015-09-10 19:56:31 +02:00
|
|
|
}
|
2015-09-16 08:28:52 +02:00
|
|
|
});
|
2015-09-10 08:21:27 +02:00
|
|
|
|
2015-11-10 23:53:39 +01:00
|
|
|
cfg.skip_struct(move |ty| {
|
|
|
|
match ty {
|
|
|
|
"sockaddr_nl" => musl,
|
2015-12-03 20:44:14 +01:00
|
|
|
|
|
|
|
// The alignment of this is 4 on 64-bit OSX...
|
|
|
|
"kevent" if apple && x86_64 => true,
|
|
|
|
|
2015-11-10 23:53:39 +01:00
|
|
|
_ => false
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-09-16 08:28:52 +02:00
|
|
|
cfg.skip_signededness(|c| {
|
2015-09-15 23:53:01 +02:00
|
|
|
match c {
|
2015-09-16 05:56:16 +02:00
|
|
|
"LARGE_INTEGER" |
|
2015-09-16 01:57:06 +02:00
|
|
|
"mach_timebase_info_data_t" |
|
2015-09-16 05:56:16 +02:00
|
|
|
"float" |
|
2015-09-16 08:28:52 +02:00
|
|
|
"double" => true,
|
|
|
|
n if n.starts_with("pthread") => true,
|
2015-09-16 05:57:42 +02:00
|
|
|
|
|
|
|
// windows-isms
|
2015-09-16 08:28:52 +02:00
|
|
|
n if n.starts_with("P") => true,
|
|
|
|
n if n.starts_with("H") => true,
|
|
|
|
n if n.starts_with("LP") => true,
|
|
|
|
_ => false,
|
2015-09-15 23:53:01 +02:00
|
|
|
}
|
2015-09-16 08:28:52 +02:00
|
|
|
});
|
2015-09-15 23:53:01 +02:00
|
|
|
|
2015-09-16 08:28:52 +02:00
|
|
|
cfg.skip_const(move |name| {
|
2015-09-11 08:43:41 +02:00
|
|
|
match name {
|
2015-09-17 23:47:40 +02:00
|
|
|
// Apparently these don't exist in mingw headers?
|
2015-09-11 08:43:41 +02:00
|
|
|
"MEM_RESET_UNDO" |
|
|
|
|
"FILE_ATTRIBUTE_NO_SCRUB_DATA" |
|
|
|
|
"FILE_ATTRIBUTE_INTEGRITY_STREAM" |
|
2015-09-16 08:28:52 +02:00
|
|
|
"ERROR_NOTHING_TO_TERMINATE" if mingw => true,
|
2015-09-17 23:47:40 +02:00
|
|
|
|
2015-09-16 08:28:52 +02:00
|
|
|
"SIG_IGN" => true, // sighandler_t weirdness
|
2015-09-17 23:47:40 +02:00
|
|
|
|
2015-09-18 02:25:52 +02:00
|
|
|
// types on musl are defined a little differently
|
2015-10-30 00:52:25 +01:00
|
|
|
n if musl && n.contains("__SIZEOF_PTHREAD") => true,
|
2015-09-18 02:25:52 +02:00
|
|
|
|
2015-10-30 01:36:55 +01:00
|
|
|
// Skip constants not defined in MUSL but just passed down to the
|
|
|
|
// kernel regardless
|
|
|
|
"RLIMIT_NLIMITS" |
|
|
|
|
"TCP_COOKIE_TRANSACTIONS" |
|
|
|
|
"RLIMIT_RTTIME" if musl => true,
|
2015-11-27 01:02:44 +01:00
|
|
|
// work around super old mips toolchain
|
2015-12-14 00:09:45 +01:00
|
|
|
"SCHED_IDLE" | "SHM_NORESERVE" => mips,
|
2015-10-30 01:36:55 +01:00
|
|
|
|
2015-12-03 20:44:14 +01:00
|
|
|
// weird signed extension or something like that?
|
|
|
|
"MS_NOUSER" => true,
|
|
|
|
|
|
|
|
// These OSX constants are flagged as deprecated
|
|
|
|
"NOTE_EXIT_REPARENTED" |
|
|
|
|
"NOTE_REAP" if apple => true,
|
|
|
|
|
|
|
|
// The linux/quota.h header file which defines these can't be
|
|
|
|
// included with sys/quota.h currently on MIPS, so we don't include
|
|
|
|
// it and just ignore these constants
|
|
|
|
"QFMT_VFS_OLD" |
|
|
|
|
"QFMT_VFS_V0" if mips && linux => true,
|
|
|
|
|
2015-09-16 08:28:52 +02:00
|
|
|
_ => false,
|
2015-09-11 08:43:41 +02:00
|
|
|
}
|
2015-09-16 08:28:52 +02:00
|
|
|
});
|
2015-09-11 08:43:41 +02:00
|
|
|
|
2015-09-17 23:47:40 +02:00
|
|
|
cfg.skip_fn(move |name| {
|
2016-01-13 01:28:07 +01:00
|
|
|
// skip those that are manually verified
|
2015-09-11 04:59:23 +02:00
|
|
|
match name {
|
2015-09-17 23:47:40 +02:00
|
|
|
"execv" | // crazy stuff with const/mut
|
2015-09-11 04:59:23 +02:00
|
|
|
"execve" |
|
|
|
|
"execvp" |
|
2015-09-17 23:47:40 +02:00
|
|
|
"execvpe" => true,
|
|
|
|
|
2015-10-30 01:36:55 +01:00
|
|
|
"getrlimit" | "getrlimit64" | // non-int in 1st arg
|
|
|
|
"setrlimit" | "setrlimit64" | // non-int in 1st arg
|
2015-09-17 23:47:40 +02:00
|
|
|
"strerror_r" if linux => true, // actually xpg-something-or-other
|
|
|
|
|
2015-09-18 00:09:02 +02:00
|
|
|
// typed 2nd arg on linux and android
|
2015-12-21 17:26:41 +01:00
|
|
|
"gettimeofday" if linux || android || freebsd || openbsd => true,
|
2015-09-18 00:09:02 +02:00
|
|
|
|
2015-12-01 18:04:13 +01:00
|
|
|
// not declared in newer android toolchains
|
|
|
|
"getdtablesize" if android => true,
|
|
|
|
|
2015-09-18 00:09:02 +02:00
|
|
|
"dlerror" if android => true, // const-ness is added
|
2015-11-03 02:03:19 +01:00
|
|
|
"dladdr" if musl => true, // const-ness only added recently
|
2015-09-18 00:09:02 +02:00
|
|
|
|
2015-11-03 23:18:52 +01:00
|
|
|
// OSX has 'struct tm *const' which we can't actually represent in
|
|
|
|
// Rust, but is close enough to *mut
|
|
|
|
"timegm" if apple => true,
|
|
|
|
|
2015-12-03 20:44:14 +01:00
|
|
|
// OSX's daemon is deprecated in 10.5 so we'll get a warning (which
|
|
|
|
// we turn into an error) so just ignore it.
|
|
|
|
"daemon" if apple => true,
|
|
|
|
|
2015-11-27 18:40:37 +01:00
|
|
|
// 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...
|
|
|
|
"backtrace" |
|
|
|
|
"pthread_main_np" |
|
|
|
|
"pthread_set_name_np" |
|
|
|
|
"pthread_stackseg_np" |
|
|
|
|
"shm_open" |
|
|
|
|
"shm_unlink" |
|
2015-12-03 20:44:14 +01:00
|
|
|
"syscall" |
|
|
|
|
"ptrace" |
|
2015-11-27 18:40:37 +01:00
|
|
|
"sigaltstack" if rumprun => true,
|
|
|
|
|
2016-01-13 01:28:07 +01:00
|
|
|
// 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 <sys/eventfd.h>
|
|
|
|
// 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 <sys/eventfd.h> 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,
|
|
|
|
|
2016-01-18 20:18:22 +01:00
|
|
|
// The `uname` funcion 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,
|
|
|
|
|
2015-09-16 08:28:52 +02:00
|
|
|
_ => false,
|
2015-09-11 04:59:23 +02:00
|
|
|
}
|
2015-09-16 08:28:52 +02:00
|
|
|
});
|
2015-09-11 04:59:23 +02:00
|
|
|
|
2015-12-01 18:04:13 +01:00
|
|
|
cfg.skip_fn_ptrcheck(move |name| {
|
|
|
|
match name {
|
|
|
|
// This used to be called bsd_signal in rev 18 of the android
|
|
|
|
// platform and is now just called signal, the old `bsd_signal`
|
|
|
|
// symbol, however, still remains, just gives a different function
|
|
|
|
// pointer.
|
|
|
|
"signal" if android => true,
|
|
|
|
|
|
|
|
// dllimport weirdness?
|
|
|
|
_ if windows => true,
|
|
|
|
|
|
|
|
_ => false,
|
|
|
|
}
|
|
|
|
});
|
2015-09-16 18:48:14 +02:00
|
|
|
|
2015-09-18 02:25:52 +02:00
|
|
|
cfg.skip_field_type(move |struct_, field| {
|
2015-09-16 23:13:20 +02:00
|
|
|
// This is a weird union, don't check the type.
|
2015-09-17 23:47:40 +02:00
|
|
|
(struct_ == "ifaddrs" && field == "ifa_ifu") ||
|
|
|
|
// sighandler_t type is super weird
|
|
|
|
(struct_ == "sigaction" && field == "sa_sigaction")
|
|
|
|
});
|
|
|
|
|
2015-09-18 02:25:52 +02:00
|
|
|
cfg.skip_field(move |struct_, field| {
|
2015-09-17 23:47:40 +02:00
|
|
|
// this is actually a union on linux, so we can't represent it well and
|
|
|
|
// just insert some padding.
|
2015-09-18 02:25:52 +02:00
|
|
|
(struct_ == "siginfo_t" && field == "_pad") ||
|
|
|
|
// musl names this __dummy1 but it's still there
|
2015-12-29 21:00:29 +01:00
|
|
|
(musl && struct_ == "glob_t" && field == "gl_flags") ||
|
|
|
|
// musl seems to define this as an *anonymous* bitfield
|
|
|
|
(musl && struct_ == "statvfs" && field == "__f_unused")
|
2015-09-16 23:13:20 +02:00
|
|
|
});
|
|
|
|
|
2015-11-27 18:40:37 +01:00
|
|
|
cfg.fn_cname(move |name, cname| {
|
2015-12-01 18:04:13 +01:00
|
|
|
if windows {
|
2015-11-27 18:40:37 +01:00
|
|
|
cname.unwrap_or(name).to_string()
|
2015-12-01 00:07:28 +01:00
|
|
|
} else {
|
2015-11-27 18:40:37 +01:00
|
|
|
name.to_string()
|
2015-12-01 00:07:28 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-01-18 20:16:38 +01:00
|
|
|
if env::var("SKIP_COMPILE").is_ok() {
|
|
|
|
cfg.generate_files("../src/lib.rs", "all.rs");
|
|
|
|
} else {
|
|
|
|
cfg.generate("../src/lib.rs", "all.rs");
|
|
|
|
}
|
2015-09-10 19:56:31 +02:00
|
|
|
}
|