authorgravatar for radsammyt@gmail.comRadsammyT <radsammyt@gmail.com> 2026-08-08 23:04:03-04:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-10 07:55:15+02:00
log5ceec001b5d0feb09f6f7c581b1bdc5d2436bfbe
tree72762b2d08f4469c7b7ee412e7a0673d1c197fb3
parentf74dac70b022fb9cbba25865fc9b14021f45b880

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.

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

lib/std/os/linux.zig+2-1
......@@ -1746,11 +1746,12 @@ pub fn close(fd: fd_t) usize {
17461746}
17471747
17481748pub const CLOSE_RANGE = packed struct(u32) {
1749 _0: u1 = 0,
17491750 /// Unshare the file descriptor table before closing file descriptors.
17501751 UNSHARE: bool, // 0x00000001
17511752 /// Set the FD_CLOEXEC bit instead of closing the file descriptor.
17521753 CLOEXEC: bool, // 0x00000002
1753 _: u30 = 0,
1754 _: u29 = 0,
17541755};
17551756
17561757pub fn close_range(first: fd_t, last: fd_t, flags: CLOSE_RANGE) usize {