summaryrefslogtreecommitdiff
path: root/libc/libc-test/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'libc/libc-test/build.rs')
-rw-r--r--libc/libc-test/build.rs148
1 files changed, 128 insertions, 20 deletions
diff --git a/libc/libc-test/build.rs b/libc/libc-test/build.rs
index ce50812..48f596f 100644
--- a/libc/libc-test/build.rs
+++ b/libc/libc-test/build.rs
@@ -9,6 +9,7 @@ fn main() {
let aarch64 = target.contains("aarch64");
let i686 = target.contains("i686");
let x86_64 = target.contains("x86_64");
+ let x32 = target.ends_with("gnux32");
let windows = target.contains("windows");
let mingw = target.contains("windows-gnu");
let linux = target.contains("unknown-linux");
@@ -23,6 +24,7 @@ fn main() {
let netbsd = target.contains("netbsd");
let openbsd = target.contains("openbsd");
let rumprun = target.contains("rumprun");
+ let solaris = target.contains("solaris");
let bsdlike = freebsd || apple || netbsd || openbsd || dragonfly;
let mut cfg = ctest::TestGenerator::new();
@@ -33,6 +35,10 @@ fn main() {
cfg.define("_NETBSD_SOURCE", Some("1"));
} else if windows {
cfg.define("_WIN32_WINNT", Some("0x8000"));
+ } else if solaris {
+ cfg.define("_XOPEN_SOURCE", Some("700"));
+ cfg.define("__EXTENSIONS__", None);
+ cfg.define("_LCONV_C99", None);
}
// Android doesn't actually have in_port_t but it's much easier if we
@@ -91,6 +97,9 @@ fn main() {
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/time.h");
cfg.header("sys/un.h");
cfg.header("sys/wait.h");
@@ -99,7 +108,9 @@ fn main() {
cfg.header("pwd.h");
cfg.header("grp.h");
cfg.header("sys/utsname.h");
- cfg.header("sys/ptrace.h");
+ if !solaris {
+ cfg.header("sys/ptrace.h");
+ }
cfg.header("sys/mount.h");
cfg.header("sys/uio.h");
cfg.header("sched.h");
@@ -128,18 +139,18 @@ fn main() {
cfg.header("ifaddrs.h");
cfg.header("langinfo.h");
- if !openbsd && !freebsd && !dragonfly {
+ if !openbsd && !freebsd && !dragonfly && !solaris {
cfg.header("sys/quota.h");
}
- if !musl {
+ if !musl && !x32 && !solaris {
cfg.header("sys/sysctl.h");
}
+
if !musl && !uclibc {
if !netbsd && !openbsd && !uclibc {
cfg.header("execinfo.h");
- cfg.header("xlocale.h");
}
if openbsd {
@@ -155,20 +166,24 @@ fn main() {
cfg.header("mach/mach_time.h");
cfg.header("malloc/malloc.h");
cfg.header("util.h");
+ cfg.header("xlocale.h");
cfg.header("sys/xattr.h");
cfg.header("sys/sys_domain.h");
+ cfg.header("net/if_utun.h");
+ cfg.header("net/bpf.h");
if target.starts_with("x86") {
cfg.header("crt_externs.h");
}
cfg.header("net/route.h");
- cfg.header("net/route.h");
+ cfg.header("netinet/if_ether.h");
cfg.header("sys/proc_info.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");
@@ -176,6 +191,7 @@ fn main() {
}
if linux || emscripten {
+ cfg.header("mntent.h");
cfg.header("mqueue.h");
cfg.header("ucontext.h");
if !uclibc {
@@ -187,7 +203,7 @@ fn main() {
cfg.header("sys/msg.h");
cfg.header("sys/shm.h");
cfg.header("sys/user.h");
- cfg.header("sys/fsuid.h");
+ cfg.header("sys/timerfd.h");
cfg.header("shadow.h");
if !emscripten {
cfg.header("linux/input.h");
@@ -222,6 +238,7 @@ fn main() {
cfg.header("sys/reboot.h");
if !emscripten {
cfg.header("linux/netfilter_ipv4.h");
+ cfg.header("linux/fs.h");
}
if !musl {
cfg.header("asm/mman.h");
@@ -235,7 +252,30 @@ fn main() {
}
}
+ if linux || android {
+ cfg.header("sys/fsuid.h");
+ cfg.header("linux/seccomp.h");
+ cfg.header("linux/if_ether.h");
+
+ // DCCP support
+ if !uclibc && !musl && !emscripten {
+ cfg.header("linux/dccp.h");
+ }
+
+ if !musl || mips {
+ cfg.header("linux/memfd.h");
+ }
+ }
+
+ if linux {
+ cfg.header("linux/random.h");
+ cfg.header("elf.h");
+ cfg.header("link.h");
+ cfg.header("linux/if_tun.h");
+ }
+
if freebsd {
+ cfg.header("mqueue.h");
cfg.header("pthread_np.h");
cfg.header("sched.h");
cfg.header("ufs/ufs/quota.h");
@@ -246,9 +286,13 @@ fn main() {
}
if netbsd {
+ cfg.header("mqueue.h");
cfg.header("ufs/ufs/quota.h");
cfg.header("ufs/ufs/quota1.h");
cfg.header("sys/ioctl_compat.h");
+
+ // DCCP support
+ cfg.header("netinet/dccp.h");
}
if openbsd {
@@ -258,11 +302,19 @@ fn main() {
}
if dragonfly {
+ cfg.header("mqueue.h");
cfg.header("ufs/ufs/quota.h");
cfg.header("pthread_np.h");
cfg.header("sys/ioctl_compat.h");
}
+ if solaris {
+ cfg.header("port.h");
+ cfg.header("ucontext.h");
+ cfg.header("sys/filio.h");
+ cfg.header("sys/loadavg.h");
+ }
+
if linux || freebsd || dragonfly || netbsd || apple || emscripten {
if !uclibc {
cfg.header("aio.h");
@@ -275,7 +327,9 @@ fn main() {
"FILE" |
"fd_set" |
"Dl_info" |
- "DIR" => ty.to_string(),
+ "DIR" |
+ "Elf32_Phdr" |
+ "Elf64_Phdr" => ty.to_string(),
// Fixup a few types on windows that don't actually exist.
"time64_t" if windows => "__time64_t".to_string(),
@@ -362,6 +416,10 @@ fn main() {
// 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,
+
_ => false
}
});
@@ -376,7 +434,9 @@ fn main() {
"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 || rumprun => true,
+ "sem_t" if openbsd || freebsd || dragonfly || netbsd => true,
+ // mqd_t is a pointer on FreeBSD and DragonFly
+ "mqd_t" if freebsd || dragonfly => true,
// windows-isms
n if n.starts_with("P") => true,
@@ -394,7 +454,10 @@ fn main() {
"FILE_ATTRIBUTE_INTEGRITY_STREAM" |
"ERROR_NOTHING_TO_TERMINATE" if mingw => true,
+ "SIG_DFL" |
+ "SIG_ERR" |
"SIG_IGN" => true, // sighandler_t weirdness
+ "SIGUNUSED" => true, // removed in glibc 2.26
// types on musl are defined a little differently
n if musl && n.contains("__SIZEOF_PTHREAD") => true,
@@ -416,12 +479,6 @@ fn main() {
"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,
-
// These constants were removed in FreeBSD 11 (svn r273250) but will
// still be accepted and ignored at runtime.
"MAP_RENAME" |
@@ -455,7 +512,12 @@ fn main() {
// Musl uses old, patched kernel headers
"FALLOC_FL_COLLAPSE_RANGE" | "FALLOC_FL_ZERO_RANGE" |
- "FALLOC_FL_INSERT_RANGE" | "FALLOC_FL_UNSHARE_RANGE" if musl => true,
+ "FALLOC_FL_INSERT_RANGE" | "FALLOC_FL_UNSHARE_RANGE" |
+ "RENAME_NOREPLACE" | "RENAME_EXCHANGE" | "RENAME_WHITEOUT" if musl => true,
+
+ // Both android and musl use old kernel headers
+ // These are constants used in getrandom syscall
+ "GRND_NONBLOCK" | "GRND_RANDOM" if musl || android => true,
// Defined by libattr not libc on linux (hard to test).
// See constant definition for more details.
@@ -477,6 +539,17 @@ fn main() {
// 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,
+
+ "MFD_CLOEXEC" | "MFD_ALLOW_SEALING" if !mips && musl => true,
+
+ "DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK" | "DT_SOCK" if solaris => true,
+ "USRQUOTA" | "GRPQUOTA" if solaris => true,
+ "PRIO_MIN" | "PRIO_MAX" if solaris => true,
+
+ // 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,
_ => false,
}
@@ -508,7 +581,7 @@ fn main() {
"getdtablesize" if android => true,
"dlerror" if android => true, // const-ness is added
- "dladdr" if musl => true, // const-ness only added recently
+ "dladdr" if musl || solaris => true, // const-ness only added recently
// OSX has 'struct tm *const' which we can't actually represent in
// Rust, but is close enough to *mut
@@ -529,6 +602,16 @@ fn main() {
"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,
@@ -594,11 +677,19 @@ fn main() {
// 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,
+ "setpriority" | "personality" if android || solaris => 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,
+ // signal is defined with sighandler_t, so ignore
+ "signal" if solaris => true,
+
+ "cfmakeraw" | "cfsetspeed" if solaris => true,
+
+ // FIXME: mincore is defined with caddr_t on Solaris.
+ "mincore" if solaris => true,
+
_ => false,
}
});
@@ -658,8 +749,7 @@ fn main() {
// fails on a lot of platforms.
let mut cfg = ctest::TestGenerator::new();
cfg.skip_type(|_| true)
- .skip_struct(|_| true)
- .skip_fn(|_| true);
+ .skip_fn(|_| true);
if android || linux {
// musl defines these directly in `fcntl.h`
if musl {
@@ -667,15 +757,33 @@ fn main() {
} 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| {
+ match ty {
+ t if is_struct => format!("struct {}", t),
+ t => t.to_string(),
+ }
+ });
} else {
cfg.skip_const(|_| true);
+ cfg.skip_struct(|_| true);
}
cfg.generate("../src/lib.rs", "linux_fcntl.rs");
}