Alex Crichton | b5da7c0 | 2015-09-16 17:44:40 -0700 | [diff] [blame] | 1 | #![deny(warnings)] |
| 2 | |
Alan Somers | 38cf5b1 | 2019-01-31 22:34:17 -0700 | [diff] [blame] | 3 | extern crate cc; |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 4 | extern crate ctest; |
Alex Crichton | 8e5f0cd | 2015-09-09 22:46:19 -0700 | [diff] [blame] | 5 | |
| 6 | use std::env; |
Alex Crichton | 8e5f0cd | 2015-09-09 22:46:19 -0700 | [diff] [blame] | 7 | |
Alan Somers | 38cf5b1 | 2019-01-31 22:34:17 -0700 | [diff] [blame] | 8 | #[cfg(unix)] |
| 9 | fn do_cc() { |
gnzlbg | 0a5484e | 2019-02-07 11:13:38 +0100 | [diff] [blame] | 10 | cc::Build::new().file("src/cmsg.c").compile("cmsg"); |
Alan Somers | 38cf5b1 | 2019-01-31 22:34:17 -0700 | [diff] [blame] | 11 | } |
| 12 | #[cfg(not(unix))] |
gnzlbg | 0a5484e | 2019-02-07 11:13:38 +0100 | [diff] [blame] | 13 | fn do_cc() {} |
Alan Somers | 38cf5b1 | 2019-01-31 22:34:17 -0700 | [diff] [blame] | 14 | |
| 15 | fn do_ctest() { |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 16 | let target = env::var("TARGET").unwrap(); |
Marco A L Barbosa | 92ce518 | 2017-02-23 18:15:02 -0300 | [diff] [blame] | 17 | let aarch64 = target.contains("aarch64"); |
Marcin Mielniczuk | 2a59767 | 2017-07-22 09:37:22 +0200 | [diff] [blame] | 18 | let i686 = target.contains("i686"); |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 19 | let x86_64 = target.contains("x86_64"); |
Marco A L Barbosa | 343b7c1 | 2017-10-18 12:08:36 -0200 | [diff] [blame] | 20 | let x32 = target.ends_with("gnux32"); |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 21 | let windows = target.contains("windows"); |
| 22 | let mingw = target.contains("windows-gnu"); |
Alex Crichton | cd9b33e | 2015-09-17 14:47:40 -0700 | [diff] [blame] | 23 | let linux = target.contains("unknown-linux"); |
Alex Crichton | 1ff9610 | 2015-09-17 15:09:02 -0700 | [diff] [blame] | 24 | let android = target.contains("android"); |
Alex Crichton | baef611 | 2015-09-19 23:20:53 -0700 | [diff] [blame] | 25 | let apple = target.contains("apple"); |
Alex Crichton | 83f78df | 2018-07-31 14:13:30 -0700 | [diff] [blame] | 26 | let ios = target.contains("apple-ios"); |
Alex Crichton | 22b98de | 2017-08-26 20:39:46 -0700 | [diff] [blame] | 27 | let emscripten = target.contains("asm"); |
| 28 | let musl = target.contains("musl") || emscripten; |
Kelvin Ly | 9a83558 | 2017-04-20 02:34:50 -0400 | [diff] [blame] | 29 | let uclibc = target.contains("uclibc"); |
Alex Crichton | a1b948e | 2015-09-18 11:54:32 -0700 | [diff] [blame] | 30 | let freebsd = target.contains("freebsd"); |
Michael Neumann | a6a64d1 | 2016-02-20 13:34:01 +0100 | [diff] [blame] | 31 | let dragonfly = target.contains("dragonfly"); |
Alexander Polakov | 26974c7 | 2015-11-27 03:02:44 +0300 | [diff] [blame] | 32 | let mips = target.contains("mips"); |
Alex Crichton | 49d7bca | 2015-11-27 09:40:37 -0800 | [diff] [blame] | 33 | let netbsd = target.contains("netbsd"); |
Sébastien Marie | c618f36 | 2015-12-21 17:26:41 +0100 | [diff] [blame] | 34 | let openbsd = target.contains("openbsd"); |
Alex Crichton | 49d7bca | 2015-11-27 09:40:37 -0800 | [diff] [blame] | 35 | let rumprun = target.contains("rumprun"); |
bgermann | b3870b4 | 2017-11-18 14:57:54 +0100 | [diff] [blame] | 36 | let solaris = target.contains("solaris"); |
Tom Parker-Shemilt | b758037 | 2018-11-23 21:21:24 +0000 | [diff] [blame] | 37 | let cloudabi = target.contains("cloudabi"); |
Tom Parker-Shemilt | d75fc9c | 2018-11-23 21:25:23 +0000 | [diff] [blame] | 38 | let redox = target.contains("redox"); |
Michael Neumann | a6a64d1 | 2016-02-20 13:34:01 +0100 | [diff] [blame] | 39 | let bsdlike = freebsd || apple || netbsd || openbsd || dragonfly; |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 40 | let mut cfg = ctest::TestGenerator::new(); |
Alex Crichton | 8e5f0cd | 2015-09-09 22:46:19 -0700 | [diff] [blame] | 41 | |
Tomasz Miąsko | c4947bb | 2016-07-21 07:27:21 +0200 | [diff] [blame] | 42 | // Pull in extra goodies |
Alex Crichton | 22b98de | 2017-08-26 20:39:46 -0700 | [diff] [blame] | 43 | if linux || android || emscripten { |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 44 | cfg.define("_GNU_SOURCE", None); |
Tomasz Miąsko | c4947bb | 2016-07-21 07:27:21 +0200 | [diff] [blame] | 45 | } else if netbsd { |
| 46 | cfg.define("_NETBSD_SOURCE", Some("1")); |
Jake McGinty | 0e3cf47 | 2018-04-22 15:09:20 -0700 | [diff] [blame] | 47 | } else if apple { |
| 48 | cfg.define("__APPLE_USE_RFC_3542", None); |
Alex Crichton | 1ff9610 | 2015-09-17 15:09:02 -0700 | [diff] [blame] | 49 | } else if windows { |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 50 | cfg.define("_WIN32_WINNT", Some("0x8000")); |
bgermann | b3870b4 | 2017-11-18 14:57:54 +0100 | [diff] [blame] | 51 | } else if solaris { |
bgermann | 85680dc | 2017-11-18 22:03:14 +0100 | [diff] [blame] | 52 | cfg.define("_XOPEN_SOURCE", Some("700")); |
| 53 | cfg.define("__EXTENSIONS__", None); |
| 54 | cfg.define("_LCONV_C99", None); |
Tom Parker-Shemilt | 9c6714e | 2018-11-20 23:50:37 +0000 | [diff] [blame] | 55 | } else if freebsd { |
| 56 | cfg.define("_WITH_GETLINE", None); |
Alex Crichton | 0df7c10 | 2015-09-10 16:35:37 -0700 | [diff] [blame] | 57 | } |
| 58 | |
Alex Crichton | 094f44d | 2015-09-16 16:27:23 -0700 | [diff] [blame] | 59 | // Android doesn't actually have in_port_t but it's much easier if we |
| 60 | // provide one for us to test against |
Alex Crichton | 1ff9610 | 2015-09-17 15:09:02 -0700 | [diff] [blame] | 61 | if android { |
Alex Crichton | 094f44d | 2015-09-16 16:27:23 -0700 | [diff] [blame] | 62 | cfg.define("in_port_t", Some("uint16_t")); |
| 63 | } |
| 64 | |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 65 | cfg.header("errno.h") |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 66 | .header("fcntl.h") |
| 67 | .header("limits.h") |
| 68 | .header("locale.h") |
| 69 | .header("stddef.h") |
| 70 | .header("stdint.h") |
| 71 | .header("stdio.h") |
| 72 | .header("stdlib.h") |
| 73 | .header("sys/stat.h") |
| 74 | .header("sys/types.h") |
| 75 | .header("time.h") |
| 76 | .header("wchar.h"); |
Alex Crichton | ac2bd85 | 2015-09-10 17:21:20 -0700 | [diff] [blame] | 77 | |
Alex Crichton | 1ff9610 | 2015-09-17 15:09:02 -0700 | [diff] [blame] | 78 | if windows { |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 79 | cfg.header("winsock2.h"); // must be before windows.h |
| 80 | |
| 81 | cfg.header("direct.h"); |
| 82 | cfg.header("io.h"); |
| 83 | cfg.header("sys/utime.h"); |
| 84 | cfg.header("windows.h"); |
| 85 | cfg.header("process.h"); |
| 86 | cfg.header("ws2ipdef.h"); |
Mackenzie Clark | 313483b | 2018-12-16 16:23:53 -0800 | [diff] [blame] | 87 | cfg.header("signal.h"); |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 88 | |
| 89 | if target.contains("gnu") { |
| 90 | cfg.header("ws2tcpip.h"); |
Alex Crichton | 310d623 | 2015-09-10 10:56:31 -0700 | [diff] [blame] | 91 | } |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 92 | } else { |
Knight | 0e0fb68 | 2016-08-09 13:59:40 +0800 | [diff] [blame] | 93 | cfg.flag("-Wno-deprecated-declarations"); |
| 94 | |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 95 | cfg.header("ctype.h"); |
| 96 | cfg.header("dirent.h"); |
Sébastien Marie | c618f36 | 2015-12-21 17:26:41 +0100 | [diff] [blame] | 97 | if openbsd { |
| 98 | cfg.header("sys/socket.h"); |
| 99 | } |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 100 | cfg.header("net/if.h"); |
Alex Crichton | 83f78df | 2018-07-31 14:13:30 -0700 | [diff] [blame] | 101 | if !ios { |
| 102 | cfg.header("net/route.h"); |
| 103 | cfg.header("net/if_arp.h"); |
| 104 | } |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 105 | cfg.header("netdb.h"); |
| 106 | cfg.header("netinet/in.h"); |
| 107 | cfg.header("netinet/ip.h"); |
| 108 | cfg.header("netinet/tcp.h"); |
Nicolas Dusart | 9f5766f | 2017-07-07 11:58:11 +0200 | [diff] [blame] | 109 | cfg.header("netinet/udp.h"); |
Jon Gjengset | ef20ddb | 2017-04-26 22:39:52 -0400 | [diff] [blame] | 110 | cfg.header("resolv.h"); |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 111 | cfg.header("pthread.h"); |
Alex Crichton | 1ff9610 | 2015-09-17 15:09:02 -0700 | [diff] [blame] | 112 | cfg.header("dlfcn.h"); |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 113 | cfg.header("signal.h"); |
| 114 | cfg.header("string.h"); |
| 115 | cfg.header("sys/file.h"); |
| 116 | cfg.header("sys/ioctl.h"); |
| 117 | cfg.header("sys/mman.h"); |
| 118 | cfg.header("sys/resource.h"); |
| 119 | cfg.header("sys/socket.h"); |
SilverWingedSeraph | 6f170ef | 2017-09-12 12:33:10 -0500 | [diff] [blame] | 120 | if linux && !musl { |
SilverWingedSeraph | 121795e | 2017-09-12 09:09:13 -0500 | [diff] [blame] | 121 | cfg.header("linux/if.h"); |
gnzlbg | c099bb9 | 2018-01-19 12:11:14 +0100 | [diff] [blame] | 122 | cfg.header("sys/auxv.h"); |
SilverWingedSeraph | 121795e | 2017-09-12 09:09:13 -0500 | [diff] [blame] | 123 | } |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 124 | cfg.header("sys/time.h"); |
| 125 | cfg.header("sys/un.h"); |
| 126 | cfg.header("sys/wait.h"); |
| 127 | cfg.header("unistd.h"); |
| 128 | cfg.header("utime.h"); |
Alex Crichton | cd9b33e | 2015-09-17 14:47:40 -0700 | [diff] [blame] | 129 | cfg.header("pwd.h"); |
| 130 | cfg.header("grp.h"); |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 131 | cfg.header("sys/utsname.h"); |
Alex Crichton | 83f78df | 2018-07-31 14:13:30 -0700 | [diff] [blame] | 132 | if !solaris && !ios { |
bgermann | b3870b4 | 2017-11-18 14:57:54 +0100 | [diff] [blame] | 133 | cfg.header("sys/ptrace.h"); |
| 134 | } |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 135 | cfg.header("sys/mount.h"); |
| 136 | cfg.header("sys/uio.h"); |
| 137 | cfg.header("sched.h"); |
| 138 | cfg.header("termios.h"); |
David Henningsson | 9d2493e | 2015-12-25 22:06:44 +0100 | [diff] [blame] | 139 | cfg.header("poll.h"); |
Raphael Cohn | 7fc0969 | 2016-05-05 15:41:21 +0100 | [diff] [blame] | 140 | cfg.header("syslog.h"); |
Steven Fackler | 41699f7 | 2016-06-03 21:02:56 -0700 | [diff] [blame] | 141 | cfg.header("semaphore.h"); |
Marco A L Barbosa | bad80ba | 2017-02-21 16:58:03 -0300 | [diff] [blame] | 142 | cfg.header("sys/statvfs.h"); |
Andrew Salmon | 6fb7c90 | 2017-05-26 15:24:54 -0700 | [diff] [blame] | 143 | cfg.header("sys/times.h"); |
Alex Crichton | cd9b33e | 2015-09-17 14:47:40 -0700 | [diff] [blame] | 144 | } |
Alex Crichton | a1b948e | 2015-09-18 11:54:32 -0700 | [diff] [blame] | 145 | |
| 146 | if android { |
Marco A L Barbosa | 3ca6ad9 | 2017-04-19 11:04:14 -0300 | [diff] [blame] | 147 | if !aarch64 && !x86_64 { |
| 148 | // time64_t is not define for aarch64 and x86_64 |
Marco A L Barbosa | 92ce518 | 2017-02-23 18:15:02 -0300 | [diff] [blame] | 149 | // If included it will generate the error 'Your time_t is already 64-bit' |
| 150 | cfg.header("time64.h"); |
| 151 | } |
Alex Crichton | a1b948e | 2015-09-18 11:54:32 -0700 | [diff] [blame] | 152 | cfg.header("arpa/inet.h"); |
A.J. Gardner | 24c84f1 | 2016-03-31 20:08:03 -0500 | [diff] [blame] | 153 | cfg.header("xlocale.h"); |
Knight | a6b283b | 2016-07-27 19:42:36 +0800 | [diff] [blame] | 154 | cfg.header("utmp.h"); |
Bastian Köcher | 6a6dc86 | 2018-05-26 08:59:30 +0200 | [diff] [blame] | 155 | cfg.header("ifaddrs.h"); |
Marcin Mielniczuk | b9166f4 | 2017-08-01 16:20:13 +0200 | [diff] [blame] | 156 | if i686 || x86_64 { |
| 157 | cfg.header("sys/reg.h"); |
| 158 | } |
Alex Crichton | a1b948e | 2015-09-18 11:54:32 -0700 | [diff] [blame] | 159 | } else if !windows { |
| 160 | cfg.header("glob.h"); |
| 161 | cfg.header("ifaddrs.h"); |
A.J. Gardner | 24c84f1 | 2016-03-31 20:08:03 -0500 | [diff] [blame] | 162 | cfg.header("langinfo.h"); |
Alex Crichton | bb6f198 | 2016-01-18 11:18:22 -0800 | [diff] [blame] | 163 | |
bgermann | b3870b4 | 2017-11-18 14:57:54 +0100 | [diff] [blame] | 164 | if !openbsd && !freebsd && !dragonfly && !solaris { |
Sébastien Marie | c618f36 | 2015-12-21 17:26:41 +0100 | [diff] [blame] | 165 | cfg.header("sys/quota.h"); |
| 166 | } |
Alex Crichton | a1b948e | 2015-09-18 11:54:32 -0700 | [diff] [blame] | 167 | |
bgermann | b3870b4 | 2017-11-18 14:57:54 +0100 | [diff] [blame] | 168 | if !musl && !x32 && !solaris { |
Alex Crichton | a1b948e | 2015-09-18 11:54:32 -0700 | [diff] [blame] | 169 | cfg.header("sys/sysctl.h"); |
Kelvin Ly | 26670c7 | 2017-04-21 18:20:02 -0400 | [diff] [blame] | 170 | } |
Marco A L Barbosa | 343b7c1 | 2017-10-18 12:08:36 -0200 | [diff] [blame] | 171 | |
Kelvin Ly | 26670c7 | 2017-04-21 18:20:02 -0400 | [diff] [blame] | 172 | if !musl && !uclibc { |
Kelvin Ly | 9a83558 | 2017-04-20 02:34:50 -0400 | [diff] [blame] | 173 | if !netbsd && !openbsd && !uclibc { |
Alex Crichton | 49d7bca | 2015-11-27 09:40:37 -0800 | [diff] [blame] | 174 | cfg.header("execinfo.h"); |
| 175 | } |
Knight | a6b283b | 2016-07-27 19:42:36 +0800 | [diff] [blame] | 176 | |
| 177 | if openbsd { |
| 178 | cfg.header("utmp.h"); |
| 179 | } else { |
| 180 | cfg.header("utmpx.h"); |
| 181 | } |
Alex Crichton | a1b948e | 2015-09-18 11:54:32 -0700 | [diff] [blame] | 182 | } |
| 183 | } |
| 184 | |
Alex Crichton | baef611 | 2015-09-19 23:20:53 -0700 | [diff] [blame] | 185 | if apple { |
Alex Crichton | 4621a34 | 2018-01-25 16:19:35 -0800 | [diff] [blame] | 186 | cfg.header("spawn.h"); |
Alex Crichton | a1b948e | 2015-09-18 11:54:32 -0700 | [diff] [blame] | 187 | cfg.header("mach-o/dyld.h"); |
| 188 | cfg.header("mach/mach_time.h"); |
| 189 | cfg.header("malloc/malloc.h"); |
Kamal Marhubi | 89a7700 | 2016-02-27 14:58:43 -0500 | [diff] [blame] | 190 | cfg.header("util.h"); |
Vojtech Kral | 4ed612c | 2017-10-09 18:36:52 +0200 | [diff] [blame] | 191 | cfg.header("xlocale.h"); |
Lee Bousfield | fdbfe8f | 2017-05-07 15:40:15 -0600 | [diff] [blame] | 192 | cfg.header("sys/xattr.h"); |
Alex Crichton | 83f78df | 2018-07-31 14:13:30 -0700 | [diff] [blame] | 193 | if target.starts_with("x86") && !ios { |
Alex Crichton | baef611 | 2015-09-19 23:20:53 -0700 | [diff] [blame] | 194 | cfg.header("crt_externs.h"); |
| 195 | } |
Jake McGinty | 0e3cf47 | 2018-04-22 15:09:20 -0700 | [diff] [blame] | 196 | cfg.header("netinet/in.h"); |
gnzlbg | 53e4733 | 2018-02-02 17:07:12 +0100 | [diff] [blame] | 197 | cfg.header("sys/ipc.h"); |
Craig M. Brandenburg | 6d22f54 | 2018-12-02 09:10:10 -0700 | [diff] [blame] | 198 | cfg.header("sys/sem.h"); |
gnzlbg | 53e4733 | 2018-02-02 17:07:12 +0100 | [diff] [blame] | 199 | cfg.header("sys/shm.h"); |
Alex Crichton | 83f78df | 2018-07-31 14:13:30 -0700 | [diff] [blame] | 200 | |
| 201 | if !ios { |
| 202 | cfg.header("sys/sys_domain.h"); |
| 203 | cfg.header("net/if_utun.h"); |
| 204 | cfg.header("net/bpf.h"); |
| 205 | cfg.header("net/route.h"); |
| 206 | cfg.header("netinet/if_ether.h"); |
| 207 | cfg.header("sys/proc_info.h"); |
| 208 | cfg.header("sys/kern_control.h"); |
| 209 | } |
Alex Crichton | a1b948e | 2015-09-18 11:54:32 -0700 | [diff] [blame] | 210 | } |
| 211 | |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 212 | if bsdlike { |
| 213 | cfg.header("sys/event.h"); |
luozijun | 789fd5e | 2017-12-12 11:24:00 +0800 | [diff] [blame] | 214 | cfg.header("net/if_dl.h"); |
Kamal Marhubi | 9c4af10 | 2016-02-27 14:58:43 -0500 | [diff] [blame] | 215 | if freebsd { |
luozijun | 536b5cf | 2017-12-26 16:02:17 +0800 | [diff] [blame] | 216 | cfg.header("net/bpf.h"); |
Kamal Marhubi | 9c4af10 | 2016-02-27 14:58:43 -0500 | [diff] [blame] | 217 | cfg.header("libutil.h"); |
| 218 | } else { |
| 219 | cfg.header("util.h"); |
| 220 | } |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 221 | } |
| 222 | |
Alex Crichton | 22b98de | 2017-08-26 20:39:46 -0700 | [diff] [blame] | 223 | if linux || emscripten { |
Kelsey Z | 586867d | 2018-01-11 20:15:51 +1300 | [diff] [blame] | 224 | cfg.header("mntent.h"); |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 225 | cfg.header("mqueue.h"); |
Philipp Matthias Schaefer | 7e3a151 | 2016-02-22 20:11:01 +0100 | [diff] [blame] | 226 | cfg.header("ucontext.h"); |
Kelvin Ly | 26670c7 | 2017-04-21 18:20:02 -0400 | [diff] [blame] | 227 | if !uclibc { |
| 228 | // optionally included in uclibc |
| 229 | cfg.header("sys/xattr.h"); |
| 230 | } |
Alexander Polakov | 5850156 | 2015-12-14 02:09:45 +0300 | [diff] [blame] | 231 | cfg.header("sys/ipc.h"); |
Andrew Salmon | bc48202 | 2017-05-26 12:47:53 -0700 | [diff] [blame] | 232 | cfg.header("sys/sem.h"); |
Alexander Schlarb | 7590565 | 2016-09-17 22:17:17 +0200 | [diff] [blame] | 233 | cfg.header("sys/msg.h"); |
Alexander Polakov | 5850156 | 2015-12-14 02:09:45 +0300 | [diff] [blame] | 234 | cfg.header("sys/shm.h"); |
Daniel McKenna | 6acbf87 | 2017-05-29 18:27:27 +0100 | [diff] [blame] | 235 | cfg.header("sys/user.h"); |
slyrz | 340cbbf | 2017-09-09 13:02:29 +0200 | [diff] [blame] | 236 | cfg.header("sys/timerfd.h"); |
Philipp Keller | 04d0b71 | 2016-09-27 07:19:17 +0200 | [diff] [blame] | 237 | cfg.header("shadow.h"); |
Alex Crichton | 22b98de | 2017-08-26 20:39:46 -0700 | [diff] [blame] | 238 | if !emscripten { |
| 239 | cfg.header("linux/input.h"); |
| 240 | cfg.header("linux/falloc.h"); |
| 241 | } |
Andrew Salmon | 553c5dc | 2017-06-07 19:27:14 -0700 | [diff] [blame] | 242 | if x86_64 { |
| 243 | cfg.header("sys/io.h"); |
| 244 | } |
Marcin Mielniczuk | 2a59767 | 2017-07-22 09:37:22 +0200 | [diff] [blame] | 245 | if i686 || x86_64 { |
Marcin Mielniczuk | 37b4e73 | 2017-07-21 21:55:47 +0200 | [diff] [blame] | 246 | cfg.header("sys/reg.h"); |
| 247 | } |
Alexander Polakov | 30baed0 | 2015-12-01 15:29:05 +0300 | [diff] [blame] | 248 | } |
Bryant Mairs | 46933f0 | 2018-01-14 20:44:34 -0800 | [diff] [blame] | 249 | |
Alex Crichton | 22b98de | 2017-08-26 20:39:46 -0700 | [diff] [blame] | 250 | if linux || android || emscripten { |
Alex Crichton | a1b948e | 2015-09-18 11:54:32 -0700 | [diff] [blame] | 251 | cfg.header("malloc.h"); |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 252 | cfg.header("net/ethernet.h"); |
| 253 | cfg.header("netpacket/packet.h"); |
| 254 | cfg.header("sched.h"); |
| 255 | cfg.header("sys/epoll.h"); |
| 256 | cfg.header("sys/eventfd.h"); |
Alex Crichton | cd9b33e | 2015-09-17 14:47:40 -0700 | [diff] [blame] | 257 | cfg.header("sys/prctl.h"); |
Kamal Marhubi | 143358b | 2016-02-04 14:08:50 -0500 | [diff] [blame] | 258 | cfg.header("sys/sendfile.h"); |
Bryant Mairs | 83ab9a3 | 2017-07-16 22:49:28 -0700 | [diff] [blame] | 259 | cfg.header("sys/signalfd.h"); |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 260 | cfg.header("sys/vfs.h"); |
Alex Crichton | 881ef9b | 2015-12-01 09:04:13 -0800 | [diff] [blame] | 261 | cfg.header("sys/syscall.h"); |
Andrew Salmon | c98b9f7 | 2017-06-07 16:26:42 -0700 | [diff] [blame] | 262 | cfg.header("sys/personality.h"); |
| 263 | cfg.header("sys/swap.h"); |
Nicolas Dusart | 4abc3ce | 2017-06-29 21:25:55 +0200 | [diff] [blame] | 264 | cfg.header("pty.h"); |
Kelvin Ly | 9a83558 | 2017-04-20 02:34:50 -0400 | [diff] [blame] | 265 | if !uclibc { |
| 266 | cfg.header("sys/sysinfo.h"); |
| 267 | } |
Sergey Bugaev | a98c983 | 2016-07-12 13:22:51 +0300 | [diff] [blame] | 268 | cfg.header("sys/reboot.h"); |
Alex Crichton | 305cec3 | 2017-08-27 09:07:18 -0700 | [diff] [blame] | 269 | if !emscripten { |
Andrew Cann | b02c6a3 | 2018-05-30 18:08:28 +0800 | [diff] [blame] | 270 | cfg.header("linux/sockios.h"); |
Linus Färnstrand | 69ae346 | 2018-02-22 14:52:46 +0100 | [diff] [blame] | 271 | cfg.header("linux/netlink.h"); |
| 272 | cfg.header("linux/genetlink.h"); |
Alex Crichton | 305cec3 | 2017-08-27 09:07:18 -0700 | [diff] [blame] | 273 | cfg.header("linux/netfilter_ipv4.h"); |
Linus Färnstrand | 750fcf5 | 2018-02-25 22:41:50 +0100 | [diff] [blame] | 274 | cfg.header("linux/netfilter_ipv6.h"); |
Joerg Thalheim | 8c24117 | 2017-10-16 17:12:16 +0100 | [diff] [blame] | 275 | cfg.header("linux/fs.h"); |
Alex Crichton | 305cec3 | 2017-08-27 09:07:18 -0700 | [diff] [blame] | 276 | } |
Alexander Polakov | 420f2e4 | 2015-11-11 01:53:39 +0300 | [diff] [blame] | 277 | if !musl { |
Alex Crichton | 22b98de | 2017-08-26 20:39:46 -0700 | [diff] [blame] | 278 | cfg.header("asm/mman.h"); |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 279 | cfg.header("linux/magic.h"); |
Sergey Bugaev | a98c983 | 2016-07-12 13:22:51 +0300 | [diff] [blame] | 280 | cfg.header("linux/reboot.h"); |
Linus Färnstrand | 4d5ed47 | 2018-01-30 14:30:21 +0100 | [diff] [blame] | 281 | cfg.header("linux/netfilter/nf_tables.h"); |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 282 | |
| 283 | if !mips { |
| 284 | cfg.header("linux/quota.h"); |
| 285 | } |
Alexander Polakov | 420f2e4 | 2015-11-11 01:53:39 +0300 | [diff] [blame] | 286 | } |
Alex Crichton | 310d623 | 2015-09-10 10:56:31 -0700 | [diff] [blame] | 287 | } |
neirac | 3092748 | 2018-01-11 15:25:00 +0000 | [diff] [blame] | 288 | if solaris { |
| 289 | cfg.header("sys/epoll.h"); |
Linus Färnstrand | 4d5ed47 | 2018-01-30 14:30:21 +0100 | [diff] [blame] | 290 | } |
Alex Crichton | 310d623 | 2015-09-10 10:56:31 -0700 | [diff] [blame] | 291 | |
Jack Pappas | 787addf | 2017-09-18 21:41:34 -0400 | [diff] [blame] | 292 | if linux || android { |
Joerg Thalheim | 3406fe9 | 2017-10-12 17:41:17 +0100 | [diff] [blame] | 293 | cfg.header("sys/fsuid.h"); |
Pascal Bach | ebe0feb | 2018-07-16 20:24:50 +0200 | [diff] [blame] | 294 | cfg.header("linux/module.h"); |
Jörg Thalheim | 9f720f3 | 2017-12-19 09:11:33 +0000 | [diff] [blame] | 295 | cfg.header("linux/seccomp.h"); |
luozijun | 5ea536a | 2017-12-25 07:55:58 +0800 | [diff] [blame] | 296 | cfg.header("linux/if_ether.h"); |
luozijun | 0f4ae0b | 2018-02-04 21:39:40 +0800 | [diff] [blame] | 297 | cfg.header("linux/if_tun.h"); |
Gerd Zellweger | 2f83a7a | 2018-10-24 10:02:26 -0700 | [diff] [blame] | 298 | cfg.header("linux/net_tstamp.h"); |
Vincent Dagonneau | dfb7c0c | 2019-02-04 09:11:21 +0100 | [diff] [blame] | 299 | cfg.header("sys/inotify.h"); |
Vincent Dagonneau | eb3e48c | 2019-01-28 19:41:29 +0100 | [diff] [blame] | 300 | |
Jack Pappas | 787addf | 2017-09-18 21:41:34 -0400 | [diff] [blame] | 301 | // DCCP support |
| 302 | if !uclibc && !musl && !emscripten { |
| 303 | cfg.header("linux/dccp.h"); |
| 304 | } |
Bryant Mairs | c0935ac | 2017-11-05 13:13:35 -0800 | [diff] [blame] | 305 | |
| 306 | if !musl || mips { |
| 307 | cfg.header("linux/memfd.h"); |
| 308 | } |
Jack Pappas | 787addf | 2017-09-18 21:41:34 -0400 | [diff] [blame] | 309 | } |
| 310 | |
Marco A L Barbosa | ae49626 | 2017-11-01 18:41:58 -0200 | [diff] [blame] | 311 | if linux { |
| 312 | cfg.header("linux/random.h"); |
Steven Fackler | 8f7839f | 2017-11-10 19:58:04 -0800 | [diff] [blame] | 313 | cfg.header("elf.h"); |
| 314 | cfg.header("link.h"); |
Alex Crichton | 4621a34 | 2018-01-25 16:19:35 -0800 | [diff] [blame] | 315 | cfg.header("spawn.h"); |
Marco A L Barbosa | ae49626 | 2017-11-01 18:41:58 -0200 | [diff] [blame] | 316 | } |
| 317 | |
Alex Crichton | a1b948e | 2015-09-18 11:54:32 -0700 | [diff] [blame] | 318 | if freebsd { |
Alan Somers | 831ca99 | 2017-12-13 20:49:17 -0700 | [diff] [blame] | 319 | cfg.header("mqueue.h"); |
Alex Crichton | a1b948e | 2015-09-18 11:54:32 -0700 | [diff] [blame] | 320 | cfg.header("pthread_np.h"); |
Alexander Polakov | 26974c7 | 2015-11-27 03:02:44 +0300 | [diff] [blame] | 321 | cfg.header("sched.h"); |
Alex Crichton | bb6f198 | 2016-01-18 11:18:22 -0800 | [diff] [blame] | 322 | cfg.header("ufs/ufs/quota.h"); |
Alan Somers | cd35cda | 2018-10-30 14:04:04 -0600 | [diff] [blame] | 323 | cfg.header("sys/extattr.h"); |
Ryan Moeller | 7c03711 | 2017-02-21 00:41:12 +0000 | [diff] [blame] | 324 | cfg.header("sys/jail.h"); |
superriva | 2122616 | 2017-03-28 12:30:53 +0300 | [diff] [blame] | 325 | cfg.header("sys/ipc.h"); |
| 326 | cfg.header("sys/msg.h"); |
| 327 | cfg.header("sys/shm.h"); |
Greg V | 6725fd6 | 2018-01-04 02:40:12 +0300 | [diff] [blame] | 328 | cfg.header("sys/procdesc.h"); |
Greg V | c13302d | 2018-01-22 19:44:59 +0300 | [diff] [blame] | 329 | cfg.header("sys/rtprio.h"); |
Bryan Drewery | 92d50c9 | 2018-02-26 16:36:13 -0800 | [diff] [blame] | 330 | cfg.header("spawn.h"); |
Alex Crichton | a1b948e | 2015-09-18 11:54:32 -0700 | [diff] [blame] | 331 | } |
| 332 | |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 333 | if netbsd { |
Alan Somers | 831ca99 | 2017-12-13 20:49:17 -0700 | [diff] [blame] | 334 | cfg.header("mqueue.h"); |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 335 | cfg.header("ufs/ufs/quota.h"); |
| 336 | cfg.header("ufs/ufs/quota1.h"); |
Alan Somers | cd35cda | 2018-10-30 14:04:04 -0600 | [diff] [blame] | 337 | cfg.header("sys/extattr.h"); |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 338 | cfg.header("sys/ioctl_compat.h"); |
Jack Pappas | 787addf | 2017-09-18 21:41:34 -0400 | [diff] [blame] | 339 | |
| 340 | // DCCP support |
| 341 | cfg.header("netinet/dccp.h"); |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 342 | } |
| 343 | |
Sébastien Marie | c618f36 | 2015-12-21 17:26:41 +0100 | [diff] [blame] | 344 | if openbsd { |
| 345 | cfg.header("ufs/ufs/quota.h"); |
Sébastien Marie | c618f36 | 2015-12-21 17:26:41 +0100 | [diff] [blame] | 346 | cfg.header("pthread_np.h"); |
| 347 | cfg.header("sys/syscall.h"); |
| 348 | } |
| 349 | |
Michael Neumann | a6a64d1 | 2016-02-20 13:34:01 +0100 | [diff] [blame] | 350 | if dragonfly { |
Alan Somers | 831ca99 | 2017-12-13 20:49:17 -0700 | [diff] [blame] | 351 | cfg.header("mqueue.h"); |
Michael Neumann | a6a64d1 | 2016-02-20 13:34:01 +0100 | [diff] [blame] | 352 | cfg.header("ufs/ufs/quota.h"); |
| 353 | cfg.header("pthread_np.h"); |
Greg V | c13302d | 2018-01-22 19:44:59 +0300 | [diff] [blame] | 354 | cfg.header("sys/rtprio.h"); |
Michael Neumann | a6a64d1 | 2016-02-20 13:34:01 +0100 | [diff] [blame] | 355 | } |
| 356 | |
bgermann | b3870b4 | 2017-11-18 14:57:54 +0100 | [diff] [blame] | 357 | if solaris { |
| 358 | cfg.header("port.h"); |
| 359 | cfg.header("ucontext.h"); |
| 360 | cfg.header("sys/filio.h"); |
| 361 | cfg.header("sys/loadavg.h"); |
| 362 | } |
| 363 | |
Alex Crichton | 22b98de | 2017-08-26 20:39:46 -0700 | [diff] [blame] | 364 | if linux || freebsd || dragonfly || netbsd || apple || emscripten { |
Kelvin Ly | 9a83558 | 2017-04-20 02:34:50 -0400 | [diff] [blame] | 365 | if !uclibc { |
| 366 | cfg.header("aio.h"); |
| 367 | } |
Alan Somers | 4ec884a | 2016-11-13 08:07:45 -0700 | [diff] [blame] | 368 | } |
| 369 | |
Tom Parker-Shemilt | d75fc9c | 2018-11-23 21:25:23 +0000 | [diff] [blame] | 370 | if cloudabi || redox { |
Tom Parker-Shemilt | b758037 | 2018-11-23 21:21:24 +0000 | [diff] [blame] | 371 | cfg.header("strings.h"); |
| 372 | } |
| 373 | |
alesharik | 5ec8699 | 2018-07-13 02:06:08 +0300 | [diff] [blame] | 374 | cfg.type_name(move |ty, is_struct, is_union| { |
Alex Crichton | 310d623 | 2015-09-10 10:56:31 -0700 | [diff] [blame] | 375 | match ty { |
Alex Crichton | 3150484 | 2015-09-10 23:43:41 -0700 | [diff] [blame] | 376 | // Just pass all these through, no need for a "struct" prefix |
gnzlbg | 5c1a6b8 | 2018-11-21 20:34:50 +0100 | [diff] [blame] | 377 | "FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" |
| 378 | | "Elf64_Phdr" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym" |
| 379 | | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr" |
| 380 | | "Elf64_Chdr" => ty.to_string(), |
Alex Crichton | cd9b33e | 2015-09-17 14:47:40 -0700 | [diff] [blame] | 381 | |
| 382 | // Fixup a few types on windows that don't actually exist. |
| 383 | "time64_t" if windows => "__time64_t".to_string(), |
| 384 | "ssize_t" if windows => "SSIZE_T".to_string(), |
gnzlbg | 0a5484e | 2019-02-07 11:13:38 +0100 | [diff] [blame] | 385 | // windows |
Mackenzie Clark | af19934 | 2018-12-17 18:46:48 -0800 | [diff] [blame] | 386 | "sighandler_t" if windows && !mingw => "_crt_signal_t".to_string(), |
| 387 | "sighandler_t" if windows && mingw => "__p_sig_fn_t".to_string(), |
Alex Crichton | de9736d | 2015-09-17 15:47:44 -0700 | [diff] [blame] | 388 | // OSX calls this something else |
Alex Crichton | a1b948e | 2015-09-18 11:54:32 -0700 | [diff] [blame] | 389 | "sighandler_t" if bsdlike => "sig_t".to_string(), |
Alex Crichton | de9736d | 2015-09-17 15:47:44 -0700 | [diff] [blame] | 390 | |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 391 | t if is_union => format!("union {}", t), |
alesharik | 5ec8699 | 2018-07-13 02:06:08 +0300 | [diff] [blame] | 392 | |
Alex Crichton | cd9b33e | 2015-09-17 14:47:40 -0700 | [diff] [blame] | 393 | t if t.ends_with("_t") => t.to_string(), |
Alex Crichton | 310d623 | 2015-09-10 10:56:31 -0700 | [diff] [blame] | 394 | |
Alex Crichton | 3150484 | 2015-09-10 23:43:41 -0700 | [diff] [blame] | 395 | // Windows uppercase structs don't have `struct` in front, there's a |
| 396 | // few special cases for windows, and then otherwise put `struct` in |
| 397 | // front of everything. |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 398 | t if is_struct => { |
Alex Crichton | 13a6f2d | 2015-09-10 18:10:58 -0700 | [diff] [blame] | 399 | if windows && ty.chars().next().unwrap().is_uppercase() { |
| 400 | t.to_string() |
| 401 | } else if windows && t == "stat" { |
| 402 | "struct __stat64".to_string() |
Alex Crichton | 7da9b10 | 2015-09-10 20:57:14 -0700 | [diff] [blame] | 403 | } else if windows && t == "utimbuf" { |
| 404 | "struct __utimbuf64".to_string() |
Alex Crichton | 13a6f2d | 2015-09-10 18:10:58 -0700 | [diff] [blame] | 405 | } else { |
| 406 | format!("struct {}", t) |
| 407 | } |
| 408 | } |
Alex Crichton | 310d623 | 2015-09-10 10:56:31 -0700 | [diff] [blame] | 409 | |
| 410 | t => t.to_string(), |
| 411 | } |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 412 | }); |
Alex Crichton | 310d623 | 2015-09-10 10:56:31 -0700 | [diff] [blame] | 413 | |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 414 | let target2 = target.clone(); |
| 415 | cfg.field_name(move |struct_, field| { |
Alex Crichton | 310d623 | 2015-09-10 10:56:31 -0700 | [diff] [blame] | 416 | match field { |
gnzlbg | 5c1a6b8 | 2018-11-21 20:34:50 +0100 | [diff] [blame] | 417 | "st_birthtime" if openbsd && struct_ == "stat" => { |
| 418 | "__st_birthtime".to_string() |
| 419 | } |
| 420 | "st_birthtime_nsec" if openbsd && struct_ == "stat" => { |
| 421 | "__st_birthtimensec".to_string() |
| 422 | } |
Alex Crichton | 3150484 | 2015-09-10 23:43:41 -0700 | [diff] [blame] | 423 | // Our stat *_nsec fields normally don't actually exist but are part |
| 424 | // of a timeval struct |
Alex Crichton | 7482522 | 2015-10-29 17:36:55 -0700 | [diff] [blame] | 425 | s if s.ends_with("_nsec") && struct_.starts_with("stat") => { |
Alex Crichton | baef611 | 2015-09-19 23:20:53 -0700 | [diff] [blame] | 426 | if target2.contains("apple") { |
Alex Crichton | 310d623 | 2015-09-10 10:56:31 -0700 | [diff] [blame] | 427 | s.replace("_nsec", "spec.tv_nsec") |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 428 | } else if target2.contains("android") { |
Alex Crichton | d3d7792 | 2015-09-11 17:03:39 -0700 | [diff] [blame] | 429 | s.to_string() |
Alex Crichton | 310d623 | 2015-09-10 10:56:31 -0700 | [diff] [blame] | 430 | } else { |
| 431 | s.replace("e_nsec", ".tv_nsec") |
| 432 | } |
| 433 | } |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 434 | "u64" if struct_ == "epoll_event" => "data.u64".to_string(), |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 435 | "type_" |
| 436 | if (linux || freebsd || dragonfly) |
| 437 | && (struct_ == "input_event" |
| 438 | || struct_ == "input_mask" |
| 439 | || struct_ == "ff_effect" |
| 440 | || struct_ == "rtprio") => |
| 441 | { |
| 442 | "type".to_string() |
| 443 | } |
Alex Crichton | 310d623 | 2015-09-10 10:56:31 -0700 | [diff] [blame] | 444 | s => s.to_string(), |
| 445 | } |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 446 | }); |
Alex Crichton | 310d623 | 2015-09-10 10:56:31 -0700 | [diff] [blame] | 447 | |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 448 | cfg.skip_type(move |ty| { |
Alex Crichton | 310d623 | 2015-09-10 10:56:31 -0700 | [diff] [blame] | 449 | match ty { |
Alex Crichton | d3d7792 | 2015-09-11 17:03:39 -0700 | [diff] [blame] | 450 | // sighandler_t is crazy across platforms |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 451 | "sighandler_t" => true, |
Alex Crichton | d3d7792 | 2015-09-11 17:03:39 -0700 | [diff] [blame] | 452 | |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 453 | _ => false, |
Alex Crichton | 310d623 | 2015-09-10 10:56:31 -0700 | [diff] [blame] | 454 | } |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 455 | }); |
Alex Crichton | 1608306 | 2015-09-09 22:59:24 -0700 | [diff] [blame] | 456 | |
Alexander Polakov | 420f2e4 | 2015-11-11 01:53:39 +0300 | [diff] [blame] | 457 | cfg.skip_struct(move |ty| { |
| 458 | match ty { |
| 459 | "sockaddr_nl" => musl, |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 460 | |
Knight | 866c9e4 | 2016-08-09 14:01:33 +0800 | [diff] [blame] | 461 | // On Linux, the type of `ut_tv` field of `struct utmpx` |
| 462 | // can be an anonymous struct, so an extra struct, |
| 463 | // which is absent in glibc, has to be defined. |
| 464 | "__timeval" if linux => true, |
| 465 | |
Alex Crichton | 91bd079 | 2018-11-19 22:14:05 -0800 | [diff] [blame] | 466 | // Fixed on feature=align with repr(packed(4)) |
gnzlbg | dfee17f | 2018-04-15 14:50:00 +0200 | [diff] [blame] | 467 | // Once repr_packed stabilizes we can fix this unconditionally |
| 468 | // and remove this check. |
Craig M. Brandenburg | 6d22f54 | 2018-12-02 09:10:10 -0700 | [diff] [blame] | 469 | "kevent" | "shmid_ds" | "semid_ds" if apple && x86_64 => true, |
gnzlbg | dfee17f | 2018-04-15 14:50:00 +0200 | [diff] [blame] | 470 | |
Alan Somers | 9245e07 | 2016-11-13 13:52:34 -0700 | [diff] [blame] | 471 | // This is actually a union, not a struct |
| 472 | "sigval" => true, |
| 473 | |
Mateusz Sieczko | 60d9322 | 2017-06-13 17:26:14 +0200 | [diff] [blame] | 474 | // Linux kernel headers used on musl are too old to have this |
| 475 | // definition. Because it's tested on other Linux targets, skip it. |
| 476 | "input_mask" if musl => true, |
| 477 | |
Nicolas Dusart | 4abc3ce | 2017-06-29 21:25:55 +0200 | [diff] [blame] | 478 | // These structs have changed since unified headers in NDK r14b. |
| 479 | // `st_atime` and `st_atime_nsec` have changed sign. |
| 480 | // FIXME: unskip it for next major release |
| 481 | "stat" | "stat64" if android => true, |
| 482 | |
Bryant Mairs | 6d55c24 | 2017-10-18 18:55:41 -0700 | [diff] [blame] | 483 | // These are tested as part of the linux_fcntl tests since there are |
| 484 | // header conflicts when including them with all the other structs. |
| 485 | "termios2" => true, |
| 486 | |
Alex Crichton | 83f78df | 2018-07-31 14:13:30 -0700 | [diff] [blame] | 487 | // Present on historical versions of iOS but missing in more recent |
| 488 | // SDKs |
gnzlbg | 5c1a6b8 | 2018-11-21 20:34:50 +0100 | [diff] [blame] | 489 | "bpf_hdr" | "proc_taskinfo" | "proc_taskallinfo" |
| 490 | | "proc_bsdinfo" | "proc_threadinfo" | "sockaddr_inarp" |
| 491 | | "sockaddr_ctl" | "arphdr" |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 492 | if ios => |
| 493 | { |
| 494 | true |
| 495 | } |
Alex Crichton | 83f78df | 2018-07-31 14:13:30 -0700 | [diff] [blame] | 496 | |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 497 | _ => false, |
Alexander Polakov | 420f2e4 | 2015-11-11 01:53:39 +0300 | [diff] [blame] | 498 | } |
| 499 | }); |
| 500 | |
Michael Neumann | a6a64d1 | 2016-02-20 13:34:01 +0100 | [diff] [blame] | 501 | cfg.skip_signededness(move |c| { |
Alex Crichton | 6d3cfdb | 2015-09-15 14:53:01 -0700 | [diff] [blame] | 502 | match c { |
gnzlbg | 5c1a6b8 | 2018-11-21 20:34:50 +0100 | [diff] [blame] | 503 | "LARGE_INTEGER" |
| 504 | | "mach_timebase_info_data_t" |
| 505 | | "float" |
| 506 | | "double" => true, |
Michael Neumann | a09fe71 | 2016-02-21 12:28:10 +0100 | [diff] [blame] | 507 | // uuid_t is a struct, not an integer. |
Michael Neumann | a6a64d1 | 2016-02-20 13:34:01 +0100 | [diff] [blame] | 508 | "uuid_t" if dragonfly => true, |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 509 | n if n.starts_with("pthread") => true, |
Steven Fackler | 41699f7 | 2016-06-03 21:02:56 -0700 | [diff] [blame] | 510 | // sem_t is a struct or pointer |
Alan Somers | 831ca99 | 2017-12-13 20:49:17 -0700 | [diff] [blame] | 511 | "sem_t" if openbsd || freebsd || dragonfly || netbsd => true, |
| 512 | // mqd_t is a pointer on FreeBSD and DragonFly |
| 513 | "mqd_t" if freebsd || dragonfly => true, |
Alex Crichton | 1846918 | 2015-09-15 20:57:42 -0700 | [diff] [blame] | 514 | |
Alex Crichton | 4621a34 | 2018-01-25 16:19:35 -0800 | [diff] [blame] | 515 | // Just some typedefs on osx, no need to check their sign |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 516 | "posix_spawnattr_t" | "posix_spawn_file_actions_t" => true, |
Alex Crichton | 4621a34 | 2018-01-25 16:19:35 -0800 | [diff] [blame] | 517 | |
Alex Crichton | 1846918 | 2015-09-15 20:57:42 -0700 | [diff] [blame] | 518 | // windows-isms |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 519 | n if n.starts_with("P") => true, |
| 520 | n if n.starts_with("H") => true, |
| 521 | n if n.starts_with("LP") => true, |
Mackenzie Clark | 2f25aaa | 2018-12-17 17:24:37 -0800 | [diff] [blame] | 522 | "__p_sig_fn_t" if mingw => true, |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 523 | _ => false, |
Alex Crichton | 6d3cfdb | 2015-09-15 14:53:01 -0700 | [diff] [blame] | 524 | } |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 525 | }); |
Alex Crichton | 6d3cfdb | 2015-09-15 14:53:01 -0700 | [diff] [blame] | 526 | |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 527 | cfg.skip_const(move |name| { |
Alex Crichton | 3150484 | 2015-09-10 23:43:41 -0700 | [diff] [blame] | 528 | match name { |
Alex Crichton | cd9b33e | 2015-09-17 14:47:40 -0700 | [diff] [blame] | 529 | // Apparently these don't exist in mingw headers? |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 530 | "MEM_RESET_UNDO" |
| 531 | | "FILE_ATTRIBUTE_NO_SCRUB_DATA" |
| 532 | | "FILE_ATTRIBUTE_INTEGRITY_STREAM" |
| 533 | | "ERROR_NOTHING_TO_TERMINATE" |
| 534 | if mingw => |
| 535 | { |
| 536 | true |
| 537 | } |
Alex Crichton | cd9b33e | 2015-09-17 14:47:40 -0700 | [diff] [blame] | 538 | |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 539 | "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness |
| 540 | "SIGUNUSED" => true, // removed in glibc 2.26 |
Alex Crichton | cd9b33e | 2015-09-17 14:47:40 -0700 | [diff] [blame] | 541 | |
Alex Crichton | 15b83c2 | 2015-09-17 17:25:52 -0700 | [diff] [blame] | 542 | // types on musl are defined a little differently |
Alex Crichton | 3a572fd | 2015-10-29 16:52:25 -0700 | [diff] [blame] | 543 | n if musl && n.contains("__SIZEOF_PTHREAD") => true, |
Alex Crichton | 15b83c2 | 2015-09-17 17:25:52 -0700 | [diff] [blame] | 544 | |
Alex Crichton | 7482522 | 2015-10-29 17:36:55 -0700 | [diff] [blame] | 545 | // Skip constants not defined in MUSL but just passed down to the |
| 546 | // kernel regardless |
gnzlbg | 5c1a6b8 | 2018-11-21 20:34:50 +0100 | [diff] [blame] | 547 | "RLIMIT_NLIMITS" |
| 548 | | "TCP_COOKIE_TRANSACTIONS" |
| 549 | | "RLIMIT_RTTIME" |
| 550 | | "MSG_COPY" |
| 551 | if musl => |
| 552 | { |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 553 | true |
| 554 | } |
Alexander Polakov | 26974c7 | 2015-11-27 03:02:44 +0300 | [diff] [blame] | 555 | // work around super old mips toolchain |
Alexander Polakov | 5850156 | 2015-12-14 02:09:45 +0300 | [diff] [blame] | 556 | "SCHED_IDLE" | "SHM_NORESERVE" => mips, |
Alex Crichton | 7482522 | 2015-10-29 17:36:55 -0700 | [diff] [blame] | 557 | |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 558 | // weird signed extension or something like that? |
| 559 | "MS_NOUSER" => true, |
NODA, Kai | 4d1efd9 | 2016-04-03 21:53:49 +0800 | [diff] [blame] | 560 | "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13 |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 561 | |
| 562 | // These OSX constants are flagged as deprecated |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 563 | "NOTE_EXIT_REPARENTED" | "NOTE_REAP" if apple => true, |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 564 | |
Alan Somers | 9860c29 | 2016-11-13 08:45:59 -0700 | [diff] [blame] | 565 | // These constants were removed in FreeBSD 11 (svn r273250) but will |
| 566 | // still be accepted and ignored at runtime. |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 567 | "MAP_RENAME" | "MAP_NORESERVE" if freebsd => true, |
Alan Somers | 9860c29 | 2016-11-13 08:45:59 -0700 | [diff] [blame] | 568 | |
| 569 | // These constants were removed in FreeBSD 11 (svn r262489), |
| 570 | // and they've never had any legitimate use outside of the |
| 571 | // base system anyway. |
gnzlbg | 5c1a6b8 | 2018-11-21 20:34:50 +0100 | [diff] [blame] | 572 | "CTL_MAXID" | "KERN_MAXID" | "HW_MAXID" | "NET_MAXID" |
| 573 | | "USER_MAXID" |
| 574 | if freebsd => |
| 575 | { |
| 576 | true |
| 577 | } |
Alan Somers | 9860c29 | 2016-11-13 08:45:59 -0700 | [diff] [blame] | 578 | |
Greg V | 2aeb382 | 2018-01-10 22:59:38 +0300 | [diff] [blame] | 579 | // These constants were added in FreeBSD 11 |
gnzlbg | 5c1a6b8 | 2018-11-21 20:34:50 +0100 | [diff] [blame] | 580 | "EVFILT_PROCDESC" | "EVFILT_SENDFILE" | "EVFILT_EMPTY" |
| 581 | | "PD_CLOEXEC" | "PD_ALLOWED_AT_FORK" |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 582 | if freebsd => |
| 583 | { |
| 584 | true |
| 585 | } |
Greg V | 2aeb382 | 2018-01-10 22:59:38 +0300 | [diff] [blame] | 586 | |
Andrew Morrow | 96ee7bf | 2018-05-16 22:26:14 -0600 | [diff] [blame] | 587 | // These constants were added in FreeBSD 12 |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 588 | "SF_USER_READAHEAD" | "SO_REUSEPORT_LB" if freebsd => true, |
Andrew Morrow | 96ee7bf | 2018-05-16 22:26:14 -0600 | [diff] [blame] | 589 | |
Kevin Brothaler | 7fbff3a | 2017-01-16 12:49:49 -0400 | [diff] [blame] | 590 | // These OSX constants are removed in Sierra. |
| 591 | // https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html |
| 592 | "KERN_KDENABLE_BG_TRACE" if apple => true, |
| 593 | "KERN_KDDISABLE_BG_TRACE" if apple => true, |
| 594 | |
Wesley Moore | 58c772b | 2017-08-03 18:10:21 +1000 | [diff] [blame] | 595 | // These constants were removed in OpenBSD 6 (https://git.io/v7gBO |
| 596 | // https://git.io/v7gBq) |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 597 | "KERN_USERMOUNT" | "KERN_ARND" if openbsd => true, |
Wesley Moore | 58c772b | 2017-08-03 18:10:21 +1000 | [diff] [blame] | 598 | |
Kelvin Ly | c0bec43 | 2017-05-06 02:49:54 -0400 | [diff] [blame] | 599 | // These are either unimplemented or optionally built into uClibc |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 600 | "LC_CTYPE_MASK" |
| 601 | | "LC_NUMERIC_MASK" |
| 602 | | "LC_TIME_MASK" |
| 603 | | "LC_COLLATE_MASK" |
| 604 | | "LC_MONETARY_MASK" |
| 605 | | "LC_MESSAGES_MASK" |
| 606 | | "MADV_MERGEABLE" |
| 607 | | "MADV_UNMERGEABLE" |
| 608 | | "MADV_HWPOISON" |
| 609 | | "IPV6_ADD_MEMBERSHIP" |
| 610 | | "IPV6_DROP_MEMBERSHIP" |
| 611 | | "IPV6_MULTICAST_LOOP" |
| 612 | | "IPV6_V6ONLY" |
| 613 | | "MAP_STACK" |
| 614 | | "RTLD_DEEPBIND" |
| 615 | | "SOL_IPV6" |
| 616 | | "SOL_ICMPV6" |
| 617 | if uclibc => |
| 618 | { |
| 619 | true |
| 620 | } |
Kelvin Ly | c0bec43 | 2017-05-06 02:49:54 -0400 | [diff] [blame] | 621 | |
Gabriel | f60ff2d | 2017-07-20 00:28:08 +0200 | [diff] [blame] | 622 | // Musl uses old, patched kernel headers |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 623 | "FALLOC_FL_COLLAPSE_RANGE" |
| 624 | | "FALLOC_FL_ZERO_RANGE" |
| 625 | | "FALLOC_FL_INSERT_RANGE" |
| 626 | | "FALLOC_FL_UNSHARE_RANGE" |
| 627 | | "RENAME_NOREPLACE" |
| 628 | | "RENAME_EXCHANGE" |
| 629 | | "RENAME_WHITEOUT" |
| 630 | if musl => |
| 631 | { |
| 632 | true |
| 633 | } |
Gabriel | f60ff2d | 2017-07-20 00:28:08 +0200 | [diff] [blame] | 634 | |
Marco A L Barbosa | ae49626 | 2017-11-01 18:41:58 -0200 | [diff] [blame] | 635 | // Both android and musl use old kernel headers |
| 636 | // These are constants used in getrandom syscall |
| 637 | "GRND_NONBLOCK" | "GRND_RANDOM" if musl || android => true, |
| 638 | |
Lee Bousfield | 98889cf | 2017-05-15 09:15:53 -0600 | [diff] [blame] | 639 | // Defined by libattr not libc on linux (hard to test). |
| 640 | // See constant definition for more details. |
Mateusz Mikuła | 27043ec | 2018-07-04 18:43:48 +0200 | [diff] [blame] | 641 | "ENOATTR" if android || linux => true, |
Lee Bousfield | 98889cf | 2017-05-15 09:15:53 -0600 | [diff] [blame] | 642 | |
Bryant Mairs | f04b442 | 2017-07-11 23:17:15 -0700 | [diff] [blame] | 643 | // On mips*-unknown-linux-gnu* CMSPAR cannot be included with the set of headers we |
| 644 | // want to use here for testing. It's originally defined in asm/termbits.h, which is |
| 645 | // also included by asm/termios.h, but not the standard termios.h. There's no way to |
| 646 | // include both asm/termbits.h and termios.h and there's no way to include both |
| 647 | // asm/termios.h and ioctl.h (+ some other headers) because of redeclared types. |
| 648 | "CMSPAR" if mips && linux && !musl => true, |
| 649 | |
Bryant Mairs | c9e6f55 | 2017-08-10 14:31:11 -0700 | [diff] [blame] | 650 | // On mips Linux targets, MADV_SOFT_OFFLINE is currently missing, though it's been added but CI has too old |
| 651 | // of a Linux version. Since it exists on all other Linux targets, just ignore this for now and remove once |
| 652 | // it's been fixed in CI. |
| 653 | "MADV_SOFT_OFFLINE" if mips && linux => true, |
| 654 | |
Bryant Mairs | 2e11d9e | 2017-08-10 10:33:19 -0700 | [diff] [blame] | 655 | // These constants are tested in a separate test program generated below because there |
| 656 | // are header conflicts if we try to include the headers that define them here. |
| 657 | "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => true, |
gnzlbg | 5c1a6b8 | 2018-11-21 20:34:50 +0100 | [diff] [blame] | 658 | "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" |
| 659 | | "F_SEAL_WRITE" => true, |
| 660 | "QFMT_VFS_OLD" | "QFMT_VFS_V0" | "QFMT_VFS_V1" |
| 661 | if mips && linux => |
| 662 | { |
| 663 | true |
| 664 | } // Only on MIPS |
Bryant Mairs | 12cfa1e | 2017-10-18 18:26:59 -0700 | [diff] [blame] | 665 | "BOTHER" => true, |
Bryant Mairs | 2e11d9e | 2017-08-10 10:33:19 -0700 | [diff] [blame] | 666 | |
Bryant Mairs | fa81ab3 | 2017-11-06 18:45:30 -0800 | [diff] [blame] | 667 | "MFD_CLOEXEC" | "MFD_ALLOW_SEALING" if !mips && musl => true, |
Tobias Klauser | df277e2 | 2018-12-12 16:46:41 +0100 | [diff] [blame] | 668 | // MFD_HUGETLB is not available in some older libc versions on the CI builders. On the |
| 669 | // x86_64 and i686 builders it seems to be available for all targets, so at least test |
| 670 | // it there. |
gnzlbg | 0a5484e | 2019-02-07 11:13:38 +0100 | [diff] [blame] | 671 | "MFD_HUGETLB" |
| 672 | if !(x86_64 || i686) || musl || (x86_64 && android) => |
| 673 | { |
| 674 | true |
| 675 | } |
bgermann | b3870b4 | 2017-11-18 14:57:54 +0100 | [diff] [blame] | 676 | |
gnzlbg | 5c1a6b8 | 2018-11-21 20:34:50 +0100 | [diff] [blame] | 677 | "DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" |
| 678 | | "DT_LNK" | "DT_SOCK" |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 679 | if solaris => |
| 680 | { |
| 681 | true |
| 682 | } |
bgermann | b3870b4 | 2017-11-18 14:57:54 +0100 | [diff] [blame] | 683 | "USRQUOTA" | "GRPQUOTA" if solaris => true, |
| 684 | "PRIO_MIN" | "PRIO_MAX" if solaris => true, |
| 685 | |
| 686 | // These are defined for Solaris 11, but the crate is tested on illumos, where they are currently not defined |
gnzlbg | 5c1a6b8 | 2018-11-21 20:34:50 +0100 | [diff] [blame] | 687 | "EADI" |
| 688 | | "PORT_SOURCE_POSTWAIT" |
| 689 | | "PORT_SOURCE_SIGNAL" |
| 690 | | "PTHREAD_STACK_MIN" => true, |
bgermann | b3870b4 | 2017-11-18 14:57:54 +0100 | [diff] [blame] | 691 | |
Alex Crichton | 1f29ac3 | 2018-01-18 11:21:30 -0800 | [diff] [blame] | 692 | // These change all the time from release to release of linux |
| 693 | // distros, let's just not bother trying to verify them. They |
| 694 | // shouldn't be used in code anyway... |
| 695 | "AF_MAX" | "PF_MAX" => true, |
| 696 | |
Tobias Klauser | cc22997 | 2018-12-04 17:36:48 +0100 | [diff] [blame] | 697 | // These are not in a glibc release yet, only in kernel headers. |
| 698 | "AF_XDP" | "PF_XDP" | "SOL_XDP" if linux => true, |
| 699 | |
Alex Crichton | 83f78df | 2018-07-31 14:13:30 -0700 | [diff] [blame] | 700 | // Present on historical versions of iOS, but now removed in more |
| 701 | // recent SDKs |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 702 | "ARPOP_REQUEST" |
| 703 | | "ARPOP_REPLY" |
| 704 | | "ATF_COM" |
| 705 | | "ATF_PERM" |
| 706 | | "ATF_PUBL" |
| 707 | | "ATF_USETRAILERS" |
| 708 | | "AF_SYS_CONTROL" |
| 709 | | "SYSPROTO_EVENT" |
| 710 | | "PROC_PIDTASKALLINFO" |
| 711 | | "PROC_PIDTASKINFO" |
| 712 | | "PROC_PIDTHREADINFO" |
| 713 | | "UTUN_OPT_FLAGS" |
| 714 | | "UTUN_OPT_IFNAME" |
| 715 | | "BPF_ALIGNMENT" |
| 716 | | "SYSPROTO_CONTROL" |
| 717 | if ios => |
| 718 | { |
| 719 | true |
| 720 | } |
Alex Crichton | 83f78df | 2018-07-31 14:13:30 -0700 | [diff] [blame] | 721 | s if ios && s.starts_with("RTF_") => true, |
| 722 | s if ios && s.starts_with("RTM_") => true, |
| 723 | s if ios && s.starts_with("RTA_") => true, |
| 724 | s if ios && s.starts_with("RTAX_") => true, |
| 725 | s if ios && s.starts_with("RTV_") => true, |
| 726 | s if ios && s.starts_with("DLT_") => true, |
| 727 | |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 728 | _ => false, |
Alex Crichton | 3150484 | 2015-09-10 23:43:41 -0700 | [diff] [blame] | 729 | } |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 730 | }); |
Alex Crichton | 3150484 | 2015-09-10 23:43:41 -0700 | [diff] [blame] | 731 | |
Alex Crichton | cd9b33e | 2015-09-17 14:47:40 -0700 | [diff] [blame] | 732 | cfg.skip_fn(move |name| { |
Jim Blandy | f8772f7 | 2016-01-12 16:28:07 -0800 | [diff] [blame] | 733 | // skip those that are manually verified |
Alex Crichton | 2237882 | 2015-09-10 19:59:23 -0700 | [diff] [blame] | 734 | match name { |
Alex Crichton | cd9b33e | 2015-09-17 14:47:40 -0700 | [diff] [blame] | 735 | "execv" | // crazy stuff with const/mut |
Alex Crichton | 2237882 | 2015-09-10 19:59:23 -0700 | [diff] [blame] | 736 | "execve" | |
| 737 | "execvp" | |
Luca Bruno | 858d47c | 2017-07-21 15:13:44 +0000 | [diff] [blame] | 738 | "execvpe" | |
| 739 | "fexecve" => true, |
Alex Crichton | cd9b33e | 2015-09-17 14:47:40 -0700 | [diff] [blame] | 740 | |
Alex Crichton | 7482522 | 2015-10-29 17:36:55 -0700 | [diff] [blame] | 741 | "getrlimit" | "getrlimit64" | // non-int in 1st arg |
| 742 | "setrlimit" | "setrlimit64" | // non-int in 1st arg |
Kamal Marhubi | 9569599 | 2016-04-27 14:29:19 -0400 | [diff] [blame] | 743 | "prlimit" | "prlimit64" | // non-int in 2nd arg |
Alex Crichton | cd9b33e | 2015-09-17 14:47:40 -0700 | [diff] [blame] | 744 | "strerror_r" if linux => true, // actually xpg-something-or-other |
| 745 | |
NODA, Kai | 61c23fb | 2016-04-10 22:21:55 +0800 | [diff] [blame] | 746 | // int vs uint. Sorry musl, your prototype declarations are "correct" in the sense that |
| 747 | // they match the interface defined by Linux verbatim, but they conflict with other |
| 748 | // send*/recv* syscalls |
| 749 | "sendmmsg" | "recvmmsg" if musl => true, |
| 750 | |
Alex Crichton | 1ff9610 | 2015-09-17 15:09:02 -0700 | [diff] [blame] | 751 | // typed 2nd arg on linux and android |
Michael Neumann | a6a64d1 | 2016-02-20 13:34:01 +0100 | [diff] [blame] | 752 | "gettimeofday" if linux || android || freebsd || openbsd || dragonfly => true, |
Alex Crichton | 1ff9610 | 2015-09-17 15:09:02 -0700 | [diff] [blame] | 753 | |
Alex Crichton | 881ef9b | 2015-12-01 09:04:13 -0800 | [diff] [blame] | 754 | // not declared in newer android toolchains |
| 755 | "getdtablesize" if android => true, |
| 756 | |
Alex Crichton | 1ff9610 | 2015-09-17 15:09:02 -0700 | [diff] [blame] | 757 | "dlerror" if android => true, // const-ness is added |
bgermann | 85680dc | 2017-11-18 22:03:14 +0100 | [diff] [blame] | 758 | "dladdr" if musl || solaris => true, // const-ness only added recently |
Alex Crichton | 1ff9610 | 2015-09-17 15:09:02 -0700 | [diff] [blame] | 759 | |
Alex Crichton | 568705e | 2015-11-03 14:18:52 -0800 | [diff] [blame] | 760 | // OSX has 'struct tm *const' which we can't actually represent in |
| 761 | // Rust, but is close enough to *mut |
| 762 | "timegm" if apple => true, |
| 763 | |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 764 | // OSX's daemon is deprecated in 10.5 so we'll get a warning (which |
| 765 | // we turn into an error) so just ignore it. |
| 766 | "daemon" if apple => true, |
| 767 | |
Steven Fackler | 41699f7 | 2016-06-03 21:02:56 -0700 | [diff] [blame] | 768 | // Deprecated on OSX |
| 769 | "sem_destroy" if apple => true, |
| 770 | "sem_init" if apple => true, |
| 771 | |
Alex Crichton | 49d7bca | 2015-11-27 09:40:37 -0800 | [diff] [blame] | 772 | // These functions presumably exist on netbsd but don't look like |
| 773 | // they're implemented on rumprun yet, just let them slide for now. |
| 774 | // Some of them look like they have headers but then don't have |
| 775 | // corresponding actual definitions either... |
Alex Crichton | 49d7bca | 2015-11-27 09:40:37 -0800 | [diff] [blame] | 776 | "shm_open" | |
| 777 | "shm_unlink" | |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 778 | "syscall" | |
Alan Somers | 831ca99 | 2017-12-13 20:49:17 -0700 | [diff] [blame] | 779 | "mq_open" | |
| 780 | "mq_close" | |
| 781 | "mq_getattr" | |
| 782 | "mq_notify" | |
| 783 | "mq_receive" | |
| 784 | "mq_send" | |
| 785 | "mq_setattr" | |
| 786 | "mq_timedreceive" | |
| 787 | "mq_timedsend" | |
| 788 | "mq_unlink" | |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 789 | "ptrace" | |
Alex Crichton | 49d7bca | 2015-11-27 09:40:37 -0800 | [diff] [blame] | 790 | "sigaltstack" if rumprun => true, |
| 791 | |
Jim Blandy | f8772f7 | 2016-01-12 16:28:07 -0800 | [diff] [blame] | 792 | // There seems to be a small error in EGLIBC's eventfd.h header. The |
| 793 | // [underlying system call][1] always takes its first `count` |
| 794 | // argument as an `unsigned int`, but [EGLIBC's <sys/eventfd.h> |
| 795 | // header][2] declares it to take an `int`. [GLIBC's header][3] |
| 796 | // matches the kernel. |
| 797 | // |
| 798 | // EGLIBC is no longer actively developed, and Debian, the largest |
| 799 | // distribution that had been using it, switched back to GLIBC in |
| 800 | // April 2015. So effectively all Linux <sys/eventfd.h> headers will |
| 801 | // be using `unsigned int` soon. |
| 802 | // |
| 803 | // [1]: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/fs/eventfd.c?id=refs/tags/v3.12.51#n397 |
| 804 | // [2]: http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/trusty/eglibc/trusty/view/head:/sysdeps/unix/sysv/linux/sys/eventfd.h |
| 805 | // [3]: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/sys/eventfd.h;h=6295f32e937e779e74318eb9d3bdbe76aef8a8f3;hb=4e42b5b8f89f0e288e68be7ad70f9525aebc2cff#l34 |
| 806 | "eventfd" if linux => true, |
| 807 | |
Boris Faure | da445b9 | 2016-11-05 20:16:50 +0100 | [diff] [blame] | 808 | // The `uname` function in freebsd is now an inline wrapper that |
Alex Crichton | bb6f198 | 2016-01-18 11:18:22 -0800 | [diff] [blame] | 809 | // delegates to another, but the symbol still exists, so don't check |
| 810 | // the symbol. |
| 811 | "uname" if freebsd => true, |
| 812 | |
Fredrick Brennan | 6d959f1 | 2018-03-04 13:11:04 +0000 | [diff] [blame] | 813 | // FIXME: need to upgrade FreeBSD version; see https://github.com/rust-lang/libc/issues/938 |
| 814 | "setgrent" if freebsd => true, |
| 815 | |
Alan Somers | e0ff0d6 | 2016-11-13 14:35:17 -0700 | [diff] [blame] | 816 | // aio_waitcomplete's return type changed between FreeBSD 10 and 11. |
| 817 | "aio_waitcomplete" if freebsd => true, |
| 818 | |
Alan Somers | 9245e07 | 2016-11-13 13:52:34 -0700 | [diff] [blame] | 819 | // lio_listio confuses the checker, probably because one of its |
| 820 | // arguments is an array |
| 821 | "lio_listio" if freebsd => true, |
Alan Somers | e0ff0d6 | 2016-11-13 14:35:17 -0700 | [diff] [blame] | 822 | "lio_listio" if musl => true, |
Alan Somers | 9245e07 | 2016-11-13 13:52:34 -0700 | [diff] [blame] | 823 | |
Alex Crichton | c284246 | 2016-11-16 14:12:12 -0800 | [diff] [blame] | 824 | // Apparently the NDK doesn't have this defined on android, but |
| 825 | // it's in a header file? |
| 826 | "endpwent" if android => true, |
| 827 | |
Kelvin Ly | 96a8306 | 2017-05-04 22:08:48 -0400 | [diff] [blame] | 828 | |
Kelvin Ly | 9a83558 | 2017-04-20 02:34:50 -0400 | [diff] [blame] | 829 | // These are either unimplemented or optionally built into uClibc |
| 830 | // or "sysinfo", where it's defined but the structs in linux/sysinfo.h and sys/sysinfo.h |
Kelvin Ly | 26670c7 | 2017-04-21 18:20:02 -0400 | [diff] [blame] | 831 | // clash so it can't be tested |
| 832 | "getxattr" | "lgetxattr" | "fgetxattr" | "setxattr" | "lsetxattr" | "fsetxattr" | |
| 833 | "listxattr" | "llistxattr" | "flistxattr" | "removexattr" | "lremovexattr" | |
| 834 | "fremovexattr" | |
| 835 | "backtrace" | |
| 836 | "sysinfo" | "newlocale" | "duplocale" | "freelocale" | "uselocale" | |
Kelvin Ly | c14178c | 2017-04-26 23:01:05 -0400 | [diff] [blame] | 837 | "nl_langinfo_l" | "wcslen" | "wcstombs" if uclibc => true, |
Bryant Mairs | 9b9f36a | 2017-05-18 10:06:36 -0700 | [diff] [blame] | 838 | |
Jon Gjengset | be7e45f | 2017-05-03 15:57:29 -0400 | [diff] [blame] | 839 | // Apparently res_init exists on Android, but isn't defined in a header: |
Jon Gjengset | afebd98 | 2017-04-28 22:23:33 -0400 | [diff] [blame] | 840 | // https://mail.gnome.org/archives/commits-list/2013-May/msg01329.html |
| 841 | "res_init" if android => true, |
| 842 | |
Jon Gjengset | be7e45f | 2017-05-03 15:57:29 -0400 | [diff] [blame] | 843 | // On macOS and iOS, res_init is available, but requires linking with libresolv: |
| 844 | // http://blog.achernya.com/2013/03/os-x-has-silly-libsystem.html |
| 845 | // See discussion for skipping here: |
| 846 | // https://github.com/rust-lang/libc/pull/585#discussion_r114561460 |
| 847 | "res_init" if apple => true, |
| 848 | |
Bryant Mairs | 9b9f36a | 2017-05-18 10:06:36 -0700 | [diff] [blame] | 849 | // On Mac we don't use the default `close()`, instead using their $NOCANCEL variants. |
| 850 | "close" if apple => true, |
| 851 | |
Nicolas Dusart | 4abc3ce | 2017-06-29 21:25:55 +0200 | [diff] [blame] | 852 | // Definition of those functions as changed since unified headers from NDK r14b |
| 853 | // These changes imply some API breaking changes but are still ABI compatible. |
| 854 | // We can wait for the next major release to be compliant with the new API. |
| 855 | // FIXME: unskip these for next major release |
| 856 | "strerror_r" | "madvise" | "msync" | "mprotect" | "recvfrom" | "getpriority" | |
bgermann | 85680dc | 2017-11-18 22:03:14 +0100 | [diff] [blame] | 857 | "setpriority" | "personality" if android || solaris => true, |
Nicolas Dusart | 4abc3ce | 2017-06-29 21:25:55 +0200 | [diff] [blame] | 858 | // In Android 64 bits, these functions have been fixed since unified headers. |
| 859 | // Ignore these until next major version. |
| 860 | "bind" | "writev" | "readv" | "sendmsg" | "recvmsg" if android && (aarch64 || x86_64) => true, |
| 861 | |
bgermann | b3870b4 | 2017-11-18 14:57:54 +0100 | [diff] [blame] | 862 | // signal is defined with sighandler_t, so ignore |
| 863 | "signal" if solaris => true, |
| 864 | |
| 865 | "cfmakeraw" | "cfsetspeed" if solaris => true, |
| 866 | |
bgermann | 85680dc | 2017-11-18 22:03:14 +0100 | [diff] [blame] | 867 | // FIXME: mincore is defined with caddr_t on Solaris. |
| 868 | "mincore" if solaris => true, |
| 869 | |
Alex Crichton | 83f78df | 2018-07-31 14:13:30 -0700 | [diff] [blame] | 870 | // These were all included in historical versions of iOS but appear |
| 871 | // to be removed now |
| 872 | "system" | "ptrace" if ios => true, |
| 873 | |
Sébastien Marie | 1451f19 | 2019-01-13 09:06:05 +0100 | [diff] [blame] | 874 | // Removed in OpenBSD 6.5 |
| 875 | // https://marc.info/?l=openbsd-cvs&m=154723400730318 |
| 876 | "mincore" if openbsd => true, |
| 877 | |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 878 | _ => false, |
Alex Crichton | 2237882 | 2015-09-10 19:59:23 -0700 | [diff] [blame] | 879 | } |
Alex Crichton | d11e914 | 2015-09-15 23:28:52 -0700 | [diff] [blame] | 880 | }); |
Alex Crichton | 2237882 | 2015-09-10 19:59:23 -0700 | [diff] [blame] | 881 | |
Tobias Bucher | 8b1d846 | 2018-09-05 09:48:49 +0200 | [diff] [blame] | 882 | cfg.skip_static(move |name| { |
| 883 | match name { |
| 884 | // Internal constant, not declared in any headers. |
| 885 | "__progname" if android => true, |
| 886 | _ => false, |
| 887 | } |
| 888 | }); |
| 889 | |
Alex Crichton | 881ef9b | 2015-12-01 09:04:13 -0800 | [diff] [blame] | 890 | cfg.skip_fn_ptrcheck(move |name| { |
| 891 | match name { |
Alex Crichton | 881ef9b | 2015-12-01 09:04:13 -0800 | [diff] [blame] | 892 | // dllimport weirdness? |
| 893 | _ if windows => true, |
| 894 | |
| 895 | _ => false, |
| 896 | } |
| 897 | }); |
Alex Crichton | e0f4d10 | 2015-09-16 09:48:14 -0700 | [diff] [blame] | 898 | |
Alex Crichton | 15b83c2 | 2015-09-17 17:25:52 -0700 | [diff] [blame] | 899 | cfg.skip_field_type(move |struct_, field| { |
Alex Crichton | f3b9748 | 2015-09-16 14:13:20 -0700 | [diff] [blame] | 900 | // This is a weird union, don't check the type. |
Alex Crichton | cd9b33e | 2015-09-17 14:47:40 -0700 | [diff] [blame] | 901 | (struct_ == "ifaddrs" && field == "ifa_ifu") || |
| 902 | // sighandler_t type is super weird |
Knight | 866c9e4 | 2016-08-09 14:01:33 +0800 | [diff] [blame] | 903 | (struct_ == "sigaction" && field == "sa_sigaction") || |
| 904 | // __timeval type is a patch which doesn't exist in glibc |
Alan Somers | 9245e07 | 2016-11-13 13:52:34 -0700 | [diff] [blame] | 905 | (linux && struct_ == "utmpx" && field == "ut_tv") || |
| 906 | // sigval is actually a union, but we pretend it's a struct |
| 907 | (struct_ == "sigevent" && field == "sigev_value") || |
| 908 | // aio_buf is "volatile void*" and Rust doesn't understand volatile |
Alan Somers | 9860c29 | 2016-11-13 08:45:59 -0700 | [diff] [blame] | 909 | (struct_ == "aiocb" && field == "aio_buf") || |
| 910 | // stack_t.ss_sp's type changed from FreeBSD 10 to 11 in svn r294930 |
Mateusz Sieczko | 60d9322 | 2017-06-13 17:26:14 +0200 | [diff] [blame] | 911 | (freebsd && struct_ == "stack_t" && field == "ss_sp") || |
Sébastien Marie | 56701a7 | 2017-08-13 12:29:45 +0200 | [diff] [blame] | 912 | // type siginfo_t.si_addr changed from OpenBSD 6.0 to 6.1 |
| 913 | (openbsd && struct_ == "siginfo_t" && field == "si_addr") || |
Mateusz Sieczko | 60d9322 | 2017-06-13 17:26:14 +0200 | [diff] [blame] | 914 | // this one is an anonymous union |
| 915 | (linux && struct_ == "ff_effect" && field == "u") |
Alex Crichton | cd9b33e | 2015-09-17 14:47:40 -0700 | [diff] [blame] | 916 | }); |
| 917 | |
Alex Crichton | 15b83c2 | 2015-09-17 17:25:52 -0700 | [diff] [blame] | 918 | cfg.skip_field(move |struct_, field| { |
Alex Crichton | cd9b33e | 2015-09-17 14:47:40 -0700 | [diff] [blame] | 919 | // this is actually a union on linux, so we can't represent it well and |
| 920 | // just insert some padding. |
Alex Crichton | 15b83c2 | 2015-09-17 17:25:52 -0700 | [diff] [blame] | 921 | (struct_ == "siginfo_t" && field == "_pad") || |
| 922 | // musl names this __dummy1 but it's still there |
Brian Anderson | 773aab8 | 2015-12-29 20:00:29 +0000 | [diff] [blame] | 923 | (musl && struct_ == "glob_t" && field == "gl_flags") || |
| 924 | // musl seems to define this as an *anonymous* bitfield |
Alan Somers | 9245e07 | 2016-11-13 13:52:34 -0700 | [diff] [blame] | 925 | (musl && struct_ == "statvfs" && field == "__f_unused") || |
| 926 | // sigev_notify_thread_id is actually part of a sigev_un union |
Stephen Barber | 60ab304 | 2018-11-05 16:02:26 -0800 | [diff] [blame] | 927 | (struct_ == "sigevent" && field == "sigev_notify_thread_id") || |
| 928 | // signalfd had SIGSYS fields added in Linux 4.18, but no libc release has them yet. |
| 929 | (struct_ == "signalfd_siginfo" && (field == "ssi_addr_lsb" || |
| 930 | field == "_pad2" || |
| 931 | field == "ssi_syscall" || |
| 932 | field == "ssi_call_addr" || |
| 933 | field == "ssi_arch")) |
Alex Crichton | f3b9748 | 2015-09-16 14:13:20 -0700 | [diff] [blame] | 934 | }); |
| 935 | |
Alex Crichton | 49d7bca | 2015-11-27 09:40:37 -0800 | [diff] [blame] | 936 | cfg.fn_cname(move |name, cname| { |
Alex Crichton | 881ef9b | 2015-12-01 09:04:13 -0800 | [diff] [blame] | 937 | if windows { |
Alex Crichton | 49d7bca | 2015-11-27 09:40:37 -0800 | [diff] [blame] | 938 | cname.unwrap_or(name).to_string() |
Alex Crichton | 0af5e23 | 2015-11-30 15:07:28 -0800 | [diff] [blame] | 939 | } else { |
Alex Crichton | 49d7bca | 2015-11-27 09:40:37 -0800 | [diff] [blame] | 940 | name.to_string() |
Alex Crichton | 0af5e23 | 2015-11-30 15:07:28 -0800 | [diff] [blame] | 941 | } |
| 942 | }); |
| 943 | |
Bryant Mairs | 2e11d9e | 2017-08-10 10:33:19 -0700 | [diff] [blame] | 944 | cfg.generate("../src/lib.rs", "main.rs"); |
| 945 | |
| 946 | // On Linux or Android also generate another script for testing linux/fcntl declarations. |
| 947 | // These cannot be tested normally because including both `linux/fcntl.h` and `fcntl.h` |
| 948 | // fails on a lot of platforms. |
| 949 | let mut cfg = ctest::TestGenerator::new(); |
| 950 | cfg.skip_type(|_| true) |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 951 | .skip_fn(|_| true) |
| 952 | .skip_static(|_| true); |
Bryant Mairs | 2e11d9e | 2017-08-10 10:33:19 -0700 | [diff] [blame] | 953 | if android || linux { |
| 954 | // musl defines these directly in `fcntl.h` |
| 955 | if musl { |
| 956 | cfg.header("fcntl.h"); |
| 957 | } else { |
| 958 | cfg.header("linux/fcntl.h"); |
| 959 | } |
SilverWingedSeraph | 6f170ef | 2017-09-12 12:33:10 -0500 | [diff] [blame] | 960 | if !musl { |
| 961 | cfg.header("net/if.h"); |
| 962 | cfg.header("linux/if.h"); |
| 963 | } |
Bryant Mairs | bd4c348 | 2017-08-29 19:33:22 -0700 | [diff] [blame] | 964 | cfg.header("linux/quota.h"); |
Bryant Mairs | 12cfa1e | 2017-10-18 18:26:59 -0700 | [diff] [blame] | 965 | cfg.header("asm/termbits.h"); |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 966 | cfg.skip_const(move |name| match name { |
| 967 | "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => false, |
gnzlbg | 5c1a6b8 | 2018-11-21 20:34:50 +0100 | [diff] [blame] | 968 | "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" |
| 969 | | "F_SEAL_WRITE" => false, |
| 970 | "QFMT_VFS_OLD" | "QFMT_VFS_V0" | "QFMT_VFS_V1" |
| 971 | if mips && linux => |
| 972 | { |
| 973 | false |
| 974 | } |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 975 | "BOTHER" => false, |
| 976 | _ => true, |
Bryant Mairs | 2e11d9e | 2017-08-10 10:33:19 -0700 | [diff] [blame] | 977 | }); |
gnzlbg | aca32d9 | 2018-11-19 15:24:41 +0100 | [diff] [blame] | 978 | cfg.skip_struct(|s| s != "termios2"); |
| 979 | cfg.type_name(move |ty, is_struct, is_union| match ty { |
| 980 | t if is_struct => format!("struct {}", t), |
| 981 | t if is_union => format!("union {}", t), |
| 982 | t => t.to_string(), |
Bryant Mairs | 6d55c24 | 2017-10-18 18:55:41 -0700 | [diff] [blame] | 983 | }); |
Bryant Mairs | 2e11d9e | 2017-08-10 10:33:19 -0700 | [diff] [blame] | 984 | } else { |
| 985 | cfg.skip_const(|_| true); |
Bryant Mairs | 6d55c24 | 2017-10-18 18:55:41 -0700 | [diff] [blame] | 986 | cfg.skip_struct(|_| true); |
Bryant Mairs | 2e11d9e | 2017-08-10 10:33:19 -0700 | [diff] [blame] | 987 | } |
| 988 | cfg.generate("../src/lib.rs", "linux_fcntl.rs"); |
Alex Crichton | 310d623 | 2015-09-10 10:56:31 -0700 | [diff] [blame] | 989 | } |
Alan Somers | 38cf5b1 | 2019-01-31 22:34:17 -0700 | [diff] [blame] | 990 | |
| 991 | fn main() { |
| 992 | do_cc(); |
| 993 | do_ctest(); |
| 994 | } |