Upgrade rust/crates/libc to 0.2.72.

Bug: b/158290206
Test: mm -j40
Change-Id: Iaad65cc21e5640cfbd31d40991b44ba1a6fa6de4
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 1e7f6c0..d38aeba 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
 {
   "git": {
-    "sha1": "8712132baa9c487b229ff1489859f3ea21c70432"
+    "sha1": "73e883808c6ffa5d970c152a0a6aa59cb4bb4a6f"
   }
 }
diff --git a/Cargo.toml b/Cargo.toml
index 841a824..e30d68b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,7 +12,7 @@
 
 [package]
 name = "libc"
-version = "0.2.71"
+version = "0.2.72"
 authors = ["The Rust Project Developers"]
 build = "build.rs"
 exclude = ["/ci/*", "/azure-pipelines.yml"]
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index f5a0d47..05331e3 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
 [package]
 name = "libc"
-version = "0.2.71"
+version = "0.2.72"
 authors = ["The Rust Project Developers"]
 license = "MIT OR Apache-2.0"
 readme = "README.md"
diff --git a/METADATA b/METADATA
index 3bfc011..51e3089 100644
--- a/METADATA
+++ b/METADATA
@@ -9,11 +9,11 @@
     type: GIT
     value: "https://github.com/rust-lang/libc"
   }
-  version: "0.2.71"
+  version: "0.2.72"
   license_type: NOTICE
   last_upgrade_date {
     year: 2020
-    month: 5
-    day: 26
+    month: 7
+    day: 8
   }
 }
diff --git a/src/lib.rs b/src/lib.rs
index 5ba9e5b..321d1f2 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -5,13 +5,13 @@
 //! [pd]: https://rust-lang.github.io/libc/#platform-specific-documentation
 #![crate_name = "libc"]
 #![crate_type = "rlib"]
-// FIXME: Remove this and redundant_semicolon once renamed lint reaches stable.
-#![allow(renamed_and_removed_lints)]
 #![allow(
+    renamed_and_removed_lints, // Keep this order.
+    unknown_lints, // Keep this order.
     bad_style,
     overflowing_literals,
     improper_ctypes,
-    unknown_lints,
+    // This lint is renamed but we run CI for old stable rustc so should be here.
     redundant_semicolon,
     redundant_semicolons
 )]
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index c03c644..f130974 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -2,6 +2,7 @@
 //!
 //! This covers *-apple-* triples currently
 pub type c_char = i8;
+pub type wchar_t = i32;
 pub type clock_t = c_ulong;
 pub type time_t = c_long;
 pub type suseconds_t = i32;
diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs
index 0146363..5841947 100644
--- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs
+++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs
@@ -1,5 +1,6 @@
 pub type dev_t = u32;
 pub type c_char = i8;
+pub type wchar_t = i32;
 pub type clock_t = u64;
 pub type ino_t = u64;
 pub type lwpid_t = i32;
@@ -1051,6 +1052,10 @@
         (_CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) +
             _CMSG_ALIGN(length as usize)) as ::c_uint
     }
+
+    pub fn WIFSIGNALED(status: ::c_int) -> bool {
+        (status & 0o177) != 0o177 && (status & 0o177) != 0
+    }
 }
 
 extern "C" {
diff --git a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs
index 22fd2b8..db0093a 100644
--- a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs
@@ -1,34 +1,10 @@
 pub type c_char = u8;
 pub type c_long = i64;
 pub type c_ulong = u64;
+pub type wchar_t = u32;
 pub type time_t = i64;
 pub type suseconds_t = i64;
-
-s! {
-    pub struct stat {
-        pub st_dev: ::dev_t,
-        pub st_ino: ::ino_t,
-        pub st_mode: ::mode_t,
-        pub st_nlink: ::nlink_t,
-        pub st_uid: ::uid_t,
-        pub st_gid: ::gid_t,
-        pub st_rdev: ::dev_t,
-        pub st_atime: ::time_t,
-        pub st_atime_nsec: ::c_long,
-        pub st_mtime: ::time_t,
-        pub st_mtime_nsec: ::c_long,
-        pub st_ctime: ::time_t,
-        pub st_ctime_nsec: ::c_long,
-        pub st_size: ::off_t,
-        pub st_blocks: ::blkcnt_t,
-        pub st_blksize: ::blksize_t,
-        pub st_flags: ::fflags_t,
-        pub st_gen: u32,
-        pub st_lspare: i32,
-        pub st_birthtime: ::time_t,
-        pub st_birthtime_nsec: ::c_long,
-    }
-}
+pub type register_t = i64;
 
 // should be pub(crate), but that requires Rust 1.18.0
 cfg_if! {
@@ -42,3 +18,4 @@
 }
 
 pub const MAP_32BIT: ::c_int = 0x00080000;
+pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4
diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs
index b7480aa..300b3dd 100644
--- a/src/unix/bsd/freebsdlike/freebsd/arm.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs
@@ -1,8 +1,10 @@
 pub type c_char = u8;
 pub type c_long = i32;
 pub type c_ulong = u32;
+pub type wchar_t = u32;
 pub type time_t = i64;
 pub type suseconds_t = i32;
+pub type register_t = i32;
 
 s! {
     pub struct stat {
@@ -45,3 +47,4 @@
     }
 }
 pub const MAP_32BIT: ::c_int = 0x00080000;
+pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4
diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs
similarity index 100%
rename from src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs
rename to src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs
diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs
index 79a152f..b443da3 100644
--- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs
@@ -217,8 +217,9 @@
 }
 
 cfg_if! {
-    if #[cfg(target_arch = "x86_64")] {
-        mod x86_64;
-        pub use self::x86_64::*;
+    if #[cfg(any(target_arch = "x86_64",
+                 target_arch = "aarch64"))] {
+        mod b64;
+        pub use self::b64::*;
     }
 }
diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/b64.rs
similarity index 100%
rename from src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs
rename to src/unix/bsd/freebsdlike/freebsd/freebsd12/b64.rs
diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs
index 6bf7f95..e0dd712 100644
--- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs
@@ -217,8 +217,9 @@
 }
 
 cfg_if! {
-    if #[cfg(target_arch = "x86_64")] {
-        mod x86_64;
-        pub use self::x86_64::*;
+    if #[cfg(any(target_arch = "x86_64",
+                 target_arch = "aarch64"))] {
+        mod b64;
+        pub use self::b64::*;
     }
 }
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index db36184..35fe554 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -322,10 +322,17 @@
 pub const EXTATTR_NAMESPACE_USER: ::c_int = 1;
 pub const EXTATTR_NAMESPACE_SYSTEM: ::c_int = 2;
 
-pub const RAND_MAX: ::c_int = 0x7fff_fffd;
-pub const PTHREAD_STACK_MIN: ::size_t = 2048;
+cfg_if! {
+    if #[cfg(any(freebsd10, freebsd11, freebsd12))] {
+        pub const RAND_MAX: ::c_int = 0x7fff_fffd;
+    } else {
+        pub const RAND_MAX: ::c_int = 0x7fff_ffff;
+    }
+}
+
+pub const PTHREAD_STACK_MIN: ::size_t = MINSIGSTKSZ;
 pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 4;
-pub const SIGSTKSZ: ::size_t = 34816;
+pub const SIGSTKSZ: ::size_t = MINSIGSTKSZ + 32768;
 pub const SF_NODISKIO: ::c_int = 0x00000001;
 pub const SF_MNOWAIT: ::c_int = 0x00000002;
 pub const SF_SYNC: ::c_int = 0x00000004;
@@ -442,7 +449,13 @@
 pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 14;
 pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 15;
 
+#[doc(hidden)]
+#[deprecated(
+    since = "0.2.72",
+    note = "CTL_UNSPEC is deprecated. Use CTL_SYSCTL instead"
+)]
 pub const CTL_UNSPEC: ::c_int = 0;
+pub const CTL_SYSCTL: ::c_int = 0;
 pub const CTL_KERN: ::c_int = 1;
 pub const CTL_VM: ::c_int = 2;
 pub const CTL_VFS: ::c_int = 3;
@@ -452,6 +465,13 @@
 pub const CTL_MACHDEP: ::c_int = 7;
 pub const CTL_USER: ::c_int = 8;
 pub const CTL_P1003_1B: ::c_int = 9;
+pub const CTL_SYSCTL_DEBUG: ::c_int = 0;
+pub const CTL_SYSCTL_NAME: ::c_int = 1;
+pub const CTL_SYSCTL_NEXT: ::c_int = 2;
+pub const CTL_SYSCTL_NAME2OID: ::c_int = 3;
+pub const CTL_SYSCTL_OIDFMT: ::c_int = 4;
+pub const CTL_SYSCTL_OIDDESCR: ::c_int = 5;
+pub const CTL_SYSCTL_OIDLABEL: ::c_int = 6;
 pub const KERN_OSTYPE: ::c_int = 1;
 pub const KERN_OSRELEASE: ::c_int = 2;
 pub const KERN_OSREV: ::c_int = 3;
@@ -769,8 +789,14 @@
 pub const IPPROTO_NSP: ::c_int = 31;
 /// Merit Internodal
 pub const IPPROTO_INP: ::c_int = 32;
-/// Sequential Exchange
+#[doc(hidden)]
+#[deprecated(
+    since = "0.2.72",
+    note = "IPPROTO_SEP is deprecated. Use IPPROTO_DCCP instead"
+)]
 pub const IPPROTO_SEP: ::c_int = 33;
+/// Datagram Congestion Control Protocol
+pub const IPPROTO_DCCP: ::c_int = 33;
 /// Third Party Connect
 pub const IPPROTO_3PC: ::c_int = 34;
 /// InterDomain Policy Routing
@@ -1161,6 +1187,10 @@
         ::mem::size_of::<sockcred>() + ::mem::size_of::<::gid_t>() * ngrps
     }
 
+    pub fn WIFSIGNALED(status: ::c_int) -> bool {
+        (status & 0o177) != 0o177 && (status & 0o177) != 0 && status != 0x13
+    }
+
     pub fn uname(buf: *mut ::utsname) -> ::c_int {
         __xuname(256, buf as *mut ::c_void)
     }
diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs
index 5c0c6e7..7f5b975 100644
--- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs
@@ -1,8 +1,10 @@
 pub type c_char = u8;
 pub type c_long = i64;
 pub type c_ulong = u64;
+pub type wchar_t = i32;
 pub type time_t = i64;
 pub type suseconds_t = i64;
+pub type register_t = i64;
 
 s! {
     pub struct stat {
@@ -42,3 +44,4 @@
 }
 
 pub const MAP_32BIT: ::c_int = 0x00080000;
+pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4
diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs
index adec88c..d3a3f34 100644
--- a/src/unix/bsd/freebsdlike/freebsd/x86.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs
@@ -1,8 +1,10 @@
 pub type c_char = i8;
 pub type c_long = i32;
 pub type c_ulong = u32;
+pub type wchar_t = i32;
 pub type time_t = i32;
 pub type suseconds_t = i32;
+pub type register_t = i32;
 
 s! {
     pub struct stat {
@@ -38,6 +40,7 @@
         pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
     } else {
         #[doc(hidden)]
-        pub const _ALIGNBYTES: usize = 8 - 1;
+        pub const _ALIGNBYTES: usize = 4 - 1;
     }
 }
+pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4
diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs
index 7ca870f..3a016a0 100644
--- a/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs
@@ -1,7 +1,197 @@
+use {c_long, register_t};
+
 s_no_extra_traits! {
     #[allow(missing_debug_implementations)]
     #[repr(align(16))]
     pub struct max_align_t {
         priv_: [f64; 4]
     }
+
+    #[repr(align(16))]
+    pub struct mcontext_t {
+        pub mc_onstack: register_t,
+        pub mc_rdi: register_t,
+        pub mc_rsi: register_t,
+        pub mc_rdx: register_t,
+        pub mc_rcx: register_t,
+        pub mc_r8: register_t,
+        pub mc_r9: register_t,
+        pub mc_rax: register_t,
+        pub mc_rbx: register_t,
+        pub mc_rbp: register_t,
+        pub mc_r10: register_t,
+        pub mc_r11: register_t,
+        pub mc_r12: register_t,
+        pub mc_r13: register_t,
+        pub mc_r14: register_t,
+        pub mc_r15: register_t,
+        pub mc_trapno: u32,
+        pub mc_fs: u16,
+        pub mc_gs: u16,
+        pub mc_addr: register_t,
+        pub mc_flags: u32,
+        pub mc_es: u16,
+        pub mc_ds: u16,
+        pub mc_err: register_t,
+        pub mc_rip: register_t,
+        pub mc_cs: register_t,
+        pub mc_rflags: register_t,
+        pub mc_rsp: register_t,
+        pub mc_ss: register_t,
+        pub mc_len: c_long,
+        pub mc_fpformat: c_long,
+        pub mc_ownedfp: c_long,
+        pub mc_fpstate: [c_long; 64],
+        pub mc_fsbase: register_t,
+        pub mc_gsbase: register_t,
+        pub mc_xfpustate: register_t,
+        pub mc_xfpustate_len: register_t,
+        pub mc_spare: [c_long; 4],
+    }
+}
+
+cfg_if! {
+    if #[cfg(feature = "extra_traits")] {
+        impl PartialEq for mcontext_t {
+            fn eq(&self, other: &mcontext_t) -> bool {
+                self.mc_onstack == other.mc_onstack &&
+                self.mc_rdi == other.mc_rdi &&
+                self.mc_rsi == other.mc_rsi &&
+                self.mc_rdx == other.mc_rdx &&
+                self.mc_rcx == other.mc_rcx &&
+                self.mc_r8 == other.mc_r8 &&
+                self.mc_r9 == other.mc_r9 &&
+                self.mc_rax == other.mc_rax &&
+                self.mc_rbx == other.mc_rbx &&
+                self.mc_rbp == other.mc_rbp &&
+                self.mc_r10 == other.mc_r10 &&
+                self.mc_r11 == other.mc_r11 &&
+                self.mc_r12 == other.mc_r12 &&
+                self.mc_r13 == other.mc_r13 &&
+                self.mc_r14 == other.mc_r14 &&
+                self.mc_r15 == other.mc_r15 &&
+                self.mc_trapno == other.mc_trapno &&
+                self.mc_fs == other.mc_fs &&
+                self.mc_gs == other.mc_gs &&
+                self.mc_addr == other.mc_addr &&
+                self.mc_flags == other.mc_flags &&
+                self.mc_es == other.mc_es &&
+                self.mc_ds == other.mc_ds &&
+                self.mc_err == other.mc_err &&
+                self.mc_rip == other.mc_rip &&
+                self.mc_cs == other.mc_cs &&
+                self.mc_rflags == other.mc_rflags &&
+                self.mc_rsp == other.mc_rsp &&
+                self.mc_ss == other.mc_ss &&
+                self.mc_len == other.mc_len &&
+                self.mc_fpformat == other.mc_fpformat &&
+                self.mc_ownedfp == other.mc_ownedfp &&
+                self.mc_fpstate.iter().zip(other.mc_fpstate.iter())
+                .all(|(a, b)| a == b) &&
+                self.mc_fsbase == other.mc_fsbase &&
+                self.mc_gsbase == other.mc_gsbase &&
+                self.mc_xfpustate == other.mc_xfpustate &&
+                self.mc_xfpustate_len == other.mc_xfpustate_len &&
+                self.mc_spare == other.mc_spare
+            }
+        }
+        impl Eq for mcontext_t {}
+        impl ::fmt::Debug for mcontext_t {
+            fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+                f.debug_struct("mcontext_t")
+                    .field("mc_onstack", &self.mc_onstack)
+                    .field("mc_rdi", &self.mc_rdi)
+                    .field("mc_rsi", &self.mc_rsi)
+                    .field("mc_rdx", &self.mc_rdx)
+                    .field("mc_rcx", &self.mc_rcx)
+                    .field("mc_r8", &self.mc_r8)
+                    .field("mc_r9", &self.mc_r9)
+                    .field("mc_rax", &self.mc_rax)
+                    .field("mc_rbx", &self.mc_rbx)
+                    .field("mc_rbp", &self.mc_rbp)
+                    .field("mc_r10", &self.mc_r10)
+                    .field("mc_r11", &self.mc_r11)
+                    .field("mc_r12", &self.mc_r12)
+                    .field("mc_r13", &self.mc_r13)
+                    .field("mc_r14", &self.mc_r14)
+                    .field("mc_r15", &self.mc_r15)
+                    .field("mc_trapno", &self.mc_trapno)
+                    .field("mc_fs", &self.mc_fs)
+                    .field("mc_gs", &self.mc_gs)
+                    .field("mc_addr", &self.mc_addr)
+                    .field("mc_flags", &self.mc_flags)
+                    .field("mc_es", &self.mc_es)
+                    .field("mc_ds", &self.mc_ds)
+                    .field("mc_err", &self.mc_err)
+                    .field("mc_rip", &self.mc_rip)
+                    .field("mc_cs", &self.mc_cs)
+                    .field("mc_rflags", &self.mc_rflags)
+                    .field("mc_rsp", &self.mc_rsp)
+                    .field("mc_ss", &self.mc_ss)
+                    .field("mc_len", &self.mc_len)
+                    .field("mc_fpformat", &self.mc_fpformat)
+                    .field("mc_ownedfp", &self.mc_ownedfp)
+                    // FIXME: .field("mc_fpstate", &self.mc_fpstate)
+                    .field("mc_fsbase", &self.mc_fsbase)
+                    .field("mc_gsbase", &self.mc_gsbase)
+                    .field("mc_xfpustate", &self.mc_xfpustate)
+                    .field("mc_xfpustate_len", &self.mc_xfpustate_len)
+                    .field("mc_spare", &self.mc_spare)
+                    .finish()
+            }
+        }
+        impl ::hash::Hash for mcontext_t {
+            fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+                self.mc_onstack.hash(state);
+                self.mc_rdi.hash(state);
+                self.mc_rsi.hash(state);
+                self.mc_rdx.hash(state);
+                self.mc_rcx.hash(state);
+                self.mc_r8.hash(state);
+                self.mc_r9.hash(state);
+                self.mc_rax.hash(state);
+                self.mc_rbx.hash(state);
+                self.mc_rbp.hash(state);
+                self.mc_r10.hash(state);
+                self.mc_r11.hash(state);
+                self.mc_r12.hash(state);
+                self.mc_r13.hash(state);
+                self.mc_r14.hash(state);
+                self.mc_r15.hash(state);
+                self.mc_trapno.hash(state);
+                self.mc_fs.hash(state);
+                self.mc_gs.hash(state);
+                self.mc_addr.hash(state);
+                self.mc_flags.hash(state);
+                self.mc_es.hash(state);
+                self.mc_ds.hash(state);
+                self.mc_err.hash(state);
+                self.mc_rip.hash(state);
+                self.mc_cs.hash(state);
+                self.mc_rflags.hash(state);
+                self.mc_rsp.hash(state);
+                self.mc_ss.hash(state);
+                self.mc_len.hash(state);
+                self.mc_fpformat.hash(state);
+                self.mc_ownedfp.hash(state);
+                self.mc_fpstate.hash(state);
+                self.mc_fsbase.hash(state);
+                self.mc_gsbase.hash(state);
+                self.mc_xfpustate.hash(state);
+                self.mc_xfpustate_len.hash(state);
+                self.mc_spare.hash(state);
+            }
+        }
+    }
+}
+
+s! {
+    pub struct ucontext_t {
+        pub uc_sigmask: ::sigset_t,
+        pub uc_mcontext: ::mcontext_t,
+        pub uc_link: *mut ::ucontext_t,
+        pub uc_stack: ::stack_t,
+        pub uc_flags: ::c_int,
+        __spare__: [::c_int; 4],
+    }
 }
diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs
index 0769a22..d3333c8 100644
--- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs
@@ -1,8 +1,180 @@
 pub type c_char = i8;
 pub type c_long = i64;
 pub type c_ulong = u64;
+pub type wchar_t = i32;
 pub type time_t = i64;
 pub type suseconds_t = i64;
+pub type register_t = i64;
+
+s! {
+    pub struct reg32 {
+        pub r_fs: u32,
+        pub r_es: u32,
+        pub r_ds: u32,
+        pub r_edi: u32,
+        pub r_esi: u32,
+        pub r_ebp: u32,
+        pub r_isp: u32,
+        pub r_ebx: u32,
+        pub r_edx: u32,
+        pub r_ecx: u32,
+        pub r_eax: u32,
+        pub r_trapno: u32,
+        pub r_err: u32,
+        pub r_eip: u32,
+        pub r_cs: u32,
+        pub r_eflags: u32,
+        pub r_esp: u32,
+        pub r_ss: u32,
+        pub r_gs: u32,
+    }
+
+    pub struct reg {
+        pub r_r15: i64,
+        pub r_r14: i64,
+        pub r_r13: i64,
+        pub r_r12: i64,
+        pub r_r11: i64,
+        pub r_r10: i64,
+        pub r_r9: i64,
+        pub r_r8: i64,
+        pub r_rdi: i64,
+        pub r_rsi: i64,
+        pub r_rbp: i64,
+        pub r_rbx: i64,
+        pub r_rdx: i64,
+        pub r_rcx: i64,
+        pub r_rax: i64,
+        pub r_trapno: u32,
+        pub r_fs: u16,
+        pub r_gs: u16,
+        pub r_err: u32,
+        pub r_es: u16,
+        pub r_ds: u16,
+        pub r_rip: i64,
+        pub r_cs: i64,
+        pub r_rflags: i64,
+        pub r_rsp: i64,
+        pub r_ss: i64,
+    }
+}
+
+s_no_extra_traits! {
+    pub struct fpreg32 {
+        pub fpr_env: [u32; 7],
+        pub fpr_acc: [[u8; 10]; 8],
+        pub fpr_ex_sw: u32,
+        pub fpr_pad: [u8; 64],
+    }
+
+    pub struct fpreg {
+        pub fpr_env: [u64; 4],
+        pub fpr_acc: [[u8; 16]; 8],
+        pub fpr_xacc: [[u8; 16]; 16],
+        pub fpr_spare: [u64; 12],
+    }
+
+    pub struct xmmreg {
+        pub xmm_env: [u32; 8],
+        pub xmm_acc: [[u8; 16]; 8],
+        pub xmm_reg: [[u8; 16]; 8],
+        pub xmm_pad: [u8; 224],
+    }
+}
+
+cfg_if! {
+    if #[cfg(feature = "extra_traits")] {
+        impl PartialEq for fpreg32 {
+            fn eq(&self, other: &fpreg32) -> bool {
+                self.fpr_env == other.fpr_env &&
+                    self.fpr_acc == other.fpr_acc &&
+                    self.fpr_ex_sw == other.fpr_ex_sw &&
+                    self.fpr_pad
+                        .iter()
+                        .zip(other.fpr_pad.iter())
+                        .all(|(a,b)| a == b)
+            }
+        }
+        impl Eq for fpreg32 {}
+        impl ::fmt::Debug for fpreg32 {
+            fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+                f.debug_struct("fpreg32")
+                    .field("fpr_env", &&self.fpr_env[..])
+                    .field("fpr_acc", &self.fpr_acc)
+                    .field("fpr_ex_sw", &self.fpr_ex_sw)
+                    .field("fpr_pad", &&self.fpr_pad[..])
+                    .finish()
+            }
+        }
+        impl ::hash::Hash for fpreg32 {
+            fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+                self.fpr_env.hash(state);
+                self.fpr_acc.hash(state);
+                self.fpr_ex_sw.hash(state);
+                self.fpr_pad.hash(state);
+            }
+        }
+
+        impl PartialEq for fpreg {
+            fn eq(&self, other: &fpreg) -> bool {
+                self.fpr_env == other.fpr_env &&
+                    self.fpr_acc == other.fpr_acc &&
+                    self.fpr_xacc == other.fpr_xacc &&
+                    self.fpr_spare == other.fpr_spare
+            }
+        }
+        impl Eq for fpreg {}
+        impl ::fmt::Debug for fpreg {
+            fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+                f.debug_struct("fpreg")
+                    .field("fpr_env", &self.fpr_env)
+                    .field("fpr_acc", &self.fpr_acc)
+                    .field("fpr_xacc", &self.fpr_xacc)
+                    .field("fpr_spare", &self.fpr_spare)
+                    .finish()
+            }
+        }
+        impl ::hash::Hash for fpreg {
+            fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+                self.fpr_env.hash(state);
+                self.fpr_acc.hash(state);
+                self.fpr_xacc.hash(state);
+                self.fpr_spare.hash(state);
+            }
+        }
+
+        impl PartialEq for xmmreg {
+            fn eq(&self, other: &xmmreg) -> bool {
+                self.xmm_env == other.xmm_env &&
+                    self.xmm_acc == other.xmm_acc &&
+                    self.xmm_reg == other.xmm_reg &&
+                    self.xmm_pad
+                        .iter()
+                        .zip(other.xmm_pad.iter())
+                        .all(|(a,b)| a == b)
+            }
+        }
+        impl Eq for xmmreg {}
+        impl ::fmt::Debug for xmmreg {
+            fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+                f.debug_struct("xmmreg")
+                    .field("xmm_env", &self.xmm_env)
+                    .field("xmm_acc", &self.xmm_acc)
+                    .field("xmm_reg", &self.xmm_reg)
+                    .field("xmm_pad", &&self.xmm_pad[..])
+                    .finish()
+            }
+        }
+        impl ::hash::Hash for xmmreg {
+            fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+                self.xmm_env.hash(state);
+                self.xmm_acc.hash(state);
+                self.xmm_reg.hash(state);
+                self.xmm_pad.hash(state);
+            }
+        }
+    }
+}
 
 // should be pub(crate), but that requires Rust 1.18.0
 cfg_if! {
@@ -15,6 +187,18 @@
     }
 }
 pub const MAP_32BIT: ::c_int = 0x00080000;
+pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4
+
+pub const _MC_HASSEGS: u32 = 0x1;
+pub const _MC_HASBASES: u32 = 0x2;
+pub const _MC_HASFPXSTATE: u32 = 0x4;
+pub const _MC_FLAG_MASK: u32 = _MC_HASSEGS | _MC_HASBASES | _MC_HASFPXSTATE;
+
+pub const _MC_FPFMT_NODEV: c_long = 0x10000;
+pub const _MC_FPFMT_XMM: c_long = 0x10002;
+pub const _MC_FPOWNED_NONE: c_long = 0x20000;
+pub const _MC_FPOWNED_FPU: c_long = 0x20001;
+pub const _MC_FPOWNED_PCB: c_long = 0x20002;
 
 cfg_if! {
     if #[cfg(libc_align)] {
diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs
index 44457c3..3158ed0 100644
--- a/src/unix/bsd/freebsdlike/mod.rs
+++ b/src/unix/bsd/freebsdlike/mod.rs
@@ -1194,10 +1194,6 @@
         status >> 8
     }
 
-    pub fn WIFSIGNALED(status: ::c_int) -> bool {
-        (status & 0o177) != 0o177 && (status & 0o177) != 0
-    }
-
     pub fn WIFSTOPPED(status: ::c_int) -> bool {
         (status & 0o177) == 0o177
     }
@@ -1219,17 +1215,6 @@
         addrlen: *mut ::socklen_t,
         flags: ::c_int,
     ) -> ::c_int;
-    pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
-    pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
-    pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
-    pub fn aio_error(aiocbp: *const aiocb) -> ::c_int;
-    pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t;
-    pub fn aio_suspend(
-        aiocb_list: *const *const aiocb,
-        nitems: ::c_int,
-        timeout: *const ::timespec,
-    ) -> ::c_int;
-    pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
     pub fn chflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int;
     pub fn chflagsat(
         fd: ::c_int,
@@ -1315,43 +1300,6 @@
         mode: ::mode_t,
         dev: dev_t,
     ) -> ::c_int;
-    pub fn mq_close(mqd: ::mqd_t) -> ::c_int;
-    pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int;
-    pub fn mq_notify(mqd: ::mqd_t, notification: *const ::sigevent)
-        -> ::c_int;
-    pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t;
-    pub fn mq_receive(
-        mqd: ::mqd_t,
-        msg_ptr: *mut ::c_char,
-        msg_len: ::size_t,
-        msg_prio: *mut ::c_uint,
-    ) -> ::ssize_t;
-    pub fn mq_send(
-        mqd: ::mqd_t,
-        msg_ptr: *const ::c_char,
-        msg_len: ::size_t,
-        msg_prio: ::c_uint,
-    ) -> ::c_int;
-    pub fn mq_setattr(
-        mqd: ::mqd_t,
-        newattr: *const ::mq_attr,
-        oldattr: *mut ::mq_attr,
-    ) -> ::c_int;
-    pub fn mq_timedreceive(
-        mqd: ::mqd_t,
-        msg_ptr: *mut ::c_char,
-        msg_len: ::size_t,
-        msg_prio: *mut ::c_uint,
-        abs_timeout: *const ::timespec,
-    ) -> ::ssize_t;
-    pub fn mq_timedsend(
-        mqd: ::mqd_t,
-        msg_ptr: *const ::c_char,
-        msg_len: ::size_t,
-        msg_prio: ::c_uint,
-        abs_timeout: *const ::timespec,
-    ) -> ::c_int;
-    pub fn mq_unlink(name: *const ::c_char) -> ::c_int;
     pub fn mincore(
         addr: *const ::c_void,
         len: ::size_t,
@@ -1521,6 +1469,58 @@
     pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int;
 }
 
+#[link(name = "rt")]
+extern "C" {
+    pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
+    pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
+    pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
+    pub fn aio_error(aiocbp: *const aiocb) -> ::c_int;
+    pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t;
+    pub fn aio_suspend(
+        aiocb_list: *const *const aiocb,
+        nitems: ::c_int,
+        timeout: *const ::timespec,
+    ) -> ::c_int;
+    pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
+    pub fn mq_close(mqd: ::mqd_t) -> ::c_int;
+    pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int;
+    pub fn mq_notify(mqd: ::mqd_t, notification: *const ::sigevent)
+        -> ::c_int;
+    pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t;
+    pub fn mq_receive(
+        mqd: ::mqd_t,
+        msg_ptr: *mut ::c_char,
+        msg_len: ::size_t,
+        msg_prio: *mut ::c_uint,
+    ) -> ::ssize_t;
+    pub fn mq_send(
+        mqd: ::mqd_t,
+        msg_ptr: *const ::c_char,
+        msg_len: ::size_t,
+        msg_prio: ::c_uint,
+    ) -> ::c_int;
+    pub fn mq_setattr(
+        mqd: ::mqd_t,
+        newattr: *const ::mq_attr,
+        oldattr: *mut ::mq_attr,
+    ) -> ::c_int;
+    pub fn mq_timedreceive(
+        mqd: ::mqd_t,
+        msg_ptr: *mut ::c_char,
+        msg_len: ::size_t,
+        msg_prio: *mut ::c_uint,
+        abs_timeout: *const ::timespec,
+    ) -> ::ssize_t;
+    pub fn mq_timedsend(
+        mqd: ::mqd_t,
+        msg_ptr: *const ::c_char,
+        msg_len: ::size_t,
+        msg_prio: ::c_uint,
+        abs_timeout: *const ::timespec,
+    ) -> ::c_int;
+    pub fn mq_unlink(name: *const ::c_char) -> ::c_int;
+}
+
 #[link(name = "util")]
 extern "C" {
     pub fn openpty(
diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs
index a70c1d9..1b55078 100644
--- a/src/unix/bsd/mod.rs
+++ b/src/unix/bsd/mod.rs
@@ -1,4 +1,3 @@
-pub type wchar_t = i32;
 pub type off_t = i64;
 pub type useconds_t = u32;
 pub type blkcnt_t = i64;
@@ -581,7 +580,15 @@
     pub fn abs(i: ::c_int) -> ::c_int;
     pub fn atof(s: *const ::c_char) -> ::c_double;
     pub fn labs(i: ::c_long) -> ::c_long;
+    #[cfg_attr(
+        all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)),
+        link_name = "rand@FBSD_1.0"
+    )]
     pub fn rand() -> ::c_int;
+    #[cfg_attr(
+        all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)),
+        link_name = "srand@FBSD_1.0"
+    )]
     pub fn srand(seed: ::c_uint);
 
     pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int;
diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs
index 976b95c..a2a8407 100644
--- a/src/unix/bsd/netbsdlike/mod.rs
+++ b/src/unix/bsd/netbsdlike/mod.rs
@@ -1,3 +1,4 @@
+pub type wchar_t = i32;
 pub type time_t = i64;
 pub type mode_t = u32;
 pub type nlink_t = u32;
diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs
index e7b104e..27f88f1 100644
--- a/src/unix/haiku/mod.rs
+++ b/src/unix/haiku/mod.rs
@@ -962,6 +962,10 @@
 pub const _SC_TIMERS: ::c_int = 58;
 pub const _SC_CPUTIME: ::c_int = 59;
 pub const _SC_THREAD_CPUTIME: ::c_int = 60;
+pub const _SC_HOST_NAME_MAX: ::c_int = 61;
+pub const _SC_REGEXP: ::c_int = 62;
+pub const _SC_SYMLOOP_MAX: ::c_int = 63;
+pub const _SC_SHELL: ::c_int = 64;
 
 pub const PTHREAD_STACK_MIN: ::size_t = 8192;
 
diff --git a/src/unix/linux_like/android/b64/aarch64/align.rs b/src/unix/linux_like/android/b64/aarch64/align.rs
index 8e94996..154c2c5 100644
--- a/src/unix/linux_like/android/b64/aarch64/align.rs
+++ b/src/unix/linux_like/android/b64/aarch64/align.rs
@@ -5,3 +5,25 @@
         priv_: [f32; 8]
     }
 }
+
+s! {
+    pub struct ucontext_t {
+        pub uc_flags: ::c_ulong,
+        pub uc_link: *mut ucontext_t,
+        pub uc_stack: ::stack_t,
+        pub uc_sigmask: ::sigset_t,
+        pub uc_mcontext: mcontext_t,
+    }
+
+    #[repr(align(16))]
+    pub struct mcontext_t {
+        pub fault_address: ::c_ulonglong,
+        pub regs: [::c_ulonglong; 31],
+        pub sp: ::c_ulonglong,
+        pub pc: ::c_ulonglong,
+        pub pstate: ::c_ulonglong,
+        // nested arrays to get the right size/length while being able to
+        // auto-derive traits like Debug
+        __reserved: [[u64; 32]; 16],
+    }
+}
diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs
index b2b9188..b7a21e1 100644
--- a/src/unix/linux_like/android/b64/aarch64/mod.rs
+++ b/src/unix/linux_like/android/b64/aarch64/mod.rs
@@ -322,7 +322,7 @@
 pub const SYS_pkey_mprotect: ::c_long = 288;
 pub const SYS_pkey_alloc: ::c_long = 289;
 pub const SYS_pkey_free: ::c_long = 290;
-pub const SYS_syscalls: ::c_long = 292;
+pub const SYS_syscalls: ::c_long = 436;
 
 cfg_if! {
     if #[cfg(libc_align)] {
diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs
index 9cc1c77..9f369e4 100644
--- a/src/unix/linux_like/android/mod.rs
+++ b/src/unix/linux_like/android/mod.rs
@@ -19,6 +19,7 @@
 pub type rlim_t = ::c_ulong;
 pub type dev_t = ::c_ulong;
 pub type ino_t = ::c_ulong;
+pub type ino64_t = u64;
 pub type __CPU_BITTYPE = ::c_ulong;
 pub type idtype_t = ::c_int;
 pub type loff_t = ::c_longlong;
@@ -147,6 +148,11 @@
         _pad: [u8; 28],
     }
 
+    pub struct itimerspec {
+        pub it_interval: ::timespec,
+        pub it_value: ::timespec,
+    }
+
     pub struct ucred {
         pub pid: ::pid_t,
         pub uid: ::uid_t,
@@ -629,11 +635,27 @@
 pub const EPOLLRDHUP: ::c_int = 0x00002000;
 pub const EPOLLWAKEUP: ::c_int = 0x20000000;
 
-pub const EFD_CLOEXEC: ::c_int = 0x80000;
+// sys/eventfd.h
+pub const EFD_SEMAPHORE: ::c_int = 0x1;
+pub const EFD_CLOEXEC: ::c_int = O_CLOEXEC;
+pub const EFD_NONBLOCK: ::c_int = O_NONBLOCK;
+
+// sys/timerfd.h
+pub const TFD_CLOEXEC: ::c_int = O_CLOEXEC;
+pub const TFD_NONBLOCK: ::c_int = O_NONBLOCK;
+pub const TFD_TIMER_ABSTIME: ::c_int = 1;
+pub const TFD_TIMER_CANCEL_ON_SET: ::c_int = 2;
 
 pub const USER_PROCESS: ::c_short = 7;
 
+// linux/falloc.h
+pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01;
+pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02;
+pub const FALLOC_FL_NO_HIDE_STALE: ::c_int = 0x04;
 pub const FALLOC_FL_COLLAPSE_RANGE: ::c_int = 0x08;
+pub const FALLOC_FL_ZERO_RANGE: ::c_int = 0x10;
+pub const FALLOC_FL_INSERT_RANGE: ::c_int = 0x20;
+pub const FALLOC_FL_UNSHARE_RANGE: ::c_int = 0x40;
 
 pub const BUFSIZ: ::c_uint = 1024;
 pub const FILENAME_MAX: ::c_uint = 4096;
@@ -804,6 +826,11 @@
 pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
 pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
 
+// stdio.h
+pub const RENAME_NOREPLACE: ::c_int = 1;
+pub const RENAME_EXCHANGE: ::c_int = 2;
+pub const RENAME_WHITEOUT: ::c_int = 4;
+
 pub const FIOCLEX: ::c_int = 0x5451;
 pub const FIONCLEX: ::c_int = 0x5450;
 
@@ -1097,8 +1124,6 @@
 pub const PTRACE_GETSIGINFO: ::c_int = 0x4202;
 pub const PTRACE_SETSIGINFO: ::c_int = 0x4203;
 
-pub const EFD_NONBLOCK: ::c_int = 0x800;
-
 pub const F_GETLK: ::c_int = 5;
 pub const F_GETOWN: ::c_int = 9;
 pub const F_SETOWN: ::c_int = 8;
@@ -2148,6 +2173,18 @@
 pub const PRIO_PGRP: ::c_int = 1;
 pub const PRIO_USER: ::c_int = 2;
 
+// linux/sched.h
+pub const SCHED_NORMAL: ::c_int = 0;
+pub const SCHED_FIFO: ::c_int = 1;
+pub const SCHED_RR: ::c_int = 2;
+pub const SCHED_BATCH: ::c_int = 3;
+pub const SCHED_IDLE: ::c_int = 5;
+pub const SCHED_DEADLINE: ::c_int = 6;
+
+// bits/seek_constants.h
+pub const SEEK_DATA: ::c_int = 3;
+pub const SEEK_HOLE: ::c_int = 4;
+
 f! {
     pub fn CMSG_NXTHDR(mhdr: *const msghdr,
                        cmsg: *const cmsghdr) -> *mut cmsghdr {
@@ -2218,6 +2255,18 @@
     pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int;
     pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
     pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
+    pub fn prlimit(
+        pid: ::pid_t,
+        resource: ::c_int,
+        new_limit: *const ::rlimit,
+        old_limit: *mut ::rlimit,
+    ) -> ::c_int;
+    pub fn prlimit64(
+        pid: ::pid_t,
+        resource: ::c_int,
+        new_limit: *const ::rlimit64,
+        old_limit: *mut ::rlimit64,
+    ) -> ::c_int;
     pub fn strerror_r(
         errnum: ::c_int,
         buf: *mut c_char,
@@ -2273,16 +2322,101 @@
     pub fn setutent();
     pub fn getutent() -> *mut utmp;
 
+    pub fn fallocate(
+        fd: ::c_int,
+        mode: ::c_int,
+        offset: ::off_t,
+        len: ::off_t,
+    ) -> ::c_int;
+    pub fn fallocate64(
+        fd: ::c_int,
+        mode: ::c_int,
+        offset: ::off64_t,
+        len: ::off64_t,
+    ) -> ::c_int;
     pub fn posix_fallocate(
         fd: ::c_int,
         offset: ::off_t,
         len: ::off_t,
     ) -> ::c_int;
+    pub fn posix_fallocate64(
+        fd: ::c_int,
+        offset: ::off64_t,
+        len: ::off64_t,
+    ) -> ::c_int;
+    pub fn getxattr(
+        path: *const c_char,
+        name: *const c_char,
+        value: *mut ::c_void,
+        size: ::size_t,
+    ) -> ::ssize_t;
+    pub fn lgetxattr(
+        path: *const c_char,
+        name: *const c_char,
+        value: *mut ::c_void,
+        size: ::size_t,
+    ) -> ::ssize_t;
+    pub fn fgetxattr(
+        filedes: ::c_int,
+        name: *const c_char,
+        value: *mut ::c_void,
+        size: ::size_t,
+    ) -> ::ssize_t;
+    pub fn setxattr(
+        path: *const c_char,
+        name: *const c_char,
+        value: *const ::c_void,
+        size: ::size_t,
+        flags: ::c_int,
+    ) -> ::c_int;
+    pub fn lsetxattr(
+        path: *const c_char,
+        name: *const c_char,
+        value: *const ::c_void,
+        size: ::size_t,
+        flags: ::c_int,
+    ) -> ::c_int;
+    pub fn fsetxattr(
+        filedes: ::c_int,
+        name: *const c_char,
+        value: *const ::c_void,
+        size: ::size_t,
+        flags: ::c_int,
+    ) -> ::c_int;
+    pub fn listxattr(
+        path: *const c_char,
+        list: *mut c_char,
+        size: ::size_t,
+    ) -> ::ssize_t;
+    pub fn llistxattr(
+        path: *const c_char,
+        list: *mut c_char,
+        size: ::size_t,
+    ) -> ::ssize_t;
+    pub fn flistxattr(
+        filedes: ::c_int,
+        list: *mut c_char,
+        size: ::size_t,
+    ) -> ::ssize_t;
+    pub fn removexattr(path: *const c_char, name: *const c_char) -> ::c_int;
+    pub fn lremovexattr(path: *const c_char, name: *const c_char) -> ::c_int;
+    pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int;
     pub fn signalfd(
         fd: ::c_int,
         mask: *const ::sigset_t,
         flags: ::c_int,
     ) -> ::c_int;
+    pub fn timerfd_create(clock: ::clockid_t, flags: ::c_int) -> ::c_int;
+    pub fn timerfd_gettime(
+        fd: ::c_int,
+        current_value: *mut itimerspec,
+    ) -> ::c_int;
+    pub fn timerfd_settime(
+        fd: ::c_int,
+        flags: ::c_int,
+        new_value: *const itimerspec,
+        old_value: *mut itimerspec,
+    ) -> ::c_int;
     pub fn syscall(num: ::c_long, ...) -> ::c_long;
     pub fn sched_getaffinity(
         pid: ::pid_t,
@@ -2460,6 +2594,11 @@
         buflen: ::size_t,
         result: *mut *mut passwd,
     ) -> ::c_int;
+    pub fn sigtimedwait(
+        set: *const sigset_t,
+        info: *mut siginfo_t,
+        timeout: *const ::timespec,
+    ) -> ::c_int;
     pub fn sigwait(set: *const sigset_t, sig: *mut ::c_int) -> ::c_int;
     pub fn pthread_atfork(
         prepare: ::Option<unsafe extern "C" fn()>,
diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs
index 2c2f568..a65199a 100644
--- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs
+++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs
@@ -756,6 +756,10 @@
 pub const SYS_mount: ::c_long = 40;
 pub const SYS_pivot_root: ::c_long = 41;
 pub const SYS_nfsservctl: ::c_long = 42;
+pub const SYS_statfs: ::c_long = 43;
+pub const SYS_fstatfs: ::c_long = 44;
+pub const SYS_truncate: ::c_long = 45;
+pub const SYS_ftruncate: ::c_long = 46;
 pub const SYS_fallocate: ::c_long = 47;
 pub const SYS_faccessat: ::c_long = 48;
 pub const SYS_chdir: ::c_long = 49;
diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs
index da9890e..aa3e1b3 100644
--- a/src/unix/linux_like/linux/gnu/mod.rs
+++ b/src/unix/linux_like/linux/gnu/mod.rs
@@ -664,32 +664,50 @@
 
 pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5;
 pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff;
+pub const AFS_SUPER_MAGIC: ::c_long = 0x5346414f;
+pub const AUTOFS_SUPER_MAGIC: ::c_long = 0x0187;
+pub const BINDERFS_SUPER_MAGIC: ::c_long = 0x6c6f6f70;
+pub const BTRFS_SUPER_MAGIC: ::c_long = 0x9123683e;
+pub const CGROUP2_SUPER_MAGIC: ::c_long = 0x63677270;
+pub const CGROUP_SUPER_MAGIC: ::c_long = 0x27e0eb;
 pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245;
 pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45;
+pub const DEVPTS_SUPER_MAGIC: ::c_long = 0x1cd1;
+pub const ECRYPTFS_SUPER_MAGIC: ::c_long = 0xf15f;
 pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53;
 pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53;
 pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53;
 pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53;
+pub const F2FS_SUPER_MAGIC: ::c_long = 0xf2f52010;
+pub const FUTEXFS_SUPER_MAGIC: ::c_long = 0xbad1dea;
+pub const HOSTFS_SUPER_MAGIC: ::c_long = 0x00c0ffee;
 pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849;
 pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6;
 pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660;
 pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6;
-pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f;
-pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f;
-pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468;
 pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478;
+pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468;
+pub const MINIX3_SUPER_MAGIC: ::c_long = 0x4d5a;
+pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f;
+pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f;
 pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44;
 pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c;
 pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969;
+pub const NILFS_SUPER_MAGIC: ::c_long = 0x3434;
+pub const OCFS2_SUPER_MAGIC: ::c_long = 0x7461636f;
 pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1;
+pub const OVERLAYFS_SUPER_MAGIC: ::c_long = 0x794c7630;
 pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0;
 pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f;
+pub const QNX6_SUPER_MAGIC: ::c_long = 0x68191122;
+pub const RDTGROUP_SUPER_MAGIC: ::c_long = 0x7655821;
 pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973;
 pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b;
 pub const TMPFS_MAGIC: ::c_long = 0x01021994;
+pub const UDF_SUPER_MAGIC: ::c_long = 0x15013346;
 pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2;
-pub const CGROUP_SUPER_MAGIC: ::c_long = 0x27e0eb;
-pub const CGROUP2_SUPER_MAGIC: ::c_long = 0x63677270;
+pub const XENFS_SUPER_MAGIC: ::c_long = 0xabba1974;
+pub const XFS_SUPER_MAGIC: ::c_long = 0x58465342;
 
 pub const CPU_SETSIZE: ::c_int = 0x400;
 
diff --git a/src/unix/linux_like/linux/musl/b32/hexagon.rs b/src/unix/linux_like/linux/musl/b32/hexagon.rs
index 8124e4b..0006197 100644
--- a/src/unix/linux_like/linux/musl/b32/hexagon.rs
+++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs
@@ -222,6 +222,7 @@
 pub const ESTALE: ::c_int = 116;
 pub const ESTRPIPE: ::c_int = 86;
 pub const ETOOMANYREFS: ::c_int = 109;
+pub const ETIMEDOUT: ::c_int = 110;
 pub const EUCLEAN: ::c_int = 117;
 pub const EUNATCH: ::c_int = 49;
 pub const EUSERS: ::c_int = 87;
@@ -299,6 +300,8 @@
 pub const SIGPROF: ::c_int = 27;
 pub const SIGPWR: ::c_int = 30;
 pub const SIGSTKFLT: ::c_int = 16;
+pub const SIGSTKSZ: ::size_t = 8192;
+pub const MINSIGSTKSZ: ::size_t = 2048;
 pub const SIGSTOP: ::c_int = 19;
 pub const SIGSYS: ::c_int = 31;
 pub const SIGTSTP: ::c_int = 20;
diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs
index b251383..f5055b2 100644
--- a/src/unix/linux_like/linux/musl/mod.rs
+++ b/src/unix/linux_like/linux/musl/mod.rs
@@ -138,6 +138,12 @@
         pub rt_window: ::c_ulong,
         pub rt_irtt: ::c_ushort,
     }
+
+    pub struct ip_mreqn {
+        pub imr_multiaddr: ::in_addr,
+        pub imr_address: ::in_addr,
+        pub imr_ifindex: ::c_int,
+    }
 }
 
 s_no_extra_traits! {
diff --git a/src/unix/newlib/aarch64/mod.rs b/src/unix/newlib/aarch64/mod.rs
index 3a68bf4..71aa894 100644
--- a/src/unix/newlib/aarch64/mod.rs
+++ b/src/unix/newlib/aarch64/mod.rs
@@ -30,6 +30,8 @@
     }
 }
 
+pub const AF_INET6: ::c_int = 23;
+
 pub const FIONBIO: ::c_ulong = 1;
 
 pub const POLLIN: ::c_short = 0x1;
@@ -40,3 +42,11 @@
 pub const POLLNVAL: ::c_short = 0x20;
 
 pub const SOL_SOCKET: ::c_int = 65535;
+
+pub const MSG_OOB: ::c_int = 1;
+pub const MSG_PEEK: ::c_int = 2;
+pub const MSG_DONTWAIT: ::c_int = 4;
+pub const MSG_DONTROUTE: ::c_int = 0;
+pub const MSG_WAITALL: ::c_int = 0;
+pub const MSG_MORE: ::c_int = 0;
+pub const MSG_NOSIGNAL: ::c_int = 0;
diff --git a/src/unix/newlib/arm/mod.rs b/src/unix/newlib/arm/mod.rs
index 27274f7..78bea27 100644
--- a/src/unix/newlib/arm/mod.rs
+++ b/src/unix/newlib/arm/mod.rs
@@ -32,6 +32,8 @@
     }
 }
 
+pub const AF_INET6: ::c_int = 23;
+
 pub const FIONBIO: ::c_ulong = 1;
 
 pub const POLLIN: ::c_short = 0x1;
@@ -42,3 +44,11 @@
 pub const POLLNVAL: ::c_short = 0x20;
 
 pub const SOL_SOCKET: ::c_int = 65535;
+
+pub const MSG_OOB: ::c_int = 1;
+pub const MSG_PEEK: ::c_int = 2;
+pub const MSG_DONTWAIT: ::c_int = 4;
+pub const MSG_DONTROUTE: ::c_int = 0;
+pub const MSG_WAITALL: ::c_int = 0;
+pub const MSG_MORE: ::c_int = 0;
+pub const MSG_NOSIGNAL: ::c_int = 0;
diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs
index 5f53f61..55cb889 100644
--- a/src/unix/newlib/mod.rs
+++ b/src/unix/newlib/mod.rs
@@ -416,7 +416,6 @@
 
 pub const AF_UNSPEC: ::c_int = 0;
 pub const AF_INET: ::c_int = 2;
-pub const AF_INET6: ::c_int = 23;
 
 pub const CLOCK_REALTIME: ::clockid_t = 1;
 pub const CLOCK_MONOTONIC: ::clockid_t = 4;
@@ -425,14 +424,6 @@
 pub const SOCK_STREAM: ::c_int = 1;
 pub const SOCK_DGRAM: ::c_int = 2;
 
-pub const MSG_OOB: ::c_int = 1;
-pub const MSG_PEEK: ::c_int = 2;
-pub const MSG_DONTWAIT: ::c_int = 4;
-pub const MSG_DONTROUTE: ::c_int = 0;
-pub const MSG_WAITALL: ::c_int = 0;
-pub const MSG_MORE: ::c_int = 0;
-pub const MSG_NOSIGNAL: ::c_int = 0;
-
 pub const SHUT_RD: ::c_int = 0;
 pub const SHUT_WR: ::c_int = 1;
 pub const SHUT_RDWR: ::c_int = 2;
diff --git a/src/unix/newlib/xtensa/mod.rs b/src/unix/newlib/xtensa/mod.rs
index bf95d9c..bc31506 100644
--- a/src/unix/newlib/xtensa/mod.rs
+++ b/src/unix/newlib/xtensa/mod.rs
@@ -60,6 +60,7 @@
 }
 
 pub const AF_UNIX: ::c_int = 1;
+pub const AF_INET6: ::c_int = 10;
 
 pub const FIONBIO: ::c_ulong = 2147772030;
 
@@ -75,6 +76,14 @@
 
 pub const SOL_SOCKET: ::c_int = 0xfff;
 
+pub const MSG_OOB: ::c_int = 0x04;
+pub const MSG_PEEK: ::c_int = 0x01;
+pub const MSG_DONTWAIT: ::c_int = 0x08;
+pub const MSG_DONTROUTE: ::c_int = 0x4;
+pub const MSG_WAITALL: ::c_int = 0x02;
+pub const MSG_MORE: ::c_int = 0x10;
+pub const MSG_NOSIGNAL: ::c_int = 0x20;
+
 extern "C" {
     pub fn sendmsg(
         s: ::c_int,
diff --git a/src/unix/solarish/illumos.rs b/src/unix/solarish/illumos.rs
index 42b4af3..b52a5f0 100644
--- a/src/unix/solarish/illumos.rs
+++ b/src/unix/solarish/illumos.rs
@@ -18,7 +18,13 @@
 pub const AF_LOCAL: ::c_int = 1; // AF_UNIX
 pub const AF_FILE: ::c_int = 1; // AF_UNIX
 
+pub const EFD_SEMAPHORE: ::c_int = 0x1;
+pub const EFD_NONBLOCK: ::c_int = 0x800;
+pub const EFD_CLOEXEC: ::c_int = 0x80000;
+
 extern "C" {
+    pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
+
     pub fn mincore(
         addr: ::caddr_t,
         len: ::size_t,
diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs
index b0eecf1..c60e678 100644
--- a/src/unix/solarish/mod.rs
+++ b/src/unix/solarish/mod.rs
@@ -950,6 +950,8 @@
 pub const SEEK_SET: ::c_int = 0;
 pub const SEEK_CUR: ::c_int = 1;
 pub const SEEK_END: ::c_int = 2;
+pub const SEEK_DATA: ::c_int = 3;
+pub const SEEK_HOLE: ::c_int = 4;
 pub const _IOFBF: ::c_int = 0;
 pub const _IONBF: ::c_int = 4;
 pub const _IOLBF: ::c_int = 64;
@@ -1102,7 +1104,6 @@
 pub const MS_SYNC: ::c_int = 0x0004;
 pub const MS_ASYNC: ::c_int = 0x0001;
 pub const MS_INVALIDATE: ::c_int = 0x0002;
-pub const MS_INVALCURPROC: ::c_int = 0x0008;
 
 pub const EPERM: ::c_int = 1;
 pub const ENOENT: ::c_int = 2;
@@ -1357,7 +1358,6 @@
 pub const AF_INET_OFFLOAD: ::c_int = 30;
 pub const AF_TRILL: ::c_int = 31;
 pub const AF_PACKET: ::c_int = 32;
-pub const AF_LX_NETLINK: ::c_int = 33;
 
 pub const SOCK_DGRAM: ::c_int = 1;
 pub const SOCK_STREAM: ::c_int = 2;
@@ -1782,8 +1782,6 @@
 pub const TIOCSWINSZ: ::c_int = _TIOC | 103;
 pub const TIOCGSOFTCAR: ::c_int = _TIOC | 105;
 pub const TIOCSSOFTCAR: ::c_int = _TIOC | 106;
-pub const TIOCSETLD: ::c_int = _TIOC | 123;
-pub const TIOCGETLD: ::c_int = _TIOC | 124;
 pub const TIOCGPPS: ::c_int = _TIOC | 125;
 pub const TIOCSPPS: ::c_int = _TIOC | 126;
 pub const TIOCGPPSEV: ::c_int = _TIOC | 127;
@@ -1839,6 +1837,7 @@
 pub const EPOLLET: ::c_int = 0x80000000;
 pub const EPOLLRDHUP: ::c_int = 0x2000;
 pub const EPOLLONESHOT: ::c_int = 0x40000000;
+pub const EPOLLWAKEUP: ::c_int = 0x20000000;
 pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
 pub const EPOLL_CTL_ADD: ::c_int = 1;
 pub const EPOLL_CTL_MOD: ::c_int = 3;
@@ -1999,7 +1998,63 @@
 pub const PRIO_PGRP: ::c_int = 1;
 pub const PRIO_USER: ::c_int = 2;
 
+// As per sys/socket.h, header alignment must be 8 bytes on SPARC
+// and 4 bytes everywhere else:
+#[cfg(target_arch = "sparc64")]
+const _CMSG_HDR_ALIGNMENT: usize = 8;
+#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
+const _CMSG_HDR_ALIGNMENT: usize = 4;
+
+const _CMSG_DATA_ALIGNMENT: usize = ::mem::size_of::<::c_int>();
+
+fn _CMSG_HDR_ALIGN(p: usize) -> usize {
+    (p + _CMSG_HDR_ALIGNMENT - 1) & !(_CMSG_HDR_ALIGNMENT - 1)
+}
+
+fn _CMSG_DATA_ALIGN(p: usize) -> usize {
+    (p + _CMSG_DATA_ALIGNMENT - 1) & !(_CMSG_DATA_ALIGNMENT - 1)
+}
+
 f! {
+    pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar {
+        _CMSG_DATA_ALIGN(cmsg.offset(1) as usize) as *mut ::c_uchar
+    }
+
+    pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
+        _CMSG_DATA_ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length
+    }
+
+    pub fn CMSG_FIRSTHDR(mhdr: *const ::msghdr) -> *mut ::cmsghdr {
+        if ((*mhdr).msg_controllen as usize) < ::mem::size_of::<::cmsghdr>() {
+            0 as *mut ::cmsghdr
+        } else {
+            (*mhdr).msg_control as *mut ::cmsghdr
+        }
+    }
+
+    pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr)
+        -> *mut ::cmsghdr
+    {
+        if cmsg.is_null() {
+            return ::CMSG_FIRSTHDR(mhdr);
+        };
+        let next = _CMSG_HDR_ALIGN(cmsg as usize + (*cmsg).cmsg_len as usize
+            + ::mem::size_of::<::cmsghdr>());
+        let max = (*mhdr).msg_control as usize
+            + (*mhdr).msg_controllen as usize;
+        if next > max {
+            0 as *mut ::cmsghdr
+        } else {
+            _CMSG_HDR_ALIGN(cmsg as usize + (*cmsg).cmsg_len as usize)
+                as *mut ::cmsghdr
+        }
+    }
+
+    pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
+        _CMSG_HDR_ALIGN(::mem::size_of::<::cmsghdr>() as usize
+            + length as usize) as ::c_uint
+    }
+
     pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
         let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
         let fd = fd as usize;
diff --git a/src/unix/uclibc/mod.rs b/src/unix/uclibc/mod.rs
index a68cb7a..de09587 100644
--- a/src/unix/uclibc/mod.rs
+++ b/src/unix/uclibc/mod.rs
@@ -870,6 +870,7 @@
 pub const MSG_CMSG_CLOEXEC: ::c_int = 0x40000000;
 
 pub const SOCK_RAW: ::c_int = 3;
+pub const SOCK_RDM: ::c_int = 4;
 pub const IP_MULTICAST_TTL: ::c_int = 33;
 pub const IP_MULTICAST_LOOP: ::c_int = 34;
 pub const IP_TTL: ::c_int = 2;
diff --git a/src/wasi.rs b/src/wasi.rs
index 081141e..6a26858 100644
--- a/src/wasi.rs
+++ b/src/wasi.rs
@@ -180,6 +180,11 @@
 pub const _IOFBF: c_int = 0;
 pub const _IONBF: c_int = 2;
 pub const _IOLBF: c_int = 1;
+pub const F_GETFD: c_int = 1;
+pub const F_SETFD: c_int = 2;
+pub const F_GETFL: c_int = 3;
+pub const F_SETFL: c_int = 4;
+pub const FD_CLOEXEC: c_int = 1;
 pub const FD_SETSIZE: size_t = 1024;
 pub const O_APPEND: c_int = 0x0001;
 pub const O_DSYNC: c_int = 0x0002;
@@ -209,6 +214,22 @@
 pub const AT_REMOVEDIR: c_int = 0x4;
 pub const UTIME_OMIT: c_long = 0xfffffffe;
 pub const UTIME_NOW: c_long = 0xffffffff;
+pub const S_IFIFO: mode_t = 49152;
+pub const S_IFCHR: mode_t = 8192;
+pub const S_IFBLK: mode_t = 24576;
+pub const S_IFDIR: mode_t = 16384;
+pub const S_IFREG: mode_t = 32768;
+pub const S_IFLNK: mode_t = 40960;
+pub const S_IFSOCK: mode_t = 49152;
+pub const S_IFMT: mode_t = 57344;
+pub const DT_UNKNOWN: u8 = 0;
+pub const DT_BLK: u8 = 1;
+pub const DT_CHR: u8 = 2;
+pub const DT_DIR: u8 = 3;
+pub const DT_REG: u8 = 4;
+pub const DT_LNK: u8 = 7;
+pub const FIONREAD: c_int = 1;
+pub const FIONBIO: c_int = 2;
 
 pub const E2BIG: c_int = 1;
 pub const EACCES: c_int = 2;
@@ -378,6 +399,7 @@
     ) -> size_t;
     pub fn gmtime(a: *const time_t) -> *mut tm;
     pub fn gmtime_r(a: *const time_t, b: *mut tm) -> *mut tm;
+    pub fn localtime(a: *const time_t) -> *mut tm;
     pub fn localtime_r(a: *const time_t, b: *mut tm) -> *mut tm;
     pub fn asctime_r(a: *const tm, b: *mut c_char) -> *mut c_char;
     pub fn ctime_r(a: *const time_t, b: *mut c_char) -> *mut c_char;
@@ -403,6 +425,7 @@
     pub fn isspace(c: c_int) -> c_int;
     pub fn isupper(c: c_int) -> c_int;
     pub fn isxdigit(c: c_int) -> c_int;
+    pub fn isblank(c: c_int) -> c_int;
     pub fn tolower(c: c_int) -> c_int;
     pub fn toupper(c: c_int) -> c_int;
     pub fn setvbuf(
@@ -448,6 +471,7 @@
     pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t;
     pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t;
     pub fn strdup(cs: *const c_char) -> *mut c_char;
+    pub fn strndup(cs: *const c_char, n: size_t) -> *mut c_char;
     pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char;
     pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
     pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int;
@@ -515,6 +539,8 @@
     pub fn closedir(dirp: *mut ::DIR) -> ::c_int;
     pub fn rewinddir(dirp: *mut ::DIR);
     pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
+    pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
+    pub fn telldir(dirp: *mut ::DIR) -> ::c_long;
 
     pub fn openat(
         dirfd: ::c_int,
@@ -575,7 +601,6 @@
     pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int;
     pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t;
     pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
-    pub fn pause() -> ::c_int;
     pub fn rmdir(path: *const c_char) -> ::c_int;
     pub fn sleep(secs: ::c_uint) -> ::c_uint;
     pub fn unlink(c: *const c_char) -> ::c_int;
@@ -643,6 +668,8 @@
 
     pub fn sysconf(name: ::c_int) -> ::c_long;
 
+    pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
+
     pub fn fseeko(
         stream: *mut ::FILE,
         offset: ::off_t,
diff --git a/src/windows/mod.rs b/src/windows/mod.rs
index 54421dd..2770cf9 100644
--- a/src/windows/mod.rs
+++ b/src/windows/mod.rs
@@ -463,6 +463,28 @@
         argv: *const *const c_char,
         envp: *const *const c_char,
     ) -> ::c_int;
+    #[link_name = "_wexecv"]
+    pub fn wexecv(
+        prog: *const wchar_t,
+        argv: *const *const wchar_t,
+    ) -> ::intptr_t;
+    #[link_name = "_wexecve"]
+    pub fn wexecve(
+        prog: *const wchar_t,
+        argv: *const *const wchar_t,
+        envp: *const *const wchar_t,
+    ) -> ::intptr_t;
+    #[link_name = "_wexecvp"]
+    pub fn wexecvp(
+        c: *const wchar_t,
+        argv: *const *const wchar_t,
+    ) -> ::intptr_t;
+    #[link_name = "_wexecvpe"]
+    pub fn wexecvpe(
+        c: *const wchar_t,
+        argv: *const *const wchar_t,
+        envp: *const *const wchar_t,
+    ) -> ::intptr_t;
     #[link_name = "_getcwd"]
     pub fn getcwd(buf: *mut c_char, size: ::c_int) -> *mut c_char;
     #[link_name = "_getpid"]