Commit aa8e53908a

Alex Rønne Petersen <alex@alexrp.com>
2025-10-17 01:01:27
std.os.linux: clean up a bunch of dead consts
1 parent dc1bc52
lib/std/os/linux/aarch64.zig
@@ -1,18 +1,6 @@
 const builtin = @import("builtin");
 const std = @import("../../std.zig");
-const maxInt = std.math.maxInt;
-const linux = std.os.linux;
-const SYS = linux.SYS;
-const socklen_t = linux.socklen_t;
-const sockaddr = linux.sockaddr;
-const iovec = std.posix.iovec;
-const iovec_const = std.posix.iovec_const;
-const uid_t = linux.uid_t;
-const gid_t = linux.gid_t;
-const pid_t = linux.pid_t;
-const stack_t = linux.stack_t;
-const sigset_t = linux.sigset_t;
-const timespec = std.os.linux.timespec;
+const SYS = std.os.linux.SYS;
 
 pub fn syscall0(number: SYS) u64 {
     return asm volatile ("svc #0"
@@ -135,7 +123,7 @@ pub fn clone() callconv(.naked) u64 {
 pub const restore = restore_rt;
 
 pub fn restore_rt() callconv(.naked) noreturn {
-    switch (@import("builtin").zig_backend) {
+    switch (builtin.zig_backend) {
         .stage2_c => asm volatile (
             \\ mov x8, %[number]
             \\ svc #0
@@ -170,28 +158,28 @@ pub const Stat = extern struct {
     ino: ino_t,
     mode: mode_t,
     nlink: nlink_t,
-    uid: uid_t,
-    gid: gid_t,
+    uid: std.os.linux.uid_t,
+    gid: std.os.linux.gid_t,
     rdev: dev_t,
     __pad: u64,
     size: off_t,
     blksize: blksize_t,
     __pad2: i32,
     blocks: blkcnt_t,
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
+    atim: std.os.linux.timespec,
+    mtim: std.os.linux.timespec,
+    ctim: std.os.linux.timespec,
     __unused: [2]u32,
 
-    pub fn atime(self: @This()) timespec {
+    pub fn atime(self: @This()) std.os.linux.timespec {
         return self.atim;
     }
 
-    pub fn mtime(self: @This()) timespec {
+    pub fn mtime(self: @This()) std.os.linux.timespec {
         return self.mtim;
     }
 
-    pub fn ctime(self: @This()) timespec {
+    pub fn ctime(self: @This()) std.os.linux.timespec {
         return self.ctim;
     }
 };
lib/std/os/linux/arm.zig
@@ -1,17 +1,6 @@
+const builtin = @import("builtin");
 const std = @import("../../std.zig");
-const maxInt = std.math.maxInt;
-const linux = std.os.linux;
-const SYS = linux.SYS;
-const iovec = std.posix.iovec;
-const iovec_const = std.posix.iovec_const;
-const socklen_t = linux.socklen_t;
-const stack_t = linux.stack_t;
-const sigset_t = linux.sigset_t;
-const uid_t = linux.uid_t;
-const gid_t = linux.gid_t;
-const pid_t = linux.pid_t;
-const sockaddr = linux.sockaddr;
-const timespec = linux.timespec;
+const SYS = std.os.linux.SYS;
 
 pub fn syscall0(number: SYS) u32 {
     return asm volatile ("svc #0"
@@ -128,7 +117,7 @@ pub fn clone() callconv(.naked) u32 {
 }
 
 pub fn restore() callconv(.naked) noreturn {
-    switch (@import("builtin").zig_backend) {
+    switch (builtin.zig_backend) {
         .stage2_c => asm volatile (
             \\ mov r7, %[number]
             \\ svc #0
@@ -144,7 +133,7 @@ pub fn restore() callconv(.naked) noreturn {
 }
 
 pub fn restore_rt() callconv(.naked) noreturn {
-    switch (@import("builtin").zig_backend) {
+    switch (builtin.zig_backend) {
         .stage2_c => asm volatile (
             \\ mov r7, %[number]
             \\ svc #0
@@ -206,27 +195,27 @@ pub const Stat = extern struct {
     __ino_truncated: u32,
     mode: mode_t,
     nlink: nlink_t,
-    uid: uid_t,
-    gid: gid_t,
+    uid: std.os.linux.uid_t,
+    gid: std.os.linux.gid_t,
     rdev: dev_t,
     __rdev_padding: u32,
     size: off_t,
     blksize: blksize_t,
     blocks: blkcnt_t,
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
+    atim: std.os.linux.timespec,
+    mtim: std.os.linux.timespec,
+    ctim: std.os.linux.timespec,
     ino: ino_t,
 
-    pub fn atime(self: @This()) timespec {
+    pub fn atime(self: @This()) std.os.linux.timespec {
         return self.atim;
     }
 
-    pub fn mtime(self: @This()) timespec {
+    pub fn mtime(self: @This()) std.os.linux.timespec {
         return self.mtim;
     }
 
-    pub fn ctime(self: @This()) timespec {
+    pub fn ctime(self: @This()) std.os.linux.timespec {
         return self.ctim;
     }
 };
lib/std/os/linux/hexagon.zig
@@ -1,17 +1,6 @@
 const builtin = @import("builtin");
 const std = @import("../../std.zig");
-const iovec = std.posix.iovec;
-const iovec_const = std.posix.iovec_const;
-const linux = std.os.linux;
-const SYS = linux.SYS;
-const uid_t = std.os.linux.uid_t;
-const gid_t = std.os.linux.gid_t;
-const pid_t = std.os.linux.pid_t;
-const sockaddr = linux.sockaddr;
-const socklen_t = linux.socklen_t;
-const stack_t = linux.stack_t;
-const sigset_t = linux.sigset_t;
-const timespec = std.os.linux.timespec;
+const SYS = std.os.linux.SYS;
 
 pub fn syscall0(number: SYS) u32 {
     return asm volatile ("trap0(#1)"
@@ -145,28 +134,28 @@ pub const Stat = extern struct {
     ino: ino_t,
     mode: mode_t,
     nlink: nlink_t,
-    uid: uid_t,
-    gid: gid_t,
+    uid: std.os.linux.uid_t,
+    gid: std.os.linux.gid_t,
     rdev: dev_t,
     __pad: u32,
     size: off_t,
     blksize: blksize_t,
     __pad2: i32,
     blocks: blkcnt_t,
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
+    atim: std.os.linux.timespec,
+    mtim: std.os.linux.timespec,
+    ctim: std.os.linux.timespec,
     __unused: [2]u32,
 
-    pub fn atime(self: @This()) timespec {
+    pub fn atime(self: @This()) std.os.linux.timespec {
         return self.atim;
     }
 
-    pub fn mtime(self: @This()) timespec {
+    pub fn mtime(self: @This()) std.os.linux.timespec {
         return self.mtim;
     }
 
-    pub fn ctime(self: @This()) timespec {
+    pub fn ctime(self: @This()) std.os.linux.timespec {
         return self.ctim;
     }
 };
lib/std/os/linux/loongarch64.zig
@@ -1,16 +1,6 @@
 const builtin = @import("builtin");
 const std = @import("../../std.zig");
-const linux = std.os.linux;
-const SYS = linux.SYS;
-const iovec = std.posix.iovec;
-const iovec_const = std.posix.iovec_const;
-const uid_t = linux.uid_t;
-const gid_t = linux.gid_t;
-const stack_t = linux.stack_t;
-const sigset_t = linux.sigset_t;
-const sockaddr = linux.sockaddr;
-const socklen_t = linux.socklen_t;
-const timespec = linux.timespec;
+const SYS = std.os.linux.SYS;
 
 pub fn syscall0(number: SYS) u64 {
     return asm volatile (
@@ -150,28 +140,28 @@ pub const Stat = extern struct {
     ino: ino_t,
     mode: mode_t,
     nlink: nlink_t,
-    uid: uid_t,
-    gid: gid_t,
+    uid: std.os.linux.uid_t,
+    gid: std.os.linux.gid_t,
     rdev: dev_t,
     _pad1: u64,
     size: off_t,
     blksize: blksize_t,
     _pad2: i32,
     blocks: blkcnt_t,
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
+    atim: std.os.linux.timespec,
+    mtim: std.os.linux.timespec,
+    ctim: std.os.linux.timespec,
     _pad3: [2]u32,
 
-    pub fn atime(self: @This()) timespec {
+    pub fn atime(self: @This()) std.os.linux.timespec {
         return self.atim;
     }
 
-    pub fn mtime(self: @This()) timespec {
+    pub fn mtime(self: @This()) std.os.linux.timespec {
         return self.mtim;
     }
 
-    pub fn ctime(self: @This()) timespec {
+    pub fn ctime(self: @This()) std.os.linux.timespec {
         return self.ctim;
     }
 };
lib/std/os/linux/m68k.zig
@@ -1,15 +1,6 @@
 const builtin = @import("builtin");
 const std = @import("../../std.zig");
-const iovec = std.posix.iovec;
-const iovec_const = std.posix.iovec_const;
-const linux = std.os.linux;
-const SYS = linux.SYS;
-const uid_t = std.os.linux.uid_t;
-const gid_t = std.os.linux.uid_t;
-const pid_t = std.os.linux.pid_t;
-const sockaddr = linux.sockaddr;
-const socklen_t = linux.socklen_t;
-const timespec = std.os.linux.timespec;
+const SYS = std.os.linux.SYS;
 
 pub fn syscall0(number: SYS) u32 {
     return asm volatile ("trap #0"
@@ -166,27 +157,27 @@ pub const Stat = extern struct {
     __ino_truncated: i32,
     mode: mode_t,
     nlink: nlink_t,
-    uid: uid_t,
-    gid: gid_t,
+    uid: std.os.linux.uid_t,
+    gid: std.os.linux.gid_t,
     rdev: dev_t,
     __pad2: i16,
     size: off_t,
     blksize: blksize_t,
     blocks: blkcnt_t,
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
+    atim: std.os.linux.timespec,
+    mtim: std.os.linux.timespec,
+    ctim: std.os.linux.timespec,
     ino: ino_t,
 
-    pub fn atime(self: @This()) timespec {
+    pub fn atime(self: @This()) std.os.linux.timespec {
         return self.atim;
     }
 
-    pub fn mtime(self: @This()) timespec {
+    pub fn mtime(self: @This()) std.os.linux.timespec {
         return self.mtim;
     }
 
-    pub fn ctime(self: @This()) timespec {
+    pub fn ctime(self: @This()) std.os.linux.timespec {
         return self.ctim;
     }
 };
lib/std/os/linux/mips.zig
@@ -1,18 +1,6 @@
 const builtin = @import("builtin");
 const std = @import("../../std.zig");
-const maxInt = std.math.maxInt;
-const linux = std.os.linux;
-const SYS = linux.SYS;
-const socklen_t = linux.socklen_t;
-const iovec = std.posix.iovec;
-const iovec_const = std.posix.iovec_const;
-const uid_t = linux.uid_t;
-const gid_t = linux.gid_t;
-const pid_t = linux.pid_t;
-const stack_t = linux.stack_t;
-const sigset_t = linux.sigset_t;
-const sockaddr = linux.sockaddr;
-const timespec = linux.timespec;
+const SYS = std.os.linux.SYS;
 
 pub fn syscall0(number: SYS) u32 {
     return asm volatile (
@@ -264,39 +252,27 @@ pub const Stat = extern struct {
     ino: ino_t,
     mode: mode_t,
     nlink: nlink_t,
-    uid: uid_t,
-    gid: gid_t,
+    uid: std.os.linux.uid_t,
+    gid: std.os.linux.gid_t,
     rdev: dev_t,
     __pad1: [2]u32,
     size: off_t,
-    atim: i32,
-    atim_nsec: i32,
-    mtim: i32,
-    mtim_nsec: i32,
-    ctim: i32,
-    ctim_nsec: i32,
+    atim: std.os.linux.timespec,
+    mtim: std.os.linux.timespec,
+    ctim: std.os.linux.timespec,
     blksize: blksize_t,
     __pad3: u32,
     blocks: blkcnt_t,
 
-    pub fn atime(self: @This()) timespec {
-        return .{
-            .sec = self.atim,
-            .nsec = self.atim_nsec,
-        };
+    pub fn atime(self: @This()) std.os.linux.timespec {
+        return self.atim;
     }
 
-    pub fn mtime(self: @This()) timespec {
-        return .{
-            .sec = self.mtim,
-            .nsec = self.mtim_nsec,
-        };
+    pub fn mtime(self: @This()) std.os.linux.timespec {
+        return self.mtim;
     }
 
-    pub fn ctime(self: @This()) timespec {
-        return .{
-            .sec = self.ctim,
-            .nsec = self.ctim_nsec,
-        };
+    pub fn ctime(self: @This()) std.os.linux.timespec {
+        return self.ctim;
     }
 };
lib/std/os/linux/mips64.zig
@@ -1,18 +1,6 @@
 const builtin = @import("builtin");
 const std = @import("../../std.zig");
-const maxInt = std.math.maxInt;
-const linux = std.os.linux;
-const SYS = linux.SYS;
-const socklen_t = linux.socklen_t;
-const iovec = std.posix.iovec;
-const iovec_const = std.posix.iovec_const;
-const uid_t = linux.uid_t;
-const gid_t = linux.gid_t;
-const pid_t = linux.pid_t;
-const stack_t = linux.stack_t;
-const sigset_t = linux.sigset_t;
-const sockaddr = linux.sockaddr;
-const timespec = linux.timespec;
+const SYS = std.os.linux.SYS;
 
 pub fn syscall0(number: SYS) u64 {
     return asm volatile (
@@ -243,8 +231,8 @@ pub const Stat = extern struct {
     ino: ino_t,
     mode: mode_t,
     nlink: nlink_t,
-    uid: uid_t,
-    gid: gid_t,
+    uid: std.os.linux.uid_t,
+    gid: std.os.linux.gid_t,
     rdev: dev_t,
     __pad1: [2]u32, // -1 because our dev_t is u64 (kernel dev_t is really u32).
     size: off_t,
@@ -258,21 +246,21 @@ pub const Stat = extern struct {
     __pad3: u32,
     blocks: blkcnt_t,
 
-    pub fn atime(self: @This()) timespec {
+    pub fn atime(self: @This()) std.os.linux.timespec {
         return .{
             .sec = self.atim,
             .nsec = self.atim_nsec,
         };
     }
 
-    pub fn mtime(self: @This()) timespec {
+    pub fn mtime(self: @This()) std.os.linux.timespec {
         return .{
             .sec = self.mtim,
             .nsec = self.mtim_nsec,
         };
     }
 
-    pub fn ctime(self: @This()) timespec {
+    pub fn ctime(self: @This()) std.os.linux.timespec {
         return .{
             .sec = self.ctim,
             .nsec = self.ctim_nsec,
lib/std/os/linux/powerpc.zig
@@ -1,18 +1,6 @@
 const builtin = @import("builtin");
 const std = @import("../../std.zig");
-const maxInt = std.math.maxInt;
-const linux = std.os.linux;
-const SYS = linux.SYS;
-const socklen_t = linux.socklen_t;
-const iovec = std.posix.iovec;
-const iovec_const = std.posix.iovec_const;
-const uid_t = linux.uid_t;
-const gid_t = linux.gid_t;
-const pid_t = linux.pid_t;
-const stack_t = linux.stack_t;
-const sigset_t = linux.sigset_t;
-const sockaddr = linux.sockaddr;
-const timespec = linux.timespec;
+const SYS = std.os.linux.SYS;
 
 pub fn syscall0(number: SYS) u32 {
     // r0 is both an input register and a clobber. musl and glibc achieve this with
@@ -247,7 +235,7 @@ pub fn clone() callconv(.naked) u32 {
 pub const restore = restore_rt;
 
 pub fn restore_rt() callconv(.naked) noreturn {
-    switch (@import("builtin").zig_backend) {
+    switch (builtin.zig_backend) {
         .stage2_c => asm volatile (
             \\ li 0, %[number]
             \\ sc
@@ -282,27 +270,27 @@ pub const Stat = extern struct {
     ino: ino_t,
     mode: mode_t,
     nlink: nlink_t,
-    uid: uid_t,
-    gid: gid_t,
+    uid: std.os.linux.uid_t,
+    gid: std.os.linux.gid_t,
     rdev: dev_t,
     __rdev_padding: i16,
     size: off_t,
     blksize: blksize_t,
     blocks: blkcnt_t,
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
+    atim: std.os.linux.timespec,
+    mtim: std.os.linux.timespec,
+    ctim: std.os.linux.timespec,
     __unused: [2]u32,
 
-    pub fn atime(self: @This()) timespec {
+    pub fn atime(self: @This()) std.os.linux.timespec {
         return self.atim;
     }
 
-    pub fn mtime(self: @This()) timespec {
+    pub fn mtime(self: @This()) std.os.linux.timespec {
         return self.mtim;
     }
 
-    pub fn ctime(self: @This()) timespec {
+    pub fn ctime(self: @This()) std.os.linux.timespec {
         return self.ctim;
     }
 };
lib/std/os/linux/powerpc64.zig
@@ -1,18 +1,6 @@
 const builtin = @import("builtin");
 const std = @import("../../std.zig");
-const maxInt = std.math.maxInt;
-const linux = std.os.linux;
-const SYS = linux.SYS;
-const socklen_t = linux.socklen_t;
-const iovec = std.posix.iovec;
-const iovec_const = std.posix.iovec_const;
-const uid_t = linux.uid_t;
-const gid_t = linux.gid_t;
-const pid_t = linux.pid_t;
-const stack_t = linux.stack_t;
-const sigset_t = linux.sigset_t;
-const sockaddr = linux.sockaddr;
-const timespec = linux.timespec;
+const SYS = std.os.linux.SYS;
 
 pub fn syscall0(number: SYS) u64 {
     // r0 is both an input register and a clobber. musl and glibc achieve this with
@@ -232,7 +220,7 @@ pub fn clone() callconv(.naked) u64 {
 pub const restore = restore_rt;
 
 pub fn restore_rt() callconv(.naked) noreturn {
-    switch (@import("builtin").zig_backend) {
+    switch (builtin.zig_backend) {
         .stage2_c => asm volatile (
             \\ li 0, %[number]
             \\ sc
@@ -267,26 +255,26 @@ pub const Stat = extern struct {
     ino: ino_t,
     nlink: nlink_t,
     mode: mode_t,
-    uid: uid_t,
-    gid: gid_t,
+    uid: std.os.linux.uid_t,
+    gid: std.os.linux.gid_t,
     rdev: dev_t,
     size: off_t,
     blksize: blksize_t,
     blocks: blkcnt_t,
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
+    atim: std.os.linux.timespec,
+    mtim: std.os.linux.timespec,
+    ctim: std.os.linux.timespec,
     __unused: [3]u64,
 
-    pub fn atime(self: @This()) timespec {
+    pub fn atime(self: @This()) std.os.linux.timespec {
         return self.atim;
     }
 
-    pub fn mtime(self: @This()) timespec {
+    pub fn mtime(self: @This()) std.os.linux.timespec {
         return self.mtim;
     }
 
-    pub fn ctime(self: @This()) timespec {
+    pub fn ctime(self: @This()) std.os.linux.timespec {
         return self.ctim;
     }
 };
lib/std/os/linux/riscv32.zig
@@ -1,17 +1,6 @@
 const builtin = @import("builtin");
 const std = @import("../../std.zig");
-const iovec = std.posix.iovec;
-const iovec_const = std.posix.iovec_const;
-const linux = std.os.linux;
-const SYS = linux.SYS;
-const uid_t = std.os.linux.uid_t;
-const gid_t = std.os.linux.gid_t;
-const pid_t = std.os.linux.pid_t;
-const stack_t = linux.stack_t;
-const sigset_t = linux.sigset_t;
-const sockaddr = linux.sockaddr;
-const socklen_t = linux.socklen_t;
-const timespec = std.os.linux.timespec;
+const SYS = std.os.linux.SYS;
 
 pub fn syscall0(number: SYS) u32 {
     return asm volatile ("ecall"
@@ -150,28 +139,28 @@ pub const Stat = extern struct {
     ino: ino_t,
     mode: mode_t,
     nlink: nlink_t,
-    uid: uid_t,
-    gid: gid_t,
+    uid: std.os.linux.uid_t,
+    gid: std.os.linux.gid_t,
     rdev: dev_t,
     __pad: u32,
     size: off_t,
     blksize: blksize_t,
     __pad2: i32,
     blocks: blkcnt_t,
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
+    atim: std.os.linux.timespec,
+    mtim: std.os.linux.timespec,
+    ctim: std.os.linux.timespec,
     __unused: [2]u32,
 
-    pub fn atime(self: @This()) timespec {
+    pub fn atime(self: @This()) std.os.linux.timespec {
         return self.atim;
     }
 
-    pub fn mtime(self: @This()) timespec {
+    pub fn mtime(self: @This()) std.os.linux.timespec {
         return self.mtim;
     }
 
-    pub fn ctime(self: @This()) timespec {
+    pub fn ctime(self: @This()) std.os.linux.timespec {
         return self.ctim;
     }
 };
lib/std/os/linux/riscv64.zig
@@ -1,17 +1,6 @@
 const builtin = @import("builtin");
 const std = @import("../../std.zig");
-const iovec = std.posix.iovec;
-const iovec_const = std.posix.iovec_const;
-const linux = std.os.linux;
-const SYS = linux.SYS;
-const uid_t = std.os.linux.uid_t;
-const gid_t = std.os.linux.gid_t;
-const pid_t = std.os.linux.pid_t;
-const stack_t = linux.stack_t;
-const sigset_t = linux.sigset_t;
-const sockaddr = linux.sockaddr;
-const socklen_t = linux.socklen_t;
-const timespec = std.os.linux.timespec;
+const SYS = std.os.linux.SYS;
 
 pub fn syscall0(number: SYS) u64 {
     return asm volatile ("ecall"
@@ -150,28 +139,28 @@ pub const Stat = extern struct {
     ino: ino_t,
     mode: mode_t,
     nlink: nlink_t,
-    uid: uid_t,
-    gid: gid_t,
+    uid: std.os.linux.uid_t,
+    gid: std.os.linux.gid_t,
     rdev: dev_t,
     __pad: u64,
     size: off_t,
     blksize: blksize_t,
     __pad2: i32,
     blocks: blkcnt_t,
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
+    atim: std.os.linux.timespec,
+    mtim: std.os.linux.timespec,
+    ctim: std.os.linux.timespec,
     __unused: [2]u32,
 
-    pub fn atime(self: @This()) timespec {
+    pub fn atime(self: @This()) std.os.linux.timespec {
         return self.atim;
     }
 
-    pub fn mtime(self: @This()) timespec {
+    pub fn mtime(self: @This()) std.os.linux.timespec {
         return self.mtim;
     }
 
-    pub fn ctime(self: @This()) timespec {
+    pub fn ctime(self: @This()) std.os.linux.timespec {
         return self.ctim;
     }
 };
lib/std/os/linux/s390x.zig
@@ -1,17 +1,6 @@
 const builtin = @import("builtin");
 const std = @import("../../std.zig");
-const iovec = std.posix.iovec;
-const iovec_const = std.posix.iovec_const;
-const linux = std.os.linux;
-const SYS = linux.SYS;
-const uid_t = std.os.linux.uid_t;
-const gid_t = std.os.linux.gid_t;
-const pid_t = std.os.linux.pid_t;
-const sockaddr = linux.sockaddr;
-const socklen_t = linux.socklen_t;
-const timespec = std.os.linux.timespec;
-const stack_t = std.os.linux.stack_t;
-const sigset_t = std.os.linux.sigset_t;
+const SYS = std.os.linux.SYS;
 
 pub fn syscall0(number: SYS) u64 {
     return asm volatile ("svc 0"
@@ -172,26 +161,26 @@ pub const Stat = extern struct {
     ino: ino_t,
     nlink: nlink_t,
     mode: mode_t,
-    uid: uid_t,
-    gid: gid_t,
+    uid: std.os.linux.uid_t,
+    gid: std.os.linux.gid_t,
     rdev: dev_t,
     size: off_t,
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
+    atim: std.os.linux.timespec,
+    mtim: std.os.linux.timespec,
+    ctim: std.os.linux.timespec,
     blksize: blksize_t,
     blocks: blkcnt_t,
     __unused: [3]c_ulong,
 
-    pub fn atime(self: @This()) timespec {
+    pub fn atime(self: @This()) std.os.linux.timespec {
         return self.atim;
     }
 
-    pub fn mtime(self: @This()) timespec {
+    pub fn mtime(self: @This()) std.os.linux.timespec {
         return self.mtim;
     }
 
-    pub fn ctime(self: @This()) timespec {
+    pub fn ctime(self: @This()) std.os.linux.timespec {
         return self.ctim;
     }
 };
lib/std/os/linux/sparc64.zig
@@ -1,19 +1,6 @@
 const builtin = @import("builtin");
 const std = @import("../../std.zig");
-const maxInt = std.math.maxInt;
-const pid_t = linux.pid_t;
-const uid_t = linux.uid_t;
-const clock_t = linux.clock_t;
-const stack_t = linux.stack_t;
-const sigset_t = linux.sigset_t;
-
-const linux = std.os.linux;
-const SYS = linux.SYS;
-const sockaddr = linux.sockaddr;
-const socklen_t = linux.socklen_t;
-const iovec = std.posix.iovec;
-const iovec_const = std.posix.iovec_const;
-const timespec = linux.timespec;
+const SYS = std.os.linux.SYS;
 
 pub fn syscall_pipe(fd: *[2]i32) u64 {
     return asm volatile (
@@ -252,34 +239,35 @@ pub const blkcnt_t = i64;
 
 // The `stat64` definition used by the kernel.
 pub const Stat = extern struct {
-    dev: u64,
-    ino: u64,
-    nlink: u64,
+    dev: dev_t,
+    ino: ino_t,
+    nlink: nlink_t,
+    _pad: i32,
 
-    mode: u32,
-    uid: u32,
-    gid: u32,
+    mode: mode_t,
+    uid: std.os.linux.uid_t,
+    gid: std.os.linux.gid_t,
     __pad0: u32,
 
-    rdev: u64,
+    rdev: dev_t,
     size: i64,
-    blksize: i64,
-    blocks: i64,
+    blksize: blksize_t,
+    blocks: blkcnt_t,
 
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
+    atim: std.os.linux.timespec,
+    mtim: std.os.linux.timespec,
+    ctim: std.os.linux.timespec,
     __unused: [3]u64,
 
-    pub fn atime(self: @This()) timespec {
+    pub fn atime(self: @This()) std.os.linux.timespec {
         return self.atim;
     }
 
-    pub fn mtime(self: @This()) timespec {
+    pub fn mtime(self: @This()) std.os.linux.timespec {
         return self.mtim;
     }
 
-    pub fn ctime(self: @This()) timespec {
+    pub fn ctime(self: @This()) std.os.linux.timespec {
         return self.ctim;
     }
 };
lib/std/os/linux/thumb.zig
@@ -4,8 +4,7 @@
 //! Save and restore r7 around the syscall without touching the stack pointer not
 //! to break the frame chain.
 const std = @import("../../std.zig");
-const linux = std.os.linux;
-const SYS = linux.SYS;
+const SYS = std.os.linux.SYS;
 
 pub fn syscall0(number: SYS) u32 {
     var buf: [2]u32 = .{ @intFromEnum(number), undefined };
lib/std/os/linux/x86.zig
@@ -1,18 +1,6 @@
 const builtin = @import("builtin");
 const std = @import("../../std.zig");
-const maxInt = std.math.maxInt;
-const linux = std.os.linux;
-const SYS = linux.SYS;
-const socklen_t = linux.socklen_t;
-const iovec = std.posix.iovec;
-const iovec_const = std.posix.iovec_const;
-const uid_t = linux.uid_t;
-const gid_t = linux.gid_t;
-const pid_t = linux.pid_t;
-const stack_t = linux.stack_t;
-const sigset_t = linux.sigset_t;
-const sockaddr = linux.sockaddr;
-const timespec = linux.timespec;
+const SYS = std.os.linux.SYS;
 
 pub fn syscall0(number: SYS) u32 {
     return asm volatile ("int $0x80"
@@ -169,7 +157,7 @@ pub fn clone() callconv(.naked) u32 {
 }
 
 pub fn restore() callconv(.naked) noreturn {
-    switch (@import("builtin").zig_backend) {
+    switch (builtin.zig_backend) {
         .stage2_c => asm volatile (
             \\ movl %[number], %%eax
             \\ int $0x80
@@ -185,7 +173,7 @@ pub fn restore() callconv(.naked) noreturn {
 }
 
 pub fn restore_rt() callconv(.naked) noreturn {
-    switch (@import("builtin").zig_backend) {
+    switch (builtin.zig_backend) {
         .stage2_c => asm volatile (
             \\ movl %[number], %%eax
             \\ int $0x80
@@ -221,27 +209,27 @@ pub const Stat = extern struct {
     __ino_truncated: u32,
     mode: mode_t,
     nlink: nlink_t,
-    uid: uid_t,
-    gid: gid_t,
+    uid: std.os.linux.uid_t,
+    gid: std.os.linux.gid_t,
     rdev: dev_t,
     __rdev_padding: u32,
     size: off_t,
     blksize: blksize_t,
     blocks: blkcnt_t,
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
+    atim: std.os.linux.timespec,
+    mtim: std.os.linux.timespec,
+    ctim: std.os.linux.timespec,
     ino: ino_t,
 
-    pub fn atime(self: @This()) timespec {
+    pub fn atime(self: @This()) std.os.linux.timespec {
         return self.atim;
     }
 
-    pub fn mtime(self: @This()) timespec {
+    pub fn mtime(self: @This()) std.os.linux.timespec {
         return self.mtim;
     }
 
-    pub fn ctime(self: @This()) timespec {
+    pub fn ctime(self: @This()) std.os.linux.timespec {
         return self.ctim;
     }
 };
lib/std/os/linux/x86_64.zig
@@ -1,20 +1,6 @@
 const builtin = @import("builtin");
 const std = @import("../../std.zig");
-const maxInt = std.math.maxInt;
-const linux = std.os.linux;
-const SYS = linux.SYS;
-const iovec = std.posix.iovec;
-const iovec_const = std.posix.iovec_const;
-
-const pid_t = linux.pid_t;
-const uid_t = linux.uid_t;
-const gid_t = linux.gid_t;
-const clock_t = linux.clock_t;
-const stack_t = linux.stack_t;
-const sigset_t = linux.sigset_t;
-const sockaddr = linux.sockaddr;
-const socklen_t = linux.socklen_t;
-const timespec = linux.timespec;
+const SYS = std.os.linux.SYS;
 
 pub fn syscall0(number: SYS) u64 {
     return asm volatile ("syscall"
@@ -131,7 +117,7 @@ pub fn clone() callconv(.naked) u64 {
 pub const restore = restore_rt;
 
 pub fn restore_rt() callconv(.naked) noreturn {
-    switch (@import("builtin").zig_backend) {
+    switch (builtin.zig_backend) {
         .stage2_c => asm volatile (
             \\ movl %[number], %%eax
             \\ syscall
@@ -177,28 +163,28 @@ pub const Stat = extern struct {
     nlink: u64,
 
     mode: u32,
-    uid: uid_t,
-    gid: gid_t,
+    uid: std.os.linux.uid_t,
+    gid: std.os.linux.gid_t,
     __pad0: u32,
     rdev: dev_t,
     size: off_t,
     blksize: i64,
     blocks: i64,
 
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
+    atim: std.os.linux.timespec,
+    mtim: std.os.linux.timespec,
+    ctim: std.os.linux.timespec,
     __unused: [3]i64,
 
-    pub fn atime(self: @This()) timespec {
+    pub fn atime(self: @This()) std.os.linux.timespec {
         return self.atim;
     }
 
-    pub fn mtime(self: @This()) timespec {
+    pub fn mtime(self: @This()) std.os.linux.timespec {
         return self.mtim;
     }
 
-    pub fn ctime(self: @This()) timespec {
+    pub fn ctime(self: @This()) std.os.linux.timespec {
         return self.ctim;
     }
 };