From 5ceec001b5d0feb09f6f7c581b1bdc5d2436bfbe Mon Sep 17 00:00:00 2001 From: RadsammyT Date: Sat, 8 Aug 2026 23:04:03 -0400 Subject: [PATCH] std.os.linux: pad `CLOSE_RANGE` by one bit On include/uapi/linux/close_range.h of the linux src tree, The C equivalents for the CLOSE_RANGE members are defined like this: - /* Unshare the file descriptor table before closing file descriptors. */ #define CLOSE_RANGE_UNSHARE(1U << 1) /* Set the FD_CLOEXEC bit instead of closing the file descriptor. */ #define CLOSE_RANGE_CLOEXEC(1U << 2) - Originally, the zig fields of CLOSE_RANGE were offset by one bit-shift to the right. This adds one bit of padding which pushes the Zig members by one bit-shift to the left, making the Zig struct be aligned with the linux definitions. --- lib/std/os/linux.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 2df4fdf75d80e01ca25cb6bb6ea94664709a0a8c..458d3195ac2f0d383b92867373824ec016e1e6e7 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -1746,11 +1746,12 @@ pub fn close(fd: fd_t) usize { } pub const CLOSE_RANGE = packed struct(u32) { + _0: u1 = 0, /// Unshare the file descriptor table before closing file descriptors. UNSHARE: bool, // 0x00000001 /// Set the FD_CLOEXEC bit instead of closing the file descriptor. CLOEXEC: bool, // 0x00000002 - _: u30 = 0, + _: u29 = 0, }; pub fn close_range(first: fd_t, last: fd_t, flags: CLOSE_RANGE) usize { -- 2.54.0