authorgravatar for hahv@msn.comHuang Zhichao <hahv@msn.com> 2026-05-29 13:15:21+08:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-05-31 07:29:58+02:00
log0618743543464e0b5862255ebb89f265bd29c8b9
treef3bb7e93656e81daef510e15911d97e51e63727f
parent532047edd01ebedf6fae4d63ad25713f81d8fae4

std.os.linux: make dev_t u32

glibc and musl define dev_t as u64, but in the kernel it is u32. see https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/types.h?id=v7.0#n17

2 files changed, 3 insertions(+), 3 deletions(-)

lib/std/c.zig+2-2
...@@ -148,12 +148,12 @@ pub const timespec = switch (native_os) {...@@ -148,12 +148,12 @@ pub const timespec = switch (native_os) {
148};148};
149149
150pub const dev_t = switch (native_os) {150pub const dev_t = switch (native_os) {
151 .linux => linux.dev_t,
152 .emscripten => emscripten.dev_t,151 .emscripten => emscripten.dev_t,
153 .wasi => wasi.device_t,152 .wasi => wasi.device_t,
154 .openbsd, .haiku, .illumos, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => i32,153 .openbsd, .haiku, .illumos, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => i32,
154 // glibc and musl define dev_t as u64, while in Linux kernel it is u32.
155 // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L43155 // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L43
156 .netbsd, .freebsd, .serenity => u64,156 .linux, .netbsd, .freebsd, .serenity => u64,
157 else => void,157 else => void,
158};158};
159159
lib/std/os/linux.zig+1-1
...@@ -106,7 +106,7 @@ pub const user_desc = arch_bits.user_desc;...@@ -106,7 +106,7 @@ pub const user_desc = arch_bits.user_desc;
106106
107pub const blkcnt_t = u64;107pub const blkcnt_t = u64;
108pub const blksize_t = u32;108pub const blksize_t = u32;
109pub const dev_t = u64;109pub const dev_t = u32;
110pub const ino_t = u64;110pub const ino_t = u64;
111pub const mode_t = u32;111pub const mode_t = u32;
112pub const nlink_t = u32;112pub const nlink_t = u32;