diff --git a/libc-test/build.rs b/libc-test/build.rs
index 9600c72742deb0ed41a1a496a29ad366beb22773..987ff9dd89c00bfd11f472d14467e226d3fbb10f 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -1995,6 +1995,10 @@ fn test_linux(target: &str) {
         ),
     }
 
+    let arm = target.contains("arm");
+    let x86_64 = target.contains("x86_64");
+    let x86_32 = target.contains("i686");
+    let x32 = target.contains("x32");
     let mips = target.contains("mips");
     let mips32 = mips && !target.contains("64");
 
@@ -2046,7 +2050,6 @@ fn test_linux(target: &str) {
                "stdio.h",
                "stdlib.h",
                "string.h",
-               "sys/sysctl.h",
                "sys/epoll.h",
                "sys/eventfd.h",
                "sys/file.h",
@@ -2097,15 +2100,27 @@ fn test_linux(target: &str) {
 
     // `sys/io.h` is only available on x86*, Alpha, IA64, and 32-bit ARM:
     // https://bugzilla.redhat.com/show_bug.cgi?id=1116162
-    if target.contains("x86") || target.contains("arm") {
+    if x86_64 || x86_32 || arm {
         headers! { cfg: "sys/io.h" }
     }
 
     // `sys/reg.h` is only available on x86 and x86_64
-    if target.contains("x86") {
+    if x86_64 || x86_32 {
         headers! { cfg: "sys/reg.h" }
     }
 
+    // sysctl system call is deprecated and not available on musl
+    // It is also unsupported in x32:
+    if !(x32 || musl) {
+        headers! { cfg:  "sys/sysctl.h"}
+    }
+
+    // <execinfo.h> is not supported by musl:
+    // https://www.openwall.com/lists/musl/2015/04/09/3
+    if !musl {
+        headers! { cfg: "execinfo.h" }
+    }
+
     // Include linux headers at the end:
     headers! {
         cfg:
@@ -2115,7 +2130,6 @@ fn test_linux(target: &str) {
         "linux/fs.h",
         "linux/futex.h",
         "linux/genetlink.h",
-        "linux/if.h",
         "linux/if_addr.h",
         "linux/if_alg.h",
         "linux/if_ether.h",
@@ -2138,6 +2152,11 @@ fn test_linux(target: &str) {
         "sys/auxv.h",
     }
 
+    // FIXME: https://github.com/sabotage-linux/kernel-headers/issues/16
+    if !musl {
+        headers!{ cfg: "linux/if.h" }
+    }
+
     // note: aio.h must be included before sys/mount.h
     headers! { cfg:
                "sys/xattr.h",
diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs
index 05d49002c11be0e456a313c06de3bccf680fa1c1..e4dfa1f6b3036e60230de56670b690aea357fd5a 100644
--- a/src/unix/notbsd/android/mod.rs
+++ b/src/unix/notbsd/android/mod.rs
@@ -548,6 +548,7 @@ cfg_if! {
     }
 }
 
+pub const MADV_SOFT_OFFLINE: ::c_int = 101;
 pub const MS_NOUSER: ::c_ulong = 0xffffffff80000000;
 pub const MS_RMT_MASK: ::c_ulong = 0x02800051;
 
diff --git a/src/unix/notbsd/emscripten/mod.rs b/src/unix/notbsd/emscripten/mod.rs
index f1ab424b88bb0c0e96cdb9824256770df4b5dedf..da4edea5cc8f06f43452dccda757d29331edc079 100644
--- a/src/unix/notbsd/emscripten/mod.rs
+++ b/src/unix/notbsd/emscripten/mod.rs
@@ -574,6 +574,7 @@ cfg_if! {
     }
 }
 
+pub const MADV_SOFT_OFFLINE: ::c_int = 101;
 pub const MS_NOUSER: ::c_ulong = 0x80000000;
 pub const MS_RMT_MASK: ::c_ulong = 0x800051;
 
diff --git a/src/unix/notbsd/linux/mips/mod.rs b/src/unix/notbsd/linux/mips/mod.rs
index c5253accad196e64ae3c04df3af3ce1424134f77..d645fdaa99e44d6a466a15a1226a2bb6b63cc393 100644
--- a/src/unix/notbsd/linux/mips/mod.rs
+++ b/src/unix/notbsd/linux/mips/mod.rs
@@ -894,7 +894,7 @@ pub const NFT_NG_INCREMENTAL: ::c_int = 0;
 pub const NFT_NG_RANDOM: ::c_int = 1;
 
 #[doc(hidden)]
-pub const AF_MAX: ::c_int = 42;
+pub const AF_MAX: ::c_int = 45;
 #[doc(hidden)]
 pub const PF_MAX: ::c_int = AF_MAX;
 
diff --git a/src/unix/notbsd/linux/musl/b32/arm.rs b/src/unix/notbsd/linux/musl/b32/arm.rs
index 94f1a80f557af2d24ee4802acc918324f3874454..c5feafc12dd648248ea3c0fb04dc7e212f081499 100644
--- a/src/unix/notbsd/linux/musl/b32/arm.rs
+++ b/src/unix/notbsd/linux/musl/b32/arm.rs
@@ -182,6 +182,7 @@ pub const RLIMIT_NPROC: ::c_int = 6;
 pub const RLIMIT_MEMLOCK: ::c_int = 8;
 pub const RLIMIT_NLIMITS: ::c_int = 15;
 
+pub const MADV_SOFT_OFFLINE: ::c_int = 101;
 pub const MCL_CURRENT: ::c_int = 0x0001;
 pub const MCL_FUTURE: ::c_int = 0x0002;
 pub const CBAUD: ::tcflag_t = 0o0010017;
diff --git a/src/unix/notbsd/linux/musl/b32/powerpc.rs b/src/unix/notbsd/linux/musl/b32/powerpc.rs
index d0f2d682934022d12716f52cbc8a63ccf3f7ef7f..f62cf6295d853c71e6c472b5b9dc66c92ba18d68 100644
--- a/src/unix/notbsd/linux/musl/b32/powerpc.rs
+++ b/src/unix/notbsd/linux/musl/b32/powerpc.rs
@@ -166,6 +166,7 @@ s! {
     }
 }
 
+pub const MADV_SOFT_OFFLINE: ::c_int = 101;
 pub const SIGSTKSZ: ::size_t = 10240;
 pub const MINSIGSTKSZ: ::size_t = 4096;
 
diff --git a/src/unix/notbsd/linux/musl/b32/x86.rs b/src/unix/notbsd/linux/musl/b32/x86.rs
index 0f620fe5fbc581095456628be0e09249ec7ccf5b..95395f0a7afd0a7fdba04fba8bd32a056e5fce5a 100644
--- a/src/unix/notbsd/linux/musl/b32/x86.rs
+++ b/src/unix/notbsd/linux/musl/b32/x86.rs
@@ -242,6 +242,7 @@ pub const RLIMIT_NPROC: ::c_int = 6;
 pub const RLIMIT_MEMLOCK: ::c_int = 8;
 pub const RLIMIT_NLIMITS: ::c_int = 15;
 
+pub const MADV_SOFT_OFFLINE: ::c_int = 101;
 pub const MCL_CURRENT: ::c_int = 0x0001;
 pub const MCL_FUTURE: ::c_int = 0x0002;
 pub const CBAUD: ::tcflag_t = 0o0010017;
diff --git a/src/unix/notbsd/linux/musl/b64/aarch64.rs b/src/unix/notbsd/linux/musl/b64/aarch64.rs
index 018aaa9b501318a30da6fcfdaaf805bcc5ac6cd5..af654e31a3864fbf51e0048f39be23e7105bef48 100644
--- a/src/unix/notbsd/linux/musl/b64/aarch64.rs
+++ b/src/unix/notbsd/linux/musl/b64/aarch64.rs
@@ -75,6 +75,7 @@ pub const PF_MAX: ::c_int = 45;
 #[doc(hidden)]
 pub const AF_MAX: ::c_int = PF_MAX;
 
+pub const MADV_SOFT_OFFLINE: ::c_int = 101;
 pub const SYS_io_setup: ::c_long = 0;
 pub const SYS_io_destroy: ::c_long = 1;
 pub const SYS_io_submit: ::c_long = 2;
diff --git a/src/unix/notbsd/linux/musl/b64/powerpc64.rs b/src/unix/notbsd/linux/musl/b64/powerpc64.rs
index 8f16047e5d06311035ccaf25f77febd13f42642c..4230669087f22aeee88958c90a52f2114bdc36c1 100644
--- a/src/unix/notbsd/linux/musl/b64/powerpc64.rs
+++ b/src/unix/notbsd/linux/musl/b64/powerpc64.rs
@@ -60,6 +60,7 @@ s! {
     }
 }
 
+pub const MADV_SOFT_OFFLINE: ::c_int = 101;
 pub const MAP_32BIT: ::c_int = 0x0040;
 pub const O_DIRECT: ::c_int = 0x20000;
 pub const O_DIRECTORY: ::c_int = 0x4000;
diff --git a/src/unix/notbsd/linux/musl/b64/x86_64.rs b/src/unix/notbsd/linux/musl/b64/x86_64.rs
index 3a908354b586d291c64132a2099dde451f76a68e..3e2f1a435aea0fb72cbe80a084e8ebd0ad45d8cd 100644
--- a/src/unix/notbsd/linux/musl/b64/x86_64.rs
+++ b/src/unix/notbsd/linux/musl/b64/x86_64.rs
@@ -483,6 +483,7 @@ pub const ES: ::c_int = 24;
 pub const FS: ::c_int = 25;
 pub const GS: ::c_int = 26;
 
+pub const MADV_SOFT_OFFLINE: ::c_int = 101;
 pub const MAP_32BIT: ::c_int = 0x0040;
 pub const O_DIRECT: ::c_int = 0x4000;
 pub const O_DIRECTORY: ::c_int = 0x10000;
diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs
index 2ebb2acb45810d28a8abd9a43013c7ea6c44a3be..351995e16948ed28245d992e4fe1a3063dd41fd1 100644
--- a/src/unix/notbsd/linux/other/mod.rs
+++ b/src/unix/notbsd/linux/other/mod.rs
@@ -309,6 +309,7 @@ cfg_if! {
     }
 }
 
+pub const MADV_SOFT_OFFLINE: ::c_int = 101;
 pub const MS_RMT_MASK: ::c_ulong = 0x02800051;
 
 pub const __UT_LINESIZE: usize = 32;
diff --git a/src/unix/notbsd/linux/s390x/mod.rs b/src/unix/notbsd/linux/s390x/mod.rs
index 7785f9d59aeeaea80bbd729eb9211b2cf0b7a5fd..ba8bc3a8c216a1165f0f66d1b53901f66fa71578 100644
--- a/src/unix/notbsd/linux/s390x/mod.rs
+++ b/src/unix/notbsd/linux/s390x/mod.rs
@@ -353,6 +353,7 @@ cfg_if! {
     }
 }
 
+pub const MADV_SOFT_OFFLINE: ::c_int = 101;
 pub const MS_RMT_MASK: ::c_ulong = 0x02800051;
 
 pub const SFD_CLOEXEC: ::c_int = 0x080000;
diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs
index 2b6d6637a17269834061984fb8e89c7cc6defc45..fcf1299dc5050c20cf1d5c6c41819e4c6d3db678 100644
--- a/src/unix/notbsd/mod.rs
+++ b/src/unix/notbsd/mod.rs
@@ -643,7 +643,6 @@ pub const MADV_NOHUGEPAGE: ::c_int = 15;
 pub const MADV_DONTDUMP: ::c_int = 16;
 pub const MADV_DODUMP: ::c_int = 17;
 pub const MADV_HWPOISON: ::c_int = 100;
-pub const MADV_SOFT_OFFLINE: ::c_int = 101;
 
 pub const IFF_UP: ::c_int = 0x1;
 pub const IFF_BROADCAST: ::c_int = 0x2;