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