diff --git a/.github/workflows/full_ci.yml b/.github/workflows/full_ci.yml
index 042d81b158c0c..91ac0267a5b4d 100644
--- a/.github/workflows/full_ci.yml
+++ b/.github/workflows/full_ci.yml
@@ -19,12 +19,22 @@ jobs:
           i686-unknown-linux-gnu,
           x86_64-unknown-linux-gnu,
         ]
+        bits: [
+          default,
+          32,
+          64
+        ]
+        exclude:
+          - target: x86_64-unknown-linux-gnu
+            bits: 32
+          - target: x86_64-unknown-linux-gnu
+            bits: 64
     steps:
       - uses: actions/checkout@v4
       - name: Setup Rust toolchain
         run: TARGET=${{ matrix.target }} sh ./ci/install-rust.sh
       - name: Execute run-docker.sh
-        run: LIBC_CI=1 sh ./ci/run-docker.sh ${{ matrix.target }}
+        run: LIBC_CI=1 RUST_LIBC_TIME_BITS=${{ matrix.bits }} sh ./ci/run-docker.sh ${{ matrix.target }}
 
   macos:
     permissions:
@@ -133,12 +143,22 @@ jobs:
           # aren't defined on redox actually.
           # x86_64-unknown-redox,
         ]
+        include:
+          - bits: default
+          - bits: 32
+            target: arm-unknown-linux-gnueabihf
+          - bits: 64
+            target: arm-unknown-linux-gnueabihf
+          - bits: 32
+            target: powerpc-unknown-linux-gnu
+          - bits: 64
+            target: powerpc-unknown-linux-gnu
     steps:
       - uses: actions/checkout@v4
       - name: Setup Rust toolchain
         run: TARGET=${{ matrix.target }} sh ./ci/install-rust.sh
       - name: Execute run-docker.sh
-        run: LIBC_CI=1 sh ./ci/run-docker.sh ${{ matrix.target }}
+        run: LIBC_CI=1 RUST_LIBC_TIME_BITS=${{ matrix.bits }} sh ./ci/run-docker.sh ${{ matrix.target }}
 
   build_channels_linux:
     permissions:
diff --git a/build.rs b/build.rs
index 6bcaafc791715..8db9816b39976 100644
--- a/build.rs
+++ b/build.rs
@@ -14,6 +14,7 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
     "freebsd13",
     "freebsd14",
     "freebsd15",
+    "gnu_time64_abi",
     "libc_const_extern_fn",
     "libc_const_extern_fn_unstable",
     "libc_deny_warnings",
@@ -67,6 +68,11 @@ fn main() {
         Some(_) | None => (),
     }
 
+    // Some ABIs need to redirect time related symbols to their time64 equivalents.
+    if is_gnu_time64_abi() {
+        set_cfg("gnu_time64_abi");
+    }
+
     // On CI: deny all warnings
     if libc_ci {
         set_cfg("libc_deny_warnings");
@@ -205,3 +211,64 @@ fn set_cfg(cfg: &str) {
     }
     println!("cargo:rustc-cfg={}", cfg);
 }
+
+fn is_gnu_time64_abi() -> bool {
+    match env::var("CARGO_CFG_TARGET_ENV") {
+        Ok(target_env) => {
+            if target_env != "gnu" {
+                return false;
+            }
+        }
+        Err(_) => panic!("CARGO_CFG_TARGET_ENV not set"),
+    }
+    match env::var("CARGO_CFG_TARGET_OS") {
+        Ok(target_os) => {
+            if target_os != "linux" {
+                return false;
+            }
+        }
+        Err(_) => panic!("CARGO_CFG_TARGET_OS not set"),
+    }
+    match env::var("CARGO_CFG_TARGET_POINTER_WIDTH") {
+        Ok(bits) => {
+            if bits == "64" {
+                return false;
+            }
+        }
+        Err(_) => panic!("CARGO_CFG_TARGET_POINTER_WIDTH not set"),
+    }
+    match env::var("CARGO_CFG_TARGET_ARCH") {
+        Ok(bits) => {
+            if bits == "riscv32" {
+                return false;
+            }
+        }
+        Err(_) => panic!("CARGO_CFG_TARGET_ARCH not set"),
+    }
+    match env::var("RUST_LIBC_TIME_BITS") {
+        Ok(time_bits) => {
+            if time_bits == "64" {
+                return true;
+            }
+            if time_bits == "32" {
+                return false;
+            }
+            if time_bits != "default" {
+                panic!("Invalid value for RUST_LIBC_TIME_BITS");
+            }
+        }
+        Err(_) => {}
+    }
+    // At this point, we _know_ it is *-*-linux-gnu* with 32 bit
+    // pointers. Some 64 bit arch still have 32 bit pointers though.
+    match env::var("TARGET") {
+        Ok(target) => {
+            // x86_64-unknown-linux-gnux32 and similar
+            if target.contains("x86_64") && target.contains("x32") {
+                return false;
+            }
+        }
+        Err(_) => panic!("TARGET not set"),
+    }
+    return true;
+}
diff --git a/ci/build.sh b/ci/build.sh
index 512c9cfc9a12a..68a12a5ae2e39 100644
--- a/ci/build.sh
+++ b/ci/build.sh
@@ -23,6 +23,29 @@ test_target() {
     TARGET="${2}"
     NO_STD="${3}"
 
+    if [ "$RUST_LIBC_TIME_BITS" = "" ]; then
+        while true; do
+            case "$TARGET" in
+                arm-unknown-linux-gnueabi);;
+                arm-unknown-linux-gnueabihf);;
+                armv7-unknown-linux-gnueabihf);;
+                i586-unknown-linux-gnu);;
+                i686-unknown-linux-gnu);;
+                powerpc-unknown-linux-gnu);;
+                armv5te-unknown-linux-gnueabi);;
+                mips-unknown-linux-gnu);;
+                mipsel-unknown-linux-gnu);;
+                powerpc-unknown-linux-gnuspe);;
+                riscv32gc-unknown-linux-gnu);;
+                sparc-unknown-linux-gnu);;
+                *) break;
+            esac
+            RUST_LIBC_TIME_BITS=32 test_target "$BUILD_CMD" "$TARGET" "$NO_STD"
+            RUST_LIBC_TIME_BITS=64 test_target "$BUILD_CMD" "$TARGET" "$NO_STD"
+            break # also build without RUST_LIBC_TIME_BITS set
+        done
+    fi
+
     # If there is a std component, fetch it:
     if [ "${NO_STD}" != "1" ]; then
         # FIXME: rustup often fails to download some artifacts due to network
diff --git a/ci/run-docker.sh b/ci/run-docker.sh
index 042303846f3fe..a00ca4321ffa3 100755
--- a/ci/run-docker.sh
+++ b/ci/run-docker.sh
@@ -43,6 +43,7 @@ run() {
       --env LIBC_CI_ZBUILD_STD \
       --env CARGO_HOME=/cargo \
       --env CARGO_TARGET_DIR=/checkout/target \
+      --env RUST_LIBC_TIME_BITS \
       --volume "$CARGO_HOME":/cargo \
       --volume "$(rustc --print sysroot)":/rust:ro \
       --volume "$(pwd)":/checkout:ro \
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 2f45523187a51..ace0ba82306a1 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -3260,6 +3260,31 @@ fn test_vxworks(target: &str) {
     cfg.generate("../src/lib.rs", "main.rs");
 }
 
+fn config_gnu_time64(target: &str, cfg: &mut ctest::TestGenerator) {
+    let gnu = target.contains("gnu");
+    let x32 = target.contains("x32");
+    let riscv = target.contains("riscv32");
+
+    if gnu && &env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap() == "32" && !riscv && !x32 {
+        match env::var("RUST_LIBC_TIME_BITS") {
+            Ok(time_bits) => {
+                if time_bits == "64" || time_bits == "default" {
+                    cfg.define("_TIME_BITS", Some("64"));
+                    cfg.define("_FILE_OFFSET_BITS", Some("64"));
+                    cfg.cfg("gnu_time64_abi", None);
+                } else if time_bits != "32" {
+                    panic!("Unsupported RUST_LIBC_TIME_BITS value {}", time_bits)
+                }
+            }
+            Err(_) => {
+                cfg.define("_TIME_BITS", Some("64"));
+                cfg.define("_FILE_OFFSET_BITS", Some("64"));
+                cfg.cfg("gnu_time64_abi", None);
+            }
+        }
+    }
+}
+
 fn test_linux(target: &str) {
     assert!(target.contains("linux"));
 
@@ -3302,6 +3327,8 @@ fn test_linux(target: &str) {
     // glibc versions older than 2.29.
     cfg.define("__GLIBC_USE_DEPRECATED_SCANF", None);
 
+    config_gnu_time64(target, &mut cfg);
+
     headers! { cfg:
                "ctype.h",
                "dirent.h",
@@ -3503,6 +3530,8 @@ fn test_linux(target: &str) {
 
             // LFS64 types have been removed in musl 1.2.4+
             "off64_t" if musl => "off_t".to_string(),
+            // In some gnu targets `stat64` is a typedef to `stat`
+            "stat64" if gnu => format!("struct {}", ty),
 
             // typedefs don't need any keywords
             t if t.ends_with("_t") => t.to_string(),
@@ -4433,6 +4462,7 @@ fn test_linux_like_apis(target: &str) {
     if linux || android || emscripten {
         // test strerror_r from the `string.h` header
         let mut cfg = ctest_cfg();
+        config_gnu_time64(target, &mut cfg);
         cfg.skip_type(|_| true).skip_static(|_| true);
 
         headers! { cfg: "string.h" }
@@ -4449,6 +4479,7 @@ fn test_linux_like_apis(target: &str) {
         // test fcntl - see:
         // http://man7.org/linux/man-pages/man2/fcntl.2.html
         let mut cfg = ctest_cfg();
+        config_gnu_time64(target, &mut cfg);
 
         if musl {
             cfg.header("fcntl.h");
@@ -4478,6 +4509,7 @@ fn test_linux_like_apis(target: &str) {
     if linux || android {
         // test termios
         let mut cfg = ctest_cfg();
+        config_gnu_time64(target, &mut cfg);
         cfg.header("asm/termbits.h");
         cfg.header("linux/termios.h");
         cfg.skip_type(|_| true)
@@ -4502,6 +4534,7 @@ fn test_linux_like_apis(target: &str) {
     if linux || android {
         // test IPV6_ constants:
         let mut cfg = ctest_cfg();
+        config_gnu_time64(target, &mut cfg);
         headers! {
             cfg:
             "linux/in6.h"
@@ -4533,6 +4566,7 @@ fn test_linux_like_apis(target: &str) {
         // "resolve.h" defines a `p_type` macro that expands to `__p_type`
         // making the tests for these fails when both are included.
         let mut cfg = ctest_cfg();
+        config_gnu_time64(target, &mut cfg);
         cfg.header("elf.h");
         cfg.skip_fn(|_| true)
             .skip_static(|_| true)
@@ -4552,6 +4586,7 @@ fn test_linux_like_apis(target: &str) {
     if linux || android {
         // Test `ARPHRD_CAN`.
         let mut cfg = ctest_cfg();
+        config_gnu_time64(target, &mut cfg);
         cfg.header("linux/if_arp.h");
         cfg.skip_fn(|_| true)
             .skip_static(|_| true)
diff --git a/src/unix/linux_like/linux/arch/generic/mod.rs b/src/unix/linux_like/linux/arch/generic/mod.rs
index 2f437e16db26a..2e319f58233c2 100644
--- a/src/unix/linux_like/linux/arch/generic/mod.rs
+++ b/src/unix/linux_like/linux/arch/generic/mod.rs
@@ -37,10 +37,6 @@ pub const SO_PASSCRED: ::c_int = 16;
 pub const SO_PEERCRED: ::c_int = 17;
 pub const SO_RCVLOWAT: ::c_int = 18;
 pub const SO_SNDLOWAT: ::c_int = 19;
-pub const SO_RCVTIMEO: ::c_int = 20;
-pub const SO_SNDTIMEO: ::c_int = 21;
-// pub const SO_RCVTIMEO_OLD: ::c_int = 20;
-// pub const SO_SNDTIMEO_OLD: ::c_int = 21;
 pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22;
 pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23;
 pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24;
@@ -49,18 +45,35 @@ pub const SO_ATTACH_FILTER: ::c_int = 26;
 pub const SO_DETACH_FILTER: ::c_int = 27;
 pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER;
 pub const SO_PEERNAME: ::c_int = 28;
-pub const SO_TIMESTAMP: ::c_int = 29;
+
+cfg_if! {
+    if #[cfg(all(gnu_time64_abi,
+                 any(target_arch = "arm", target_arch = "x86")))] {
+        pub const SO_TIMESTAMP: ::c_int = 63;
+        pub const SO_TIMESTAMPNS: ::c_int = 64;
+        pub const SO_TIMESTAMPING: ::c_int = 65;
+        pub const SO_RCVTIMEO: ::c_int = 66;
+        pub const SO_SNDTIMEO: ::c_int = 67;
+    } else {
+        pub const SO_TIMESTAMP: ::c_int = 29;
+        pub const SO_TIMESTAMPNS: ::c_int = 35;
+        pub const SO_TIMESTAMPING: ::c_int = 37;
+        pub const SO_RCVTIMEO: ::c_int = 20;
+        pub const SO_SNDTIMEO: ::c_int = 21;
+    }
+}
 // pub const SO_TIMESTAMP_OLD: ::c_int = 29;
+// pub const SO_TIMESTAMPNS_OLD: ::c_int = 35;
+// pub const SO_TIMESTAMPING_OLD: ::c_int = 37;
+// pub const SO_RCVTIMEO_OLD: ::c_int = 20;
+// pub const SO_SNDTIMEO_OLD: ::c_int = 21;
+
 pub const SO_ACCEPTCONN: ::c_int = 30;
 pub const SO_PEERSEC: ::c_int = 31;
 pub const SO_SNDBUFFORCE: ::c_int = 32;
 pub const SO_RCVBUFFORCE: ::c_int = 33;
 pub const SO_PASSSEC: ::c_int = 34;
-pub const SO_TIMESTAMPNS: ::c_int = 35;
-// pub const SO_TIMESTAMPNS_OLD: ::c_int = 35;
 pub const SO_MARK: ::c_int = 36;
-pub const SO_TIMESTAMPING: ::c_int = 37;
-// pub const SO_TIMESTAMPING_OLD: ::c_int = 37;
 pub const SO_PROTOCOL: ::c_int = 38;
 pub const SO_DOMAIN: ::c_int = 39;
 pub const SO_RXQ_OVFL: ::c_int = 40;
diff --git a/src/unix/linux_like/linux/arch/mips/mod.rs b/src/unix/linux_like/linux/arch/mips/mod.rs
index 6a96aa9c3b159..73ac39a1e8cdc 100644
--- a/src/unix/linux_like/linux/arch/mips/mod.rs
+++ b/src/unix/linux_like/linux/arch/mips/mod.rs
@@ -33,8 +33,15 @@ pub const SO_RCVLOWAT: ::c_int = 0x1004;
 // NOTE: These definitions are now being renamed with _OLD postfix,
 // but CI haven't support them yet.
 // Some related consts could be found in b32.rs and b64.rs
-pub const SO_SNDTIMEO: ::c_int = 0x1005;
-pub const SO_RCVTIMEO: ::c_int = 0x1006;
+cfg_if! {
+    if #[cfg(gnu_time64_abi)] {
+        pub const SO_SNDTIMEO: ::c_int = 67;
+        pub const SO_RCVTIMEO: ::c_int = 66;
+    } else {
+        pub const SO_SNDTIMEO: ::c_int = 0x1005;
+        pub const SO_RCVTIMEO: ::c_int = 0x1006;
+    }
+}
 // pub const SO_SNDTIMEO_OLD: ::c_int = 0x1005;
 // pub const SO_RCVTIMEO_OLD: ::c_int = 0x1006;
 pub const SO_ACCEPTCONN: ::c_int = 0x1009;
@@ -88,9 +95,17 @@ pub const SO_BINDTOIFINDEX: ::c_int = 62;
 // NOTE: These definitions are now being renamed with _OLD postfix,
 // but CI haven't support them yet.
 // Some related consts could be found in b32.rs and b64.rs
-pub const SO_TIMESTAMP: ::c_int = 29;
-pub const SO_TIMESTAMPNS: ::c_int = 35;
-pub const SO_TIMESTAMPING: ::c_int = 37;
+cfg_if! {
+    if #[cfg(gnu_time64_abi)] {
+        pub const SO_TIMESTAMP: ::c_int = 63;
+        pub const SO_TIMESTAMPNS: ::c_int = 64;
+        pub const SO_TIMESTAMPING: ::c_int = 65;
+    } else {
+        pub const SO_TIMESTAMP: ::c_int = 29;
+        pub const SO_TIMESTAMPNS: ::c_int = 35;
+        pub const SO_TIMESTAMPING: ::c_int = 37;
+    }
+}
 // pub const SO_TIMESTAMP_OLD: ::c_int = 29;
 // pub const SO_TIMESTAMPNS_OLD: ::c_int = 35;
 // pub const SO_TIMESTAMPING_OLD: ::c_int = 37;
@@ -315,9 +330,12 @@ cfg_if! {
 }
 
 cfg_if! {
-    if #[cfg(any(target_arch = "mips", target_arch = "mips32r6"),
-         any(target_env = "gnu",
-             target_env = "uclibc"))] {
+    if #[cfg(all(gnu_time64_abi, any(target_arch = "mips", target_arch = "mips32r6")))] {
+        pub const RLIM_INFINITY: ::rlim_t = !0;
+    } else if #[cfg(all(
+        any(target_arch = "mips", target_arch = "mips32r6"),
+        any(target_env = "uclibc", all(target_env = "gnu", not(gnu_time64_abi)))
+    ))] {
         pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff;
     }
 }
diff --git a/src/unix/linux_like/linux/arch/powerpc/mod.rs b/src/unix/linux_like/linux/arch/powerpc/mod.rs
index 27834dbfeabcc..039839995cc44 100644
--- a/src/unix/linux_like/linux/arch/powerpc/mod.rs
+++ b/src/unix/linux_like/linux/arch/powerpc/mod.rs
@@ -21,8 +21,15 @@ pub const SO_REUSEPORT: ::c_int = 15;
 // powerpc only differs in these
 pub const SO_RCVLOWAT: ::c_int = 16;
 pub const SO_SNDLOWAT: ::c_int = 17;
-pub const SO_RCVTIMEO: ::c_int = 18;
-pub const SO_SNDTIMEO: ::c_int = 19;
+cfg_if! {
+    if #[cfg(gnu_time64_abi)] {
+        pub const SO_SNDTIMEO: ::c_int = 67;
+        pub const SO_RCVTIMEO: ::c_int = 66;
+    } else {
+        pub const SO_SNDTIMEO: ::c_int = 19;
+        pub const SO_RCVTIMEO: ::c_int = 18;
+    }
+}
 // pub const SO_RCVTIMEO_OLD: ::c_int = 18;
 // pub const SO_SNDTIMEO_OLD: ::c_int = 19;
 pub const SO_PASSCRED: ::c_int = 20;
@@ -36,18 +43,26 @@ pub const SO_ATTACH_FILTER: ::c_int = 26;
 pub const SO_DETACH_FILTER: ::c_int = 27;
 pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER;
 pub const SO_PEERNAME: ::c_int = 28;
-pub const SO_TIMESTAMP: ::c_int = 29;
+cfg_if! {
+    if #[cfg(gnu_time64_abi)] {
+        pub const SO_TIMESTAMP: ::c_int = 63;
+        pub const SO_TIMESTAMPNS: ::c_int = 64;
+        pub const SO_TIMESTAMPING: ::c_int = 65;
+    } else {
+        pub const SO_TIMESTAMP: ::c_int = 29;
+        pub const SO_TIMESTAMPNS: ::c_int = 35;
+        pub const SO_TIMESTAMPING: ::c_int = 37;
+    }
+}
 // pub const SO_TIMESTAMP_OLD: ::c_int = 29;
+// pub const SO_TIMESTAMPNS_OLD: ::c_int = 35;
+// pub const SO_TIMESTAMPING_OLD: ::c_int = 37;
 pub const SO_ACCEPTCONN: ::c_int = 30;
 pub const SO_PEERSEC: ::c_int = 31;
 pub const SO_SNDBUFFORCE: ::c_int = 32;
 pub const SO_RCVBUFFORCE: ::c_int = 33;
 pub const SO_PASSSEC: ::c_int = 34;
-pub const SO_TIMESTAMPNS: ::c_int = 35;
-// pub const SO_TIMESTAMPNS_OLD: ::c_int = 35;
 pub const SO_MARK: ::c_int = 36;
-pub const SO_TIMESTAMPING: ::c_int = 37;
-// pub const SO_TIMESTAMPING_OLD: ::c_int = 37;
 pub const SO_PROTOCOL: ::c_int = 38;
 pub const SO_DOMAIN: ::c_int = 39;
 pub const SO_RXQ_OVFL: ::c_int = 40;
diff --git a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs
index e689441213de0..f4e3f7828802f 100644
--- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs
+++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs
@@ -56,28 +56,6 @@ s! {
         __unused2: ::c_ulong
     }
 
-    pub struct stat64 {
-        pub st_dev: ::dev_t,
-        __pad1: ::c_uint,
-        __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,
-        __pad2: ::c_uint,
-        pub st_size: ::off64_t,
-        pub st_blksize: ::blksize_t,
-        pub st_blocks: ::blkcnt64_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_ino: ::ino64_t,
-    }
-
     pub struct statfs64 {
         pub f_type: ::__fsword_t,
         pub f_bsize: ::__fsword_t,
@@ -113,10 +91,13 @@ s! {
         pub shm_perm: ::ipc_perm,
         pub shm_segsz: ::size_t,
         pub shm_atime: ::time_t,
+        #[cfg(not(gnu_time64_abi))]
         __unused1: ::c_ulong,
         pub shm_dtime: ::time_t,
+        #[cfg(not(gnu_time64_abi))]
         __unused2: ::c_ulong,
         pub shm_ctime: ::time_t,
+        #[cfg(not(gnu_time64_abi))]
         __unused3: ::c_ulong,
         pub shm_cpid: ::pid_t,
         pub shm_lpid: ::pid_t,
@@ -128,10 +109,13 @@ s! {
     pub struct msqid_ds {
         pub msg_perm: ::ipc_perm,
         pub msg_stime: ::time_t,
+        #[cfg(not(gnu_time64_abi))]
         __glibc_reserved1: ::c_ulong,
         pub msg_rtime: ::time_t,
+        #[cfg(not(gnu_time64_abi))]
         __glibc_reserved2: ::c_ulong,
         pub msg_ctime: ::time_t,
+        #[cfg(not(gnu_time64_abi))]
         __glibc_reserved3: ::c_ulong,
         __msg_cbytes: ::c_ulong,
         pub msg_qnum: ::msgqnum_t,
@@ -341,7 +325,13 @@ pub const MCL_ONFAULT: ::c_int = 0x0004;
 pub const POLLWRNORM: ::c_short = 0x100;
 pub const POLLWRBAND: ::c_short = 0x200;
 
-pub const F_GETLK: ::c_int = 5;
+cfg_if! {
+    if #[cfg(gnu_time64_abi)] {
+        pub const F_GETLK: ::c_int = 12;
+    } else {
+        pub const F_GETLK: ::c_int = 5;
+    }
+}
 pub const F_GETOWN: ::c_int = 9;
 pub const F_SETOWN: ::c_int = 8;
 
@@ -859,3 +849,13 @@ pub const SYS_set_mempolicy_home_node: ::c_long = 450;
 
 mod align;
 pub use self::align::*;
+
+cfg_if! {
+    if #[cfg(gnu_time64_abi)] {
+        mod time64;
+        pub use self::time64::*;
+    } else {
+        mod time32;
+        pub use self::time32::*;
+    }
+}
diff --git a/src/unix/linux_like/linux/gnu/b32/arm/time32.rs b/src/unix/linux_like/linux/gnu/b32/arm/time32.rs
new file mode 100644
index 0000000000000..cd991bd00e011
--- /dev/null
+++ b/src/unix/linux_like/linux/gnu/b32/arm/time32.rs
@@ -0,0 +1,24 @@
+s! {
+    pub struct stat64 {
+        pub st_dev: ::dev_t,
+        __pad1: ::c_uint,
+        __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,
+        __pad2: ::c_uint,
+        pub st_size: ::off64_t,
+        pub st_blksize: ::blksize_t,
+        pub st_blocks: ::blkcnt64_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_ino: ::ino64_t,
+    }
+
+}
diff --git a/src/unix/linux_like/linux/gnu/b32/arm/time64.rs b/src/unix/linux_like/linux/gnu/b32/arm/time64.rs
new file mode 100644
index 0000000000000..7facf6ae7f287
--- /dev/null
+++ b/src/unix/linux_like/linux/gnu/b32/arm/time64.rs
@@ -0,0 +1,2 @@
+use stat;
+pub type stat64 = stat;
diff --git a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs
index 6f9560334c164..98d98e1f56859 100644
--- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs
+++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs
@@ -2,28 +2,6 @@ pub type c_char = i8;
 pub type wchar_t = i32;
 
 s! {
-    pub struct stat64 {
-        pub st_dev: ::c_ulong,
-        st_pad1: [::c_long; 3],
-        pub st_ino: ::ino64_t,
-        pub st_mode: ::mode_t,
-        pub st_nlink: ::nlink_t,
-        pub st_uid: ::uid_t,
-        pub st_gid: ::gid_t,
-        pub st_rdev: ::c_ulong,
-        st_pad2: [::c_long; 2],
-        pub st_size: ::off64_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_blksize: ::blksize_t,
-        st_pad3: ::c_long,
-        pub st_blocks: ::blkcnt64_t,
-        st_pad5: [::c_long; 14],
-    }
 
     pub struct statfs {
         pub f_type: ::c_long,
@@ -121,21 +99,9 @@ s! {
 
     pub struct msqid_ds {
         pub msg_perm: ::ipc_perm,
-        #[cfg(target_endian = "big")]
-        __glibc_reserved1: ::c_ulong,
         pub msg_stime: ::time_t,
-        #[cfg(target_endian = "little")]
-        __glibc_reserved1: ::c_ulong,
-        #[cfg(target_endian = "big")]
-        __glibc_reserved2: ::c_ulong,
         pub msg_rtime: ::time_t,
-        #[cfg(target_endian = "little")]
-        __glibc_reserved2: ::c_ulong,
-        #[cfg(target_endian = "big")]
-        __glibc_reserved3: ::c_ulong,
         pub msg_ctime: ::time_t,
-        #[cfg(target_endian = "little")]
-        __glibc_reserved3: ::c_ulong,
         __msg_cbytes: ::c_ulong,
         pub msg_qnum: ::msgqnum_t,
         pub msg_qbytes: ::msglen_t,
@@ -708,7 +674,13 @@ pub const MAP_HUGETLB: ::c_int = 0x080000;
 
 pub const EFD_NONBLOCK: ::c_int = 0x80;
 
-pub const F_GETLK: ::c_int = 14;
+cfg_if! {
+    if #[cfg(gnu_time64_abi)] {
+        pub const F_GETLK: ::c_int = 33;
+    } else {
+        pub const F_GETLK: ::c_int = 14;
+    }
+}
 pub const F_GETOWN: ::c_int = 23;
 pub const F_SETOWN: ::c_int = 24;
 
@@ -814,3 +786,13 @@ pub const EHWPOISON: ::c_int = 168;
 
 mod align;
 pub use self::align::*;
+
+cfg_if! {
+    if #[cfg(gnu_time64_abi)] {
+        mod time64;
+        pub use self::time64::*;
+    } else {
+        mod time32;
+        pub use self::time32::*;
+    }
+}
diff --git a/src/unix/linux_like/linux/gnu/b32/mips/time32.rs b/src/unix/linux_like/linux/gnu/b32/mips/time32.rs
new file mode 100644
index 0000000000000..b4f37a4e006ff
--- /dev/null
+++ b/src/unix/linux_like/linux/gnu/b32/mips/time32.rs
@@ -0,0 +1,24 @@
+s! {
+    pub struct stat64 {
+        pub st_dev: ::c_ulong,
+        st_pad1: [::c_long; 3],
+        pub st_ino: ::ino64_t,
+        pub st_mode: ::mode_t,
+        pub st_nlink: ::nlink_t,
+        pub st_uid: ::uid_t,
+        pub st_gid: ::gid_t,
+        pub st_rdev: ::c_ulong,
+        st_pad2: [::c_long; 2],
+        pub st_size: ::off64_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_blksize: ::blksize_t,
+        st_pad3: ::c_long,
+        pub st_blocks: ::blkcnt64_t,
+        st_pad5: [::c_long; 14],
+    }
+}
diff --git a/src/unix/linux_like/linux/gnu/b32/mips/time64.rs b/src/unix/linux_like/linux/gnu/b32/mips/time64.rs
new file mode 100644
index 0000000000000..7facf6ae7f287
--- /dev/null
+++ b/src/unix/linux_like/linux/gnu/b32/mips/time64.rs
@@ -0,0 +1,2 @@
+use stat;
+pub type stat64 = stat;
diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs
index 54c84fa617c86..58a694514dbe0 100644
--- a/src/unix/linux_like/linux/gnu/b32/mod.rs
+++ b/src/unix/linux_like/linux/gnu/b32/mod.rs
@@ -16,6 +16,7 @@ pub type __fsword_t = i32;
 pub type fsblkcnt64_t = u64;
 pub type fsfilcnt64_t = u64;
 pub type __syscall_ulong_t = ::c_ulong;
+pub type __syscall_slong_t = ::c_long;
 
 cfg_if! {
     if #[cfg(target_arch = "riscv32")] {
@@ -28,6 +29,16 @@ cfg_if! {
         pub type fsfilcnt_t = u64;
         pub type rlim_t = u64;
         pub type blksize_t = i64;
+    } else if #[cfg(gnu_time64_abi)] {
+        pub type time_t = i64;
+        pub type suseconds_t = i32;
+        pub type ino_t = u64;
+        pub type off_t = i64;
+        pub type blkcnt_t = i64;
+        pub type fsblkcnt_t = u64;
+        pub type fsfilcnt_t = u64;
+        pub type rlim_t = u64;
+        pub type blksize_t = i32;
     } else {
         pub type time_t = i32;
         pub type suseconds_t = i32;
@@ -42,54 +53,6 @@ cfg_if! {
 }
 
 s! {
-    pub struct stat {
-        #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
-        pub st_dev: ::dev_t,
-        #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
-        pub st_dev: ::c_ulong,
-
-        #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
-        __pad1: ::c_short,
-        #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
-        st_pad1: [::c_long; 3],
-        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,
-        #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
-        pub st_rdev: ::dev_t,
-        #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
-        pub st_rdev: ::c_ulong,
-        #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
-        __pad2: ::c_short,
-        #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
-        st_pad2: [::c_long; 2],
-        pub st_size: ::off_t,
-        #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
-        st_pad3: ::c_long,
-        #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
-        pub st_blksize: ::blksize_t,
-        #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
-        pub st_blocks: ::blkcnt_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,
-        #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
-        __unused4: ::c_long,
-        #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
-        __unused5: ::c_long,
-        #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
-        pub st_blksize: ::blksize_t,
-        #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
-        pub st_blocks: ::blkcnt_t,
-        #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
-        st_pad5: [::c_long; 14],
-    }
-
     pub struct statvfs {
         pub f_bsize: ::c_ulong,
         pub f_frsize: ::c_ulong,
@@ -137,17 +100,36 @@ s! {
 
     pub struct semid_ds {
         pub sem_perm: ipc_perm,
-        #[cfg(target_arch = "powerpc")]
+        #[cfg(all(not(gnu_time64_abi), target_arch = "powerpc"))]
         __reserved: ::__syscall_ulong_t,
         pub sem_otime: ::time_t,
-        #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6", target_arch = "powerpc")))]
+        #[cfg(not(any(
+            gnu_time64_abi,
+            target_arch = "mips",
+            target_arch = "mips32r6",
+            target_arch = "powerpc"
+        )))]
         __reserved: ::__syscall_ulong_t,
-        #[cfg(target_arch = "powerpc")]
+        #[cfg(all(not(gnu_time64_abi), target_arch = "powerpc"))]
         __reserved2: ::__syscall_ulong_t,
         pub sem_ctime: ::time_t,
-        #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6", target_arch = "powerpc")))]
+        #[cfg(not(any(
+            gnu_time64_abi,
+            target_arch = "mips",
+            target_arch = "mips32r6",
+            target_arch = "powerpc"
+        )))]
         __reserved2: ::__syscall_ulong_t,
         pub sem_nsems: ::__syscall_ulong_t,
+        #[cfg(all(gnu_time64_abi,
+                  not(any(
+                      target_arch = "mips",
+                      target_arch = "mips32r6",
+                      target_arch = "powerpc",
+                      target_arch = "arm",
+                      target_arch = "x86"
+                  ))))]
+        __reserved2: ::__syscall_ulong_t,
         __glibc_reserved3: ::__syscall_ulong_t,
         __glibc_reserved4: ::__syscall_ulong_t,
     }
@@ -178,9 +160,6 @@ cfg_if! {
 
         pub const PTRACE_DETACH: ::c_uint = 11;
 
-        pub const F_SETLK: ::c_int = 8;
-        pub const F_SETLKW: ::c_int = 9;
-
         pub const F_RDLCK: ::c_int = 1;
         pub const F_WRLCK: ::c_int = 2;
         pub const F_UNLCK: ::c_int = 3;
@@ -224,9 +203,6 @@ cfg_if! {
 
         pub const PTRACE_DETACH: ::c_uint = 17;
 
-        pub const F_SETLK: ::c_int = 6;
-        pub const F_SETLKW: ::c_int = 7;
-
         pub const F_RDLCK: ::c_int = 0;
         pub const F_WRLCK: ::c_int = 1;
         pub const F_UNLCK: ::c_int = 2;
@@ -262,6 +238,21 @@ cfg_if! {
         pub const EFD_CLOEXEC: ::c_int = 0x80000;
     }
 }
+cfg_if! {
+    if #[cfg(target_arch = "sparc")] {
+        pub const F_SETLK: ::c_int = 8;
+        pub const F_SETLKW: ::c_int = 9;
+    } else if #[cfg(all(gnu_time64_abi, target_arch = "mips"))] {
+        pub const F_SETLK: ::c_int = 34;
+        pub const F_SETLKW: ::c_int = 35;
+    } else if #[cfg(gnu_time64_abi)] {
+        pub const F_SETLK: ::c_int = 13;
+        pub const F_SETLKW: ::c_int = 14;
+    } else {
+        pub const F_SETLK: ::c_int = 6;
+        pub const F_SETLKW: ::c_int = 7;
+    }
+}
 
 #[cfg(target_endian = "little")]
 pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t {
@@ -345,3 +336,15 @@ cfg_if! {
         // Unknown target_arch
     }
 }
+
+cfg_if! {
+    if #[cfg(any(target_arch = "riscv32", target_arch = "sparc"))] {
+        // use the defs in self::riscv32 or self::sparc
+    } else if #[cfg(gnu_time64_abi)] {
+        mod time64;
+        pub use self::time64::*;
+    } else {
+        mod time32;
+        pub use self::time32::*;
+    }
+}
diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc/mod.rs
similarity index 95%
rename from src/unix/linux_like/linux/gnu/b32/powerpc.rs
rename to src/unix/linux_like/linux/gnu/b32/powerpc/mod.rs
index 0b0c779c4d7c7..d2bc1cc12ee15 100644
--- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs
+++ b/src/unix/linux_like/linux/gnu/b32/powerpc/mod.rs
@@ -55,28 +55,6 @@ s! {
         __glibc_reserved2: u64,
     }
 
-    pub struct stat64 {
-        pub st_dev: ::dev_t,
-        pub st_ino: ::ino64_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,
-        __pad2: ::c_ushort,
-        pub st_size: ::off64_t,
-        pub st_blksize: ::blksize_t,
-        pub st_blocks: ::blkcnt64_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,
-        __glibc_reserved4: ::c_ulong,
-        __glibc_reserved5: ::c_ulong,
-    }
-
     pub struct statfs64 {
         pub f_type: ::__fsword_t,
         pub f_bsize: ::__fsword_t,
@@ -108,29 +86,15 @@ s! {
         __f_spare: [::c_int; 6],
     }
 
-    pub struct shmid_ds {
-        pub shm_perm: ::ipc_perm,
-        __glibc_reserved1: ::c_uint,
-        pub shm_atime: ::time_t,
-        __glibc_reserved2: ::c_uint,
-        pub shm_dtime: ::time_t,
-        __glibc_reserved3: ::c_uint,
-        pub shm_ctime: ::time_t,
-        __glibc_reserved4: ::c_uint,
-        pub shm_segsz: ::size_t,
-        pub shm_cpid: ::pid_t,
-        pub shm_lpid: ::pid_t,
-        pub shm_nattch: ::shmatt_t,
-        __glibc_reserved5: ::c_ulong,
-        __glibc_reserved6: ::c_ulong,
-    }
-
     pub struct msqid_ds {
         pub msg_perm: ::ipc_perm,
+        #[cfg(not(gnu_time64_abi))]
         __glibc_reserved1: ::c_uint,
         pub msg_stime: ::time_t,
+        #[cfg(not(gnu_time64_abi))]
         __glibc_reserved2: ::c_uint,
         pub msg_rtime: ::time_t,
+        #[cfg(not(gnu_time64_abi))]
         __glibc_reserved3: ::c_uint,
         pub msg_ctime: ::time_t,
         __msg_cbytes: ::c_ulong,
@@ -299,7 +263,13 @@ pub const MCL_ONFAULT: ::c_int = 0x8000;
 pub const POLLWRNORM: ::c_short = 0x100;
 pub const POLLWRBAND: ::c_short = 0x200;
 
-pub const F_GETLK: ::c_int = 5;
+cfg_if! {
+    if #[cfg(gnu_time64_abi)] {
+        pub const F_GETLK: ::c_int = 12;
+    } else {
+        pub const F_GETLK: ::c_int = 5;
+    }
+}
 pub const F_GETOWN: ::c_int = 9;
 pub const F_SETOWN: ::c_int = 8;
 
@@ -824,3 +794,13 @@ pub const SYS_memfd_secret: ::c_long = 447;
 pub const SYS_process_mrelease: ::c_long = 448;
 pub const SYS_futex_waitv: ::c_long = 449;
 pub const SYS_set_mempolicy_home_node: ::c_long = 450;
+
+cfg_if! {
+    if #[cfg(gnu_time64_abi)] {
+        mod time64;
+        pub use self::time64::*;
+    } else {
+        mod time32;
+        pub use self::time32::*;
+    }
+}
diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc/time32.rs b/src/unix/linux_like/linux/gnu/b32/powerpc/time32.rs
new file mode 100644
index 0000000000000..74fb67b1d98bf
--- /dev/null
+++ b/src/unix/linux_like/linux/gnu/b32/powerpc/time32.rs
@@ -0,0 +1,40 @@
+s! {
+    pub struct stat64 {
+        pub st_dev: ::dev_t,
+        pub st_ino: ::ino64_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,
+        __pad2: ::c_ushort,
+        pub st_size: ::off64_t,
+        pub st_blksize: ::blksize_t,
+        pub st_blocks: ::blkcnt64_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,
+        __glibc_reserved4: ::c_ulong,
+        __glibc_reserved5: ::c_ulong,
+    }
+
+    pub struct shmid_ds {
+        pub shm_perm: ::ipc_perm,
+        __glibc_reserved1: ::c_uint,
+        pub shm_atime: ::time_t,
+        __glibc_reserved2: ::c_uint,
+        pub shm_dtime: ::time_t,
+        __glibc_reserved3: ::c_uint,
+        pub shm_ctime: ::time_t,
+        __glibc_reserved4: ::c_uint,
+        pub shm_segsz: ::size_t,
+        pub shm_cpid: ::pid_t,
+        pub shm_lpid: ::pid_t,
+        pub shm_nattch: ::shmatt_t,
+        __glibc_reserved5: ::c_ulong,
+        __glibc_reserved6: ::c_ulong,
+    }
+}
diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc/time64.rs b/src/unix/linux_like/linux/gnu/b32/powerpc/time64.rs
new file mode 100644
index 0000000000000..2a1903fd4b429
--- /dev/null
+++ b/src/unix/linux_like/linux/gnu/b32/powerpc/time64.rs
@@ -0,0 +1,17 @@
+use stat;
+pub type stat64 = stat;
+
+s! {
+    pub struct shmid_ds {
+        pub shm_perm: ::ipc_perm,
+        pub shm_segsz: ::size_t,
+        pub shm_atime: ::time_t,
+        pub shm_dtime: ::time_t,
+        pub shm_ctime: ::time_t,
+        pub shm_cpid: ::pid_t,
+        pub shm_lpid: ::pid_t,
+        pub shm_nattch: ::shmatt_t,
+        __glibc_reserved5: ::c_ulong,
+        __glibc_reserved6: ::c_ulong,
+    }
+}
diff --git a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs
index 8a75e6d42b32b..95a95ea59a591 100644
--- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs
+++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs
@@ -126,6 +126,40 @@ s! {
         pub __f_spare: [::c_int; 6],
     }
 
+    pub struct timex {
+        pub modes: ::c_uint,
+        pub offset: ::c_long,
+        pub freq: ::c_long,
+        pub maxerror: ::c_long,
+        pub esterror: ::c_long,
+        pub status: ::c_int,
+        pub constant: ::c_long,
+        pub precision: ::c_long,
+        pub tolerance: ::c_long,
+        pub time: ::timeval,
+        pub tick: ::c_long,
+        pub ppsfreq: ::c_long,
+        pub jitter: ::c_long,
+        pub shift: ::c_int,
+        pub stabil: ::c_long,
+        pub jitcnt: ::c_long,
+        pub calcnt: ::c_long,
+        pub errcnt: ::c_long,
+        pub stbcnt: ::c_long,
+        pub tai: ::c_int,
+        pub __unused1: i32,
+        pub __unused2: i32,
+        pub __unused3: i32,
+        pub __unused4: i32,
+        pub __unused5: i32,
+        pub __unused6: i32,
+        pub __unused7: i32,
+        pub __unused8: i32,
+        pub __unused9: i32,
+        pub __unused10: i32,
+        pub __unused11: i32,
+    }
+
     pub struct siginfo_t {
         pub si_signo: ::c_int,
         pub si_errno: ::c_int,
diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs
index 16b836f7e6128..898391c9a68f6 100644
--- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs
+++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs
@@ -100,21 +100,6 @@ s! {
         __reserved: [::c_long; 2],
     }
 
-    pub struct statfs64 {
-        pub f_type: ::__fsword_t,
-        pub f_bsize: ::__fsword_t,
-        pub f_blocks: u64,
-        pub f_bfree: u64,
-        pub f_bavail: u64,
-        pub f_files: u64,
-        pub f_ffree: u64,
-        pub f_fsid: ::fsid_t,
-        pub f_namelen: ::__fsword_t,
-        pub f_frsize: ::__fsword_t,
-        pub f_flags: ::__fsword_t,
-        pub f_spare: [::__fsword_t; 4],
-    }
-
     pub struct statvfs {
         pub f_bsize: ::c_ulong,
         pub f_frsize: ::c_ulong,
@@ -130,19 +115,38 @@ s! {
         __f_spare: [::c_int; 6],
     }
 
-    pub struct statvfs64 {
-        pub f_bsize: ::c_ulong,
-        pub f_frsize: ::c_ulong,
-        pub f_blocks: u64,
-        pub f_bfree: u64,
-        pub f_bavail: u64,
-        pub f_files: u64,
-        pub f_ffree: u64,
-        pub f_favail: u64,
-        pub f_fsid: ::c_ulong,
-        pub f_flag: ::c_ulong,
-        pub f_namemax: ::c_ulong,
-        __f_spare: [::c_int; 6],
+    pub struct timex {
+        pub modes: ::c_uint,
+        pub offset: ::c_long,
+        pub freq: ::c_long,
+        pub maxerror: ::c_long,
+        pub esterror: ::c_long,
+        pub status: ::c_int,
+        pub constant: ::c_long,
+        pub precision: ::c_long,
+        pub tolerance: ::c_long,
+        pub time: ::timeval,
+        pub tick: ::c_long,
+        pub ppsfreq: ::c_long,
+        pub jitter: ::c_long,
+        pub shift: ::c_int,
+        pub stabil: ::c_long,
+        pub jitcnt: ::c_long,
+        pub calcnt: ::c_long,
+        pub errcnt: ::c_long,
+        pub stbcnt: ::c_long,
+        pub tai: ::c_int,
+        pub __unused1: i32,
+        pub __unused2: i32,
+        pub __unused3: i32,
+        pub __unused4: i32,
+        pub __unused5: i32,
+        pub __unused6: i32,
+        pub __unused7: i32,
+        pub __unused8: i32,
+        pub __unused9: i32,
+        pub __unused10: i32,
+        pub __unused11: i32,
     }
 
     pub struct ipc_perm {
@@ -851,3 +855,12 @@ pub const SYS_set_mempolicy_home_node: ::c_long = 450;
 
 mod align;
 pub use self::align::*;
+cfg_if! {
+    if #[cfg(gnu_time64_abi)] {
+        mod time64;
+        pub use self::time64::*;
+    } else {
+        mod time32;
+        pub use self::time32::*;
+    }
+}
diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/time32.rs b/src/unix/linux_like/linux/gnu/b32/sparc/time32.rs
new file mode 100644
index 0000000000000..69a850a81c6f1
--- /dev/null
+++ b/src/unix/linux_like/linux/gnu/b32/sparc/time32.rs
@@ -0,0 +1,31 @@
+s! {
+    pub struct statfs64 {
+        pub f_type: ::__fsword_t,
+        pub f_bsize: ::__fsword_t,
+        pub f_blocks: u64,
+        pub f_bfree: u64,
+        pub f_bavail: u64,
+        pub f_files: u64,
+        pub f_ffree: u64,
+        pub f_fsid: ::fsid_t,
+        pub f_namelen: ::__fsword_t,
+        pub f_frsize: ::__fsword_t,
+        pub f_flags: ::__fsword_t,
+        pub f_spare: [::__fsword_t; 4],
+    }
+
+    pub struct statvfs64 {
+        pub f_bsize: ::c_ulong,
+        pub f_frsize: ::c_ulong,
+        pub f_blocks: u64,
+        pub f_bfree: u64,
+        pub f_bavail: u64,
+        pub f_files: u64,
+        pub f_ffree: u64,
+        pub f_favail: u64,
+        pub f_fsid: ::c_ulong,
+        pub f_flag: ::c_ulong,
+        pub f_namemax: ::c_ulong,
+        __f_spare: [::c_int; 6],
+    }
+}
diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/time64.rs b/src/unix/linux_like/linux/gnu/b32/sparc/time64.rs
new file mode 100644
index 0000000000000..97aa11d949c66
--- /dev/null
+++ b/src/unix/linux_like/linux/gnu/b32/sparc/time64.rs
@@ -0,0 +1,4 @@
+use statfs;
+use statvfs;
+pub type statfs64 = statfs;
+pub type statvfs64 = statvfs;
diff --git a/src/unix/linux_like/linux/gnu/b32/time32.rs b/src/unix/linux_like/linux/gnu/b32/time32.rs
new file mode 100644
index 0000000000000..fc2c0c87e824d
--- /dev/null
+++ b/src/unix/linux_like/linux/gnu/b32/time32.rs
@@ -0,0 +1,87 @@
+//! 32-bit specific definitions for linux-like values when gnu_time64_abi is not set
+
+s! {
+    pub struct stat {
+        #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
+        pub st_dev: ::dev_t,
+        #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
+        pub st_dev: ::c_ulong,
+
+        #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
+        __pad1: ::c_short,
+        #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
+        st_pad1: [::c_long; 3],
+        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,
+        #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
+        pub st_rdev: ::dev_t,
+        #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
+        pub st_rdev: ::c_ulong,
+        #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
+        __pad2: ::c_short,
+        #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
+        st_pad2: [::c_long; 2],
+        pub st_size: ::off_t,
+        #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
+        st_pad3: ::c_long,
+        #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
+        pub st_blksize: ::blksize_t,
+        #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
+        pub st_blocks: ::blkcnt_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,
+        #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
+        __unused4: ::c_long,
+        #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
+        __unused5: ::c_long,
+        #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
+        pub st_blksize: ::blksize_t,
+        #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
+        pub st_blocks: ::blkcnt_t,
+        #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
+        st_pad5: [::c_long; 14],
+    }
+
+    pub struct timex {
+        pub modes: ::c_uint,
+
+        pub offset: ::__syscall_slong_t,
+        pub freq: ::__syscall_slong_t,
+        pub maxerror: ::__syscall_slong_t,
+        pub esterror: ::__syscall_slong_t,
+        pub status: ::c_int,
+        pub constant: ::__syscall_slong_t,
+        pub precision: ::__syscall_slong_t,
+        pub tolerance: ::__syscall_slong_t,
+        pub time: ::timeval,
+        pub tick: ::__syscall_slong_t,
+        pub ppsfreq: ::__syscall_slong_t,
+        pub jitter: ::__syscall_slong_t,
+        pub shift: ::c_int,
+        pub stabil: ::__syscall_slong_t,
+        pub jitcnt: ::__syscall_slong_t,
+        pub calcnt: ::__syscall_slong_t,
+        pub errcnt: ::__syscall_slong_t,
+        pub stbcnt: ::__syscall_slong_t,
+        pub tai: ::c_int,
+        pub __unused1: i32,
+        pub __unused2: i32,
+        pub __unused3: i32,
+        pub __unused4: i32,
+        pub __unused5: i32,
+        pub __unused6: i32,
+        pub __unused7: i32,
+        pub __unused8: i32,
+        pub __unused9: i32,
+        pub __unused10: i32,
+        pub __unused11: i32,
+    }
+
+}
diff --git a/src/unix/linux_like/linux/gnu/b32/time64.rs b/src/unix/linux_like/linux/gnu/b32/time64.rs
new file mode 100644
index 0000000000000..5a76f4b652428
--- /dev/null
+++ b/src/unix/linux_like/linux/gnu/b32/time64.rs
@@ -0,0 +1,72 @@
+//! 32-bit specific definitions for linux-like values when gnu_time64_abi is set
+
+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_size: ::off_t,
+        pub st_blksize: ::blksize_t,
+        pub st_blocks: ::blkcnt_t,
+        pub st_atime: ::time_t,
+        #[cfg(target_arch = "powerpc")]
+        __pad1: i32,
+        pub st_atime_nsec: ::c_long,
+        #[cfg(not(target_arch = "powerpc"))]  //x86 and arm and ?
+        __pad1: i32,
+        pub st_mtime: ::time_t,
+        #[cfg(target_arch = "powerpc")]
+        __pad2: i32,
+        pub st_mtime_nsec: ::c_long,
+        #[cfg(not(target_arch = "powerpc"))]
+        __pad2: i32,
+        pub st_ctime: ::time_t,
+        #[cfg(target_arch = "powerpc")]
+        __pad3: i32,
+        pub st_ctime_nsec: ::c_long,
+        #[cfg(not(target_arch = "powerpc"))]
+        __pad3: i32,
+    }
+
+    pub struct timex {
+        pub modes: ::c_uint,
+
+        __unused_pad1: i32,
+        pub offset: ::c_longlong,
+        pub freq: ::c_longlong,
+        pub maxerror: ::c_longlong,
+        pub esterror: ::c_longlong,
+        pub status: ::c_int,
+        __unused_pad2: i32,
+        pub constant: ::c_longlong,
+        pub precision: ::c_longlong,
+        pub tolerance: ::c_longlong,
+        pub time: ::timeval,
+        pub tick: ::c_longlong,
+        pub ppsfreq: ::c_longlong,
+        pub jitter: ::c_longlong,
+        pub shift: ::c_int,
+        __unused_pad3: i32,
+        pub stabil: ::c_longlong,
+        pub jitcnt: ::c_longlong,
+        pub calcnt: ::c_longlong,
+        pub errcnt: ::c_longlong,
+        pub stbcnt: ::c_longlong,
+        pub tai: ::c_int,
+        __unused1: i32,
+        __unused2: i32,
+        __unused3: i32,
+        __unused4: i32,
+        __unused5: i32,
+        __unused6: i32,
+        __unused7: i32,
+        __unused8: i32,
+        __unused9: i32,
+        __unused10: i32,
+        __unused11: i32,
+    }
+}
diff --git a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs
index 8e206b114cd3a..c3c10daab17ed 100644
--- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs
+++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs
@@ -130,28 +130,6 @@ s! {
         __unused2: ::c_ulong
     }
 
-    pub struct stat64 {
-        pub st_dev: ::dev_t,
-        __pad1: ::c_uint,
-        __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,
-        __pad2: ::c_uint,
-        pub st_size: ::off64_t,
-        pub st_blksize: ::blksize_t,
-        pub st_blocks: ::blkcnt64_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_ino: ::ino64_t,
-    }
-
     pub struct statfs64 {
         pub f_type: ::__fsword_t,
         pub f_bsize: ::__fsword_t,
@@ -187,10 +165,13 @@ s! {
         pub shm_perm: ::ipc_perm,
         pub shm_segsz: ::size_t,
         pub shm_atime: ::time_t,
+        #[cfg(not(gnu_time64_abi))]
         __unused1: ::c_ulong,
         pub shm_dtime: ::time_t,
+        #[cfg(not(gnu_time64_abi))]
         __unused2: ::c_ulong,
         pub shm_ctime: ::time_t,
+        #[cfg(not(gnu_time64_abi))]
         __unused3: ::c_ulong,
         pub shm_cpid: ::pid_t,
         pub shm_lpid: ::pid_t,
@@ -202,10 +183,13 @@ s! {
     pub struct msqid_ds {
         pub msg_perm: ::ipc_perm,
         pub msg_stime: ::time_t,
+        #[cfg(not(gnu_time64_abi))]
         __glibc_reserved1: ::c_ulong,
         pub msg_rtime: ::time_t,
+        #[cfg(not(gnu_time64_abi))]
         __glibc_reserved2: ::c_ulong,
         pub msg_ctime: ::time_t,
+        #[cfg(not(gnu_time64_abi))]
         __glibc_reserved3: ::c_ulong,
         __msg_cbytes: ::c_ulong,
         pub msg_qnum: ::msgqnum_t,
@@ -492,7 +476,13 @@ pub const SA_NOCLDWAIT: ::c_int = 0x00000002;
 pub const SOCK_STREAM: ::c_int = 1;
 pub const SOCK_DGRAM: ::c_int = 2;
 
-pub const F_GETLK: ::c_int = 5;
+cfg_if! {
+    if #[cfg(gnu_time64_abi)] {
+        pub const F_GETLK: ::c_int = 12;
+    } else {
+        pub const F_GETLK: ::c_int = 5;
+    }
+}
 pub const F_GETOWN: ::c_int = 9;
 pub const F_SETOWN: ::c_int = 8;
 
@@ -1096,3 +1086,13 @@ extern "C" {
 
 mod align;
 pub use self::align::*;
+
+cfg_if! {
+    if #[cfg(gnu_time64_abi)] {
+        mod time64;
+        pub use self::time64::*;
+    } else {
+        mod time32;
+        pub use self::time32::*;
+    }
+}
diff --git a/src/unix/linux_like/linux/gnu/b32/x86/time32.rs b/src/unix/linux_like/linux/gnu/b32/x86/time32.rs
new file mode 100644
index 0000000000000..c8bd6d14deccb
--- /dev/null
+++ b/src/unix/linux_like/linux/gnu/b32/x86/time32.rs
@@ -0,0 +1,23 @@
+s! {
+    pub struct stat64 {
+        pub st_dev: ::dev_t,
+        __pad1: ::c_uint,
+        __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,
+        __pad2: ::c_uint,
+        pub st_size: ::off64_t,
+        pub st_blksize: ::blksize_t,
+        pub st_blocks: ::blkcnt64_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_ino: ::ino64_t,
+    }
+}
diff --git a/src/unix/linux_like/linux/gnu/b32/x86/time64.rs b/src/unix/linux_like/linux/gnu/b32/x86/time64.rs
new file mode 100644
index 0000000000000..7facf6ae7f287
--- /dev/null
+++ b/src/unix/linux_like/linux/gnu/b32/x86/time64.rs
@@ -0,0 +1,2 @@
+use stat;
+pub type stat64 = stat;
diff --git a/src/unix/linux_like/linux/gnu/b64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mod.rs
index ff394e33a2136..705365efd3253 100644
--- a/src/unix/linux_like/linux/gnu/b64/mod.rs
+++ b/src/unix/linux_like/linux/gnu/b64/mod.rs
@@ -9,11 +9,16 @@ pub type msglen_t = u64;
 pub type fsblkcnt_t = u64;
 pub type fsfilcnt_t = u64;
 pub type rlim_t = u64;
-#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
-pub type __syscall_ulong_t = ::c_ulonglong;
-#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
-pub type __syscall_ulong_t = ::c_ulong;
 
+cfg_if! {
+    if #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] {
+        pub type __syscall_ulong_t = ::c_ulonglong;
+        pub type __syscall_slong_t = ::c_longlong;
+    } else {
+        pub type __syscall_ulong_t = ::c_ulong;
+        pub type __syscall_slong_t = ::c_long;
+    }
+}
 cfg_if! {
     if #[cfg(all(target_arch = "aarch64", target_pointer_width = "32"))] {
         pub type clock_t = i32;
@@ -91,6 +96,46 @@ s! {
         __glibc_reserved3: ::__syscall_ulong_t,
         __glibc_reserved4: ::__syscall_ulong_t,
     }
+
+    pub struct timex {
+        pub modes: ::c_uint,
+        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
+        pub __unused_pad1: i32,
+        pub offset: ::__syscall_slong_t,
+        pub freq: ::__syscall_slong_t,
+        pub maxerror: ::__syscall_slong_t,
+        pub esterror: ::__syscall_slong_t,
+        pub status: ::c_int,
+        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
+        pub __unused_pad2: i32,
+        pub constant: ::__syscall_slong_t,
+        pub precision: ::__syscall_slong_t,
+        pub tolerance: ::__syscall_slong_t,
+        pub time: ::timeval,
+        pub tick: ::__syscall_slong_t,
+        pub ppsfreq: ::__syscall_slong_t,
+        pub jitter: ::__syscall_slong_t,
+        pub shift: ::c_int,
+        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
+        pub __unused_pad3: i32,
+        pub stabil: ::__syscall_slong_t,
+        pub jitcnt: ::__syscall_slong_t,
+        pub calcnt: ::__syscall_slong_t,
+        pub errcnt: ::__syscall_slong_t,
+        pub stbcnt: ::__syscall_slong_t,
+        pub tai: ::c_int,
+        pub __unused1: i32,
+        pub __unused2: i32,
+        pub __unused3: i32,
+        pub __unused4: i32,
+        pub __unused5: i32,
+        pub __unused6: i32,
+        pub __unused7: i32,
+        pub __unused8: i32,
+        pub __unused9: i32,
+        pub __unused10: i32,
+        pub __unused11: i32,
+    }
 }
 
 pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs
index 6d5deb6b24abd..a39a7297f11d5 100644
--- a/src/unix/linux_like/linux/gnu/mod.rs
+++ b/src/unix/linux_like/linux/gnu/mod.rs
@@ -62,7 +62,7 @@ s! {
         __error_code: ::c_int,
         __return_value: ::ssize_t,
         pub aio_offset: off_t,
-        #[cfg(all(not(target_arch = "x86_64"), target_pointer_width = "32"))]
+        #[cfg(all(not(gnu_time64_abi), not(target_arch = "x86_64"), target_pointer_width = "32"))]
         __unused1: [::c_char; 4],
         __glibc_reserved: [::c_char; 32]
     }
@@ -198,84 +198,6 @@ s! {
         pub rt_irtt: ::c_ushort,
     }
 
-    pub struct timex {
-        pub modes: ::c_uint,
-        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
-        pub offset: i64,
-        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
-        pub offset: ::c_long,
-        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
-        pub freq: i64,
-        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
-        pub freq: ::c_long,
-        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
-        pub maxerror: i64,
-        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
-        pub maxerror: ::c_long,
-        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
-        pub esterror: i64,
-        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
-        pub esterror: ::c_long,
-        pub status: ::c_int,
-        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
-        pub constant: i64,
-        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
-        pub constant: ::c_long,
-        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
-        pub precision: i64,
-        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
-        pub precision: ::c_long,
-        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
-        pub tolerance: i64,
-        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
-        pub tolerance: ::c_long,
-        pub time: ::timeval,
-        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
-        pub tick: i64,
-        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
-        pub tick: ::c_long,
-        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
-        pub ppsfreq: i64,
-        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
-        pub ppsfreq: ::c_long,
-        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
-        pub jitter: i64,
-        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
-        pub jitter: ::c_long,
-        pub shift: ::c_int,
-        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
-        pub stabil: i64,
-        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
-        pub stabil: ::c_long,
-        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
-        pub jitcnt: i64,
-        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
-        pub jitcnt: ::c_long,
-        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
-        pub calcnt: i64,
-        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
-        pub calcnt: ::c_long,
-        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
-        pub errcnt: i64,
-        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
-        pub errcnt: ::c_long,
-        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
-        pub stbcnt: i64,
-        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
-        pub stbcnt: ::c_long,
-        pub tai: ::c_int,
-        pub __unused1: i32,
-        pub __unused2: i32,
-        pub __unused3: i32,
-        pub __unused4: i32,
-        pub __unused5: i32,
-        pub __unused6: i32,
-        pub __unused7: i32,
-        pub __unused8: i32,
-        pub __unused9: i32,
-        pub __unused10: i32,
-        pub __unused11: i32,
-    }
 
     pub struct ntptimeval {
         pub time: ::timeval,
@@ -1289,12 +1211,14 @@ extern "C" {
         >,
         arg: *mut ::c_void,
     );
+    #[cfg_attr(gnu_time64_abi, link_name = "__sendmmsg64")]
     pub fn sendmmsg(
         sockfd: ::c_int,
         msgvec: *mut ::mmsghdr,
         vlen: ::c_uint,
         flags: ::c_int,
     ) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__recvmmsg64")]
     pub fn recvmmsg(
         sockfd: ::c_int,
         msgvec: *mut ::mmsghdr,
@@ -1305,8 +1229,11 @@ extern "C" {
 
     pub fn getrlimit64(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit64) -> ::c_int;
     pub fn setrlimit64(resource: ::__rlimit_resource_t, rlim: *const ::rlimit64) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "getrlimit64")]
     pub fn getrlimit(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "setrlimit64")]
     pub fn setrlimit(resource: ::__rlimit_resource_t, rlim: *const ::rlimit) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "prlimit64")]
     pub fn prlimit(
         pid: ::pid_t,
         resource: ::__rlimit_resource_t,
@@ -1329,6 +1256,7 @@ extern "C" {
     pub fn endutxent();
     pub fn getpt() -> ::c_int;
     pub fn mallopt(param: ::c_int, value: ::c_int) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__gettimeofday64")]
     pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int;
     pub fn statx(
         dirfd: ::c_int,
@@ -1341,10 +1269,14 @@ extern "C" {
     pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
     pub fn getauxval(type_: ::c_ulong) -> ::c_ulong;
 
+    #[cfg_attr(gnu_time64_abi, link_name = "___adjtimex64")]
     pub fn adjtimex(buf: *mut timex) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "___adjtimex64")]
     pub fn ntp_adjtime(buf: *mut timex) -> ::c_int;
-    #[link_name = "ntp_gettimex"]
+    #[cfg_attr(not(gnu_time64_abi), link_name = "ntp_gettimex")]
+    #[cfg_attr(gnu_time64_abi, link_name = "__ntp_gettime64")]
     pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__clock_adjtime64")]
     pub fn clock_adjtime(clk_id: ::clockid_t, buf: *mut ::timex) -> ::c_int;
 
     pub fn fanotify_mark(
@@ -1354,6 +1286,7 @@ extern "C" {
         dirfd: ::c_int,
         path: *const ::c_char,
     ) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "preadv64v2")]
     pub fn preadv2(
         fd: ::c_int,
         iov: *const ::iovec,
@@ -1361,6 +1294,7 @@ extern "C" {
         offset: ::off_t,
         flags: ::c_int,
     ) -> ::ssize_t;
+    #[cfg_attr(gnu_time64_abi, link_name = "pwritev64v2")]
     pub fn pwritev2(
         fd: ::c_int,
         iov: *const ::iovec,
@@ -1396,14 +1330,17 @@ extern "C" {
     pub fn reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void;
 
     pub fn ctermid(s: *mut ::c_char) -> *mut ::c_char;
+    #[cfg_attr(gnu_time64_abi, link_name = "__ioctl_time64")]
     pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
     pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__glob64_time64")]
     pub fn glob64(
         pattern: *const ::c_char,
         flags: ::c_int,
         errfunc: ::Option<extern "C" fn(epath: *const ::c_char, errno: ::c_int) -> ::c_int>,
         pglob: *mut glob64_t,
     ) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__globfree64_time64")]
     pub fn globfree64(pglob: *mut glob64_t);
     pub fn ptrace(request: ::c_uint, ...) -> ::c_long;
     pub fn pthread_attr_getaffinity_np(
@@ -1471,6 +1408,7 @@ extern "C" {
     pub fn eaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int;
 
     pub fn asctime_r(tm: *const ::tm, buf: *mut ::c_char) -> *mut ::c_char;
+    #[cfg_attr(gnu_time64_abi, link_name = "__ctime64_r")]
     pub fn ctime_r(timep: *const time_t, buf: *mut ::c_char) -> *mut ::c_char;
 
     pub fn strftime(
diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs
index ba68965174c09..c256f2eefed8b 100644
--- a/src/unix/linux_like/linux/mod.rs
+++ b/src/unix/linux_like/linux/mod.rs
@@ -322,7 +322,19 @@ s! {
     }
 
     pub struct input_event {
-        pub time: ::timeval,
+        #[cfg(any(target_pointer_width = "64", not(gnu_time64_abi)))]
+        pub input_event_sec: ::time_t,
+        #[cfg(all(target_pointer_width = "32", gnu_time64_abi))]
+        pub input_event_sec: ::c_ulong,
+
+        #[cfg(any(target_pointer_width = "64", not(gnu_time64_abi)))]
+        pub input_event_usec: ::suseconds_t,
+        #[cfg(all(target_pointer_width = "32", gnu_time64_abi))]
+        pub input_event_usec: ::c_ulong,
+
+        #[cfg(target_arch = "sparc64")]
+        _pad1: ::c_int,
+
         pub type_: ::__u16,
         pub code: ::__u16,
         pub value: ::__s32,
@@ -5340,17 +5352,24 @@ safe_f! {
 cfg_if! {
     if #[cfg(all(not(target_env = "uclibc"), not(target_env = "ohos")))] {
         extern "C" {
+            #[cfg_attr(gnu_time64_abi, link_name = "aio_read64")]
             pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
+            #[cfg_attr(gnu_time64_abi, link_name = "aio_write64")]
             pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
             pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
+            #[cfg_attr(gnu_time64_abi, link_name = "aio_error64")]
             pub fn aio_error(aiocbp: *const aiocb) -> ::c_int;
+            #[cfg_attr(gnu_time64_abi, link_name = "aio_return64")]
             pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t;
+            #[cfg_attr(gnu_time64_abi, link_name = "__aio_suspend_time64")]
             pub fn aio_suspend(
                 aiocb_list: *const *const aiocb,
                 nitems: ::c_int,
                 timeout: *const ::timespec,
             ) -> ::c_int;
+            #[cfg_attr(gnu_time64_abi, link_name = "aio_cancel64")]
             pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
+            #[cfg_attr(gnu_time64_abi, link_name = "lio_listio64")]
             pub fn lio_listio(
                 mode: ::c_int,
                 aiocb_list: *const *mut aiocb,
@@ -5364,12 +5383,14 @@ cfg_if! {
 cfg_if! {
     if #[cfg(not(target_env = "uclibc"))] {
         extern "C" {
+            #[cfg_attr(gnu_time64_abi, link_name = "pwritev64")]
             pub fn pwritev(
                 fd: ::c_int,
                 iov: *const ::iovec,
                 iovcnt: ::c_int,
                 offset: ::off_t,
             ) -> ::ssize_t;
+            #[cfg_attr(gnu_time64_abi, link_name = "preadv64")]
             pub fn preadv(
                 fd: ::c_int,
                 iov: *const ::iovec,
@@ -5405,6 +5426,7 @@ cfg_if! {
                 riovcnt: ::c_ulong,
                 flags: ::c_ulong,
             ) -> isize;
+            #[cfg_attr(gnu_time64_abi, link_name = "__futimes64")]
             pub fn futimes(
                 fd: ::c_int,
                 times: *const ::timeval
@@ -5437,6 +5459,7 @@ cfg_if! {
                 msg_len: ::size_t,
                 msg_prio: *mut ::c_uint,
             ) -> ::ssize_t;
+            #[cfg_attr(gnu_time64_abi, link_name = "__mq_timedreceive_time64")]
             pub fn mq_timedreceive(
                 mqd: ::mqd_t,
                 msg_ptr: *mut ::c_char,
@@ -5450,6 +5473,7 @@ cfg_if! {
                 msg_len: ::size_t,
                 msg_prio: ::c_uint,
             ) -> ::c_int;
+            #[cfg_attr(gnu_time64_abi, link_name = "__mq_timedsend_time64")]
             pub fn mq_timedsend(
                 mqd: ::mqd_t,
                 msg_ptr: *const ::c_char,
@@ -5500,6 +5524,7 @@ extern "C" {
     pub fn seed48(xseed: *mut ::c_ushort) -> *mut ::c_ushort;
     pub fn lcong48(p: *mut ::c_ushort);
 
+    #[cfg_attr(gnu_time64_abi, link_name = "__lutimes64")]
     pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;
 
     pub fn setpwent();
@@ -5521,11 +5546,14 @@ extern "C" {
     pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int;
     pub fn shmat(shmid: ::c_int, shmaddr: *const ::c_void, shmflg: ::c_int) -> *mut ::c_void;
     pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__shmctl64")]
     pub fn shmctl(shmid: ::c_int, cmd: ::c_int, buf: *mut ::shmid_ds) -> ::c_int;
     pub fn ftok(pathname: *const ::c_char, proj_id: ::c_int) -> ::key_t;
     pub fn semget(key: ::key_t, nsems: ::c_int, semflag: ::c_int) -> ::c_int;
     pub fn semop(semid: ::c_int, sops: *mut ::sembuf, nsops: ::size_t) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__semctl64")]
     pub fn semctl(semid: ::c_int, semnum: ::c_int, cmd: ::c_int, ...) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__msgctl64")]
     pub fn msgctl(msqid: ::c_int, cmd: ::c_int, buf: *mut msqid_ds) -> ::c_int;
     pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int;
     pub fn msgrcv(
@@ -5545,7 +5573,9 @@ extern "C" {
     pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int;
     pub fn __errno_location() -> *mut ::c_int;
 
+    #[cfg_attr(gnu_time64_abi, link_name = "fallocate64")]
     pub fn fallocate(fd: ::c_int, mode: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "posix_fallocate64")]
     pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int;
     pub fn readahead(fd: ::c_int, offset: ::off64_t, count: ::size_t) -> ::ssize_t;
     pub fn getxattr(
@@ -5595,7 +5625,9 @@ extern "C" {
     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(clockid: ::clockid_t, flags: ::c_int) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__timerfd_gettime64")]
     pub fn timerfd_gettime(fd: ::c_int, curr_value: *mut itimerspec) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__timerfd_settime64")]
     pub fn timerfd_settime(
         fd: ::c_int,
         flags: ::c_int,
@@ -5616,8 +5648,11 @@ extern "C" {
         sigmask: *const ::sigset_t,
     ) -> ::c_int;
     pub fn dup3(oldfd: ::c_int, newfd: ::c_int, flags: ::c_int) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "mkostemp64")]
     pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "mkostemps64")]
     pub fn mkostemps(template: *mut ::c_char, suffixlen: ::c_int, flags: ::c_int) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__sigtimedwait64")]
     pub fn sigtimedwait(
         set: *const sigset_t,
         info: *mut siginfo_t,
@@ -5664,12 +5699,14 @@ extern "C" {
         ...
     ) -> *mut ::c_void;
 
+    #[cfg_attr(gnu_time64_abi, link_name = "__glob64_time64")]
     pub fn glob(
         pattern: *const c_char,
         flags: ::c_int,
         errfunc: ::Option<extern "C" fn(epath: *const c_char, errno: ::c_int) -> ::c_int>,
         pglob: *mut ::glob_t,
     ) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__globfree64_time64")]
     pub fn globfree(pglob: *mut ::glob_t);
 
     pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int;
@@ -5695,6 +5732,7 @@ extern "C" {
         addr: *mut ::sockaddr,
         addrlen: *mut ::socklen_t,
     ) -> ::ssize_t;
+    #[cfg_attr(gnu_time64_abi, link_name = "mkstemps64")]
     pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
 
     pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;
@@ -5731,6 +5769,7 @@ extern "C" {
     pub fn umount(target: *const ::c_char) -> ::c_int;
     pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int;
     pub fn tee(fd_in: ::c_int, fd_out: ::c_int, len: ::size_t, flags: ::c_uint) -> ::ssize_t;
+    #[cfg_attr(gnu_time64_abi, link_name = "__settimeofday64")]
     pub fn settimeofday(tv: *const ::timeval, tz: *const ::timezone) -> ::c_int;
     pub fn splice(
         fd_in: ::c_int,
@@ -5744,7 +5783,9 @@ extern "C" {
     pub fn eventfd_read(fd: ::c_int, value: *mut eventfd_t) -> ::c_int;
     pub fn eventfd_write(fd: ::c_int, value: eventfd_t) -> ::c_int;
 
+    #[cfg_attr(gnu_time64_abi, link_name = "__sched_rr_get_interval64")]
     pub fn sched_rr_get_interval(pid: ::pid_t, tp: *mut ::timespec) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__sem_timedwait64")]
     pub fn sem_timedwait(sem: *mut sem_t, abstime: *const ::timespec) -> ::c_int;
     pub fn sem_getvalue(sem: *mut sem_t, sval: *mut ::c_int) -> ::c_int;
     pub fn sched_setparam(pid: ::pid_t, param: *const ::sched_param) -> ::c_int;
@@ -5764,8 +5805,10 @@ extern "C" {
         data: *const ::c_void,
     ) -> ::c_int;
     pub fn personality(persona: ::c_ulong) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__prctl_time64")]
     pub fn prctl(option: ::c_int, ...) -> ::c_int;
     pub fn sched_getparam(pid: ::pid_t, param: *mut ::sched_param) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__ppoll64")]
     pub fn ppoll(
         fds: *mut ::pollfd,
         nfds: nfds_t,
@@ -5781,6 +5824,7 @@ extern "C" {
         protocol: ::c_int,
     ) -> ::c_int;
 
+    #[cfg_attr(gnu_time64_abi, link_name = "__pthread_mutex_timedlock64")]
     pub fn pthread_mutex_timedlock(
         lock: *mut pthread_mutex_t,
         abstime: *const ::timespec,
@@ -5815,6 +5859,7 @@ extern "C" {
         ...
     ) -> ::c_int;
     pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__clock_nanosleep_time64")]
     pub fn clock_nanosleep(
         clk_id: ::clockid_t,
         flags: ::c_int,
@@ -5866,6 +5911,7 @@ extern "C" {
         policy: ::c_int,
         param: *const ::sched_param,
     ) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "sendfile64")]
     pub fn sendfile(
         out_fd: ::c_int,
         in_fd: ::c_int,
@@ -6084,7 +6130,9 @@ extern "C" {
     ) -> ::c_int;
     pub fn timer_delete(timerid: ::timer_t) -> ::c_int;
     pub fn timer_getoverrun(timerid: ::timer_t) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__timer_gettime64")]
     pub fn timer_gettime(timerid: ::timer_t, curr_value: *mut ::itimerspec) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__timer_settime64")]
     pub fn timer_settime(
         timerid: ::timer_t,
         flags: ::c_int,
diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs
index bdbec9c651fc5..864a23a375d33 100644
--- a/src/unix/linux_like/mod.rs
+++ b/src/unix/linux_like/mod.rs
@@ -1675,8 +1675,11 @@ extern "C" {
     pub fn fdatasync(fd: ::c_int) -> ::c_int;
     pub fn mincore(addr: *mut ::c_void, len: ::size_t, vec: *mut ::c_uchar) -> ::c_int;
 
+    #[cfg_attr(gnu_time64_abi, link_name = "__clock_getres64")]
     pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__clock_gettime64")]
     pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__clock_settime64")]
     pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int;
     pub fn clock_getcpuclockid(pid: ::pid_t, clk_id: *mut ::clockid_t) -> ::c_int;
 
@@ -1691,11 +1694,16 @@ extern "C" {
     pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
     pub fn setgroups(ngroups: ::size_t, ptr: *const ::gid_t) -> ::c_int;
     pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "statfs64")]
     pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "fstatfs64")]
     pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
     pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void;
+    #[cfg_attr(gnu_time64_abi, link_name = "posix_fadvise64")]
     pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, advise: ::c_int) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__futimens64")]
     pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__utimensat64")]
     pub fn utimensat(
         dirfd: ::c_int,
         path: *const ::c_char,
@@ -1741,6 +1749,7 @@ extern "C" {
     pub fn sbrk(increment: ::intptr_t) -> *mut ::c_void;
     pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int;
     pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "__wait4_time64")]
     pub fn wait4(
         pid: ::pid_t,
         status: *mut ::c_int,
@@ -1761,7 +1770,9 @@ extern "C" {
     pub fn writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t;
     pub fn readv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t;
 
+    #[cfg_attr(gnu_time64_abi, link_name = "__sendmsg64")]
     pub fn sendmsg(fd: ::c_int, msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t;
+    #[cfg_attr(gnu_time64_abi, link_name = "__recvmsg64")]
     pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t;
     pub fn uname(buf: *mut ::utsname) -> ::c_int;
 
@@ -1780,7 +1791,9 @@ cfg_if! {
             pub fn fstatvfs64(fd: ::c_int, buf: *mut statvfs64) -> ::c_int;
             pub fn statfs64(path: *const ::c_char, buf: *mut statfs64) -> ::c_int;
             pub fn creat64(path: *const c_char, mode: mode_t) -> ::c_int;
+            #[cfg_attr(gnu_time64_abi, link_name = "__fstat64_time64")]
             pub fn fstat64(fildes: ::c_int, buf: *mut stat64) -> ::c_int;
+            #[cfg_attr(gnu_time64_abi, link_name = "__fstatat64_time64")]
             pub fn fstatat64(
                 dirfd: ::c_int,
                 pathname: *const c_char,
@@ -1789,6 +1802,7 @@ cfg_if! {
             ) -> ::c_int;
             pub fn ftruncate64(fd: ::c_int, length: off64_t) -> ::c_int;
             pub fn lseek64(fd: ::c_int, offset: off64_t, whence: ::c_int) -> off64_t;
+            #[cfg_attr(gnu_time64_abi, link_name = "__lstat64_time64")]
             pub fn lstat64(path: *const c_char, buf: *mut stat64) -> ::c_int;
             pub fn mmap64(
                 addr: *mut ::c_void,
@@ -1824,6 +1838,7 @@ cfg_if! {
                 entry: *mut ::dirent64,
                 result: *mut *mut ::dirent64,
             ) -> ::c_int;
+            #[cfg_attr(gnu_time64_abi, link_name = "__stat64_time64")]
             pub fn stat64(path: *const c_char, buf: *mut stat64) -> ::c_int;
             pub fn truncate64(path: *const c_char, length: off64_t) -> ::c_int;
         }
diff --git a/src/unix/mod.rs b/src/unix/mod.rs
index 6cc072a739e6c..6d40e866a87bb 100644
--- a/src/unix/mod.rs
+++ b/src/unix/mod.rs
@@ -62,17 +62,26 @@ s! {
 
     pub struct timeval {
         pub tv_sec: time_t,
+        #[cfg(not(gnu_time64_abi))]
         pub tv_usec: suseconds_t,
+        // For 64 bit time on 32 bit linux glibc, suseconds_t is still
+        // a 32 bit type.  Using suseconds_t here will break the tests, use i64 instead
+        #[cfg(gnu_time64_abi)]
+        pub tv_usec: i64
     }
 
     // linux x32 compatibility
     // See https://sourceware.org/bugzilla/show_bug.cgi?id=16437
     pub struct timespec {
         pub tv_sec: time_t,
-        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
+        #[cfg(all(gnu_time64_abi, target_endian = "big"))]
+        __pad: i32,
+        #[cfg(all(not(target_env = "gnu"), target_arch = "x86_64", target_pointer_width = "32"))]
         pub tv_nsec: i64,
-        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
+        #[cfg(any(target_env = "gnu", not(all(target_arch = "x86_64", target_pointer_width = "32"))))]
         pub tv_nsec: ::c_long,
+        #[cfg(all(gnu_time64_abi, target_endian = "little"))]
+        __pad: i32,
     }
 
     pub struct rlimit {
@@ -449,17 +458,20 @@ extern "C" {
         all(target_os = "macos", target_arch = "x86"),
         link_name = "fopen$UNIX2003"
     )]
+    #[cfg_attr(gnu_time64_abi, link_name = "fopen64")]
     pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE;
     #[cfg_attr(
         all(target_os = "macos", target_arch = "x86"),
         link_name = "freopen$UNIX2003"
     )]
+    #[cfg_attr(gnu_time64_abi, link_name = "freopen64")]
     pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE;
 
     pub fn fflush(file: *mut FILE) -> c_int;
     pub fn fclose(file: *mut FILE) -> c_int;
     pub fn remove(filename: *const c_char) -> c_int;
     pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "tmpfile64")]
     pub fn tmpfile() -> *mut FILE;
     pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int;
     pub fn setbuf(stream: *mut FILE, buf: *mut c_char);
@@ -485,8 +497,10 @@ extern "C" {
     pub fn ftell(stream: *mut FILE) -> c_long;
     pub fn rewind(stream: *mut FILE);
     #[cfg_attr(target_os = "netbsd", link_name = "__fgetpos50")]
+    #[cfg_attr(gnu_time64_abi, link_name = "fgetpos64")]
     pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
     #[cfg_attr(target_os = "netbsd", link_name = "__fsetpos50")]
+    #[cfg_attr(gnu_time64_abi, link_name = "fsetpos64")]
     pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int;
     pub fn feof(stream: *mut FILE) -> c_int;
     pub fn ferror(stream: *mut FILE) -> c_int;
@@ -643,6 +657,7 @@ extern "C" {
         address_len: *mut socklen_t,
     ) -> ::c_int;
     #[cfg_attr(target_os = "espidf", link_name = "lwip_setsockopt")]
+    #[cfg_attr(gnu_time64_abi, link_name = "__setsockopt64")]
     pub fn setsockopt(
         socket: ::c_int,
         level: ::c_int,
@@ -705,6 +720,7 @@ extern "C" {
         all(target_os = "freebsd", any(freebsd11, freebsd10)),
         link_name = "fstat@FBSD_1.0"
     )]
+    #[cfg_attr(gnu_time64_abi, link_name = "__fstat64_time64")]
     pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
 
     pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int;
@@ -718,6 +734,7 @@ extern "C" {
         all(target_os = "freebsd", any(freebsd11, freebsd10)),
         link_name = "stat@FBSD_1.0"
     )]
+    #[cfg_attr(gnu_time64_abi, link_name = "__stat64_time64")]
     pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
 
     pub fn pclose(stream: *mut ::FILE) -> ::c_int;
@@ -732,16 +749,19 @@ extern "C" {
         all(target_os = "macos", target_arch = "x86"),
         link_name = "open$UNIX2003"
     )]
+    #[cfg_attr(gnu_time64_abi, link_name = "open64")]
     pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
     #[cfg_attr(
         all(target_os = "macos", target_arch = "x86"),
         link_name = "creat$UNIX2003"
     )]
+    #[cfg_attr(gnu_time64_abi, link_name = "creat64")]
     pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int;
     #[cfg_attr(
         all(target_os = "macos", target_arch = "x86"),
         link_name = "fcntl$UNIX2003"
     )]
+    #[cfg_attr(gnu_time64_abi, link_name = "__fcntl_time64")]
     pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int;
 
     #[cfg_attr(
@@ -764,6 +784,7 @@ extern "C" {
         all(target_os = "freebsd", any(freebsd11, freebsd10)),
         link_name = "readdir@FBSD_1.0"
     )]
+    #[cfg_attr(gnu_time64_abi, link_name = "readdir64")]
     pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent;
     #[cfg_attr(
         all(target_os = "macos", target_arch = "x86"),
@@ -802,6 +823,7 @@ extern "C" {
         all(target_os = "freebsd", any(freebsd11, freebsd10)),
         link_name = "fstatat@FBSD_1.1"
     )]
+    #[cfg_attr(gnu_time64_abi, link_name = "__fstatat64_time64")]
     pub fn fstatat(
         dirfd: ::c_int,
         pathname: *const ::c_char,
@@ -880,6 +902,7 @@ extern "C" {
     pub fn getuid() -> uid_t;
     pub fn isatty(fd: ::c_int) -> ::c_int;
     pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "lseek64")]
     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 pipe(fds: *mut ::c_int) -> ::c_int;
@@ -908,6 +931,7 @@ extern "C" {
         link_name = "nanosleep$UNIX2003"
     )]
     #[cfg_attr(target_os = "netbsd", link_name = "__nanosleep50")]
+    #[cfg_attr(gnu_time64_abi, link_name = "__nanosleep64")]
     pub fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> ::c_int;
     pub fn tcgetpgrp(fd: ::c_int) -> pid_t;
     pub fn tcsetpgrp(fd: ::c_int, pgrp: ::pid_t) -> ::c_int;
@@ -938,15 +962,18 @@ extern "C" {
         all(target_os = "macos", target_arch = "x86"),
         link_name = "pread$UNIX2003"
     )]
+    #[cfg_attr(gnu_time64_abi, link_name = "pread64")]
     pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, offset: off_t) -> ::ssize_t;
     #[cfg_attr(
         all(target_os = "macos", target_arch = "x86"),
         link_name = "pwrite$UNIX2003"
     )]
+    #[cfg_attr(gnu_time64_abi, link_name = "pwrite64")]
     pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t, offset: off_t) -> ::ssize_t;
     pub fn umask(mask: mode_t) -> mode_t;
 
     #[cfg_attr(target_os = "netbsd", link_name = "__utime50")]
+    #[cfg_attr(gnu_time64_abi, link_name = "__utime64")]
     pub fn utime(file: *const c_char, buf: *const utimbuf) -> ::c_int;
 
     #[cfg_attr(
@@ -969,6 +996,7 @@ extern "C" {
         all(target_os = "macos", target_arch = "x86"),
         link_name = "mmap$UNIX2003"
     )]
+    #[cfg_attr(gnu_time64_abi, link_name = "mmap64")]
     pub fn mmap(
         addr: *mut ::c_void,
         len: ::size_t,
@@ -995,6 +1023,7 @@ extern "C" {
         all(target_os = "freebsd", any(freebsd11, freebsd10)),
         link_name = "lstat@FBSD_1.0"
     )]
+    #[cfg_attr(gnu_time64_abi, link_name = "__lstat64_time64")]
     pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int;
 
     #[cfg_attr(
@@ -1017,12 +1046,15 @@ extern "C" {
 
     pub fn symlink(path1: *const c_char, path2: *const c_char) -> ::c_int;
 
+    #[cfg_attr(gnu_time64_abi, link_name = "truncate64")]
     pub fn truncate(path: *const c_char, length: off_t) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "ftruncate64")]
     pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int;
 
     pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t;
 
     #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")]
+    #[cfg_attr(gnu_time64_abi, link_name = "__getrusage64")]
     pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int;
 
     #[cfg_attr(
@@ -1099,6 +1131,7 @@ extern "C" {
         all(target_os = "macos", target_arch = "x86"),
         link_name = "pthread_cond_timedwait$UNIX2003"
     )]
+    #[cfg_attr(gnu_time64_abi, link_name = "__pthread_cond_timedwait64")]
     pub fn pthread_cond_timedwait(
         cond: *mut pthread_cond_t,
         lock: *mut pthread_mutex_t,
@@ -1155,6 +1188,7 @@ extern "C" {
         link_name = "__xnet_getsockopt"
     )]
     #[cfg_attr(target_os = "espidf", link_name = "lwip_getsockopt")]
+    #[cfg_attr(gnu_time64_abi, link_name = "__getsockopt64")]
     pub fn getsockopt(
         sockfd: ::c_int,
         level: ::c_int,
@@ -1165,6 +1199,7 @@ extern "C" {
     pub fn raise(signum: ::c_int) -> ::c_int;
 
     #[cfg_attr(target_os = "netbsd", link_name = "__utimes50")]
+    #[cfg_attr(gnu_time64_abi, link_name = "__utimes64")]
     pub fn utimes(filename: *const ::c_char, times: *const ::timeval) -> ::c_int;
     pub fn dlopen(filename: *const ::c_char, flag: ::c_int) -> *mut ::c_void;
     pub fn dlerror() -> *mut ::c_char;
@@ -1214,10 +1249,12 @@ extern "C" {
     #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")]
     #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))]
     // FIXME: for `time_t`
+    #[cfg_attr(gnu_time64_abi, link_name = "__gmtime64_r")]
     pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
     #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")]
     #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))]
     // FIXME: for `time_t`
+    #[cfg_attr(gnu_time64_abi, link_name = "__localtime64_r")]
     pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
     #[cfg_attr(
         all(target_os = "macos", target_arch = "x86"),
@@ -1226,26 +1263,32 @@ extern "C" {
     #[cfg_attr(target_os = "netbsd", link_name = "__mktime50")]
     #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))]
     // FIXME: for `time_t`
+    #[cfg_attr(gnu_time64_abi, link_name = "__mktime64")]
     pub fn mktime(tm: *mut tm) -> time_t;
     #[cfg_attr(target_os = "netbsd", link_name = "__time50")]
     #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))]
     // FIXME: for `time_t`
+    #[cfg_attr(gnu_time64_abi, link_name = "__time64")]
     pub fn time(time: *mut time_t) -> time_t;
     #[cfg_attr(target_os = "netbsd", link_name = "__gmtime50")]
     #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))]
     // FIXME: for `time_t`
+    #[cfg_attr(gnu_time64_abi, link_name = "__gmtime64")]
     pub fn gmtime(time_p: *const time_t) -> *mut tm;
     #[cfg_attr(target_os = "netbsd", link_name = "__locatime50")]
     #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))]
     // FIXME: for `time_t`
+    #[cfg_attr(gnu_time64_abi, link_name = "__localtime64")]
     pub fn localtime(time_p: *const time_t) -> *mut tm;
     #[cfg_attr(target_os = "netbsd", link_name = "__difftime50")]
     #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))]
     // FIXME: for `time_t`
+    #[cfg_attr(gnu_time64_abi, link_name = "__difftime64")]
     pub fn difftime(time1: time_t, time0: time_t) -> ::c_double;
     #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")]
     #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))]
     // FIXME: for `time_t`
+    #[cfg_attr(gnu_time64_abi, link_name = "__timegm64")]
     pub fn timegm(tm: *mut ::tm) -> time_t;
 
     #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")]
@@ -1300,6 +1343,7 @@ extern "C" {
         link_name = "select$UNIX2003"
     )]
     #[cfg_attr(target_os = "netbsd", link_name = "__select50")]
+    #[cfg_attr(gnu_time64_abi, link_name = "__select64")]
     pub fn select(
         nfds: ::c_int,
         readfds: *mut fd_set,
@@ -1318,7 +1362,9 @@ extern "C" {
     pub fn sem_wait(sem: *mut sem_t) -> ::c_int;
     pub fn sem_trywait(sem: *mut sem_t) -> ::c_int;
     pub fn sem_post(sem: *mut sem_t) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "statvfs64")]
     pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "fstatvfs64")]
     pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int;
 
     #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")]
@@ -1341,7 +1387,9 @@ extern "C" {
 
     pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int;
 
+    #[cfg_attr(gnu_time64_abi, link_name = "fseeko64")]
     pub fn fseeko(stream: *mut ::FILE, offset: ::off_t, whence: ::c_int) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "ftello64")]
     pub fn ftello(stream: *mut ::FILE) -> ::off_t;
     #[cfg_attr(
         all(target_os = "macos", target_arch = "x86"),
@@ -1358,6 +1406,7 @@ extern "C" {
     pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int;
     pub fn tcgetsid(fd: ::c_int) -> ::pid_t;
     pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int;
+    #[cfg_attr(gnu_time64_abi, link_name = "mkstemp64")]
     pub fn mkstemp(template: *mut ::c_char) -> ::c_int;
     pub fn mkdtemp(template: *mut ::c_char) -> *mut ::c_char;
 
@@ -1382,6 +1431,7 @@ extern "C" {
     pub fn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
     pub fn getline(lineptr: *mut *mut c_char, n: *mut size_t, stream: *mut FILE) -> ssize_t;
 
+    #[cfg_attr(gnu_time64_abi, link_name = "lockf64")]
     pub fn lockf(fd: ::c_int, cmd: ::c_int, len: ::off_t) -> ::c_int;
 
 }
@@ -1392,6 +1442,7 @@ cfg_if! {
                      target_os = "haiku",
                      target_os = "nto")))] {
         extern "C" {
+            #[cfg_attr(gnu_time64_abi, link_name = "__adjtime64")]
             pub fn adjtime(delta: *const timeval, olddelta: *mut timeval) -> ::c_int;
         }
     }
@@ -1436,6 +1487,7 @@ cfg_if! {
 
             pub fn mkdirat(dirfd: ::c_int, pathname: *const ::c_char,
                           mode: ::mode_t) -> ::c_int;
+            #[cfg_attr(gnu_time64_abi, link_name = "openat64")]
             pub fn openat(dirfd: ::c_int, pathname: *const ::c_char,
                           flags: ::c_int, ...) -> ::c_int;
 
@@ -1459,6 +1511,7 @@ cfg_if! {
             /// https://illumos.org/man/3lib/libc
             /// https://docs.oracle.com/cd/E36784_01/html/E36873/libc-3lib.html
             /// https://www.unix.com/man-page/opensolaris/3LIB/libc/
+            #[cfg_attr(gnu_time64_abi, link_name = "readdir64_r")]
             pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent,
                              result: *mut *mut ::dirent) -> ::c_int;
         }
@@ -1512,6 +1565,7 @@ cfg_if! {
                 link_name = "pselect$UNIX2003"
             )]
             #[cfg_attr(target_os = "netbsd", link_name = "__pselect50")]
+            #[cfg_attr(gnu_time64_abi, link_name = "__pselect64")]
             pub fn pselect(
                 nfds: ::c_int,
                 readfds: *mut fd_set,