authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-04 22:02:56-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-05 20:28:58-08:00
logf9a5b34e67ab12a46110568f75a99cb3aa6628c4
treea69caa06324fd856ad18a44d85433fa3777db09c
parent3859250c4d83d1611d256976e0845b16396a2e5c

std.Io.Threaded: fix compilation on s390x, hexagon, or1k, m68k

Apparently the O_TMPFILE flag is split across two bits on these architectures and missing on m68k.

2 files changed, 15 insertions(+), 9 deletions(-)

lib/std/Io/Threaded.zig+11-6
......@@ -3430,6 +3430,17 @@ fn dirCreateFileAtomic(
34303430 // useless when we have to make up a bogus path name to do the rename()
34313431 // anyway.
34323432 if (native_os == .linux and !options.replace) tmpfile: {
3433 const flags: posix.O = if (@hasField(posix.O, "TMPFILE")) .{
3434 .ACCMODE = .RDWR,
3435 .TMPFILE = true,
3436 .CLOEXEC = true,
3437 } else if (@hasField(posix.O, "TMPFILE0") and !@hasField(posix.O, "TMPFILE2")) .{
3438 .ACCMODE = .RDWR,
3439 .TMPFILE0 = true,
3440 .TMPFILE1 = true,
3441 .CLOEXEC = true,
3442 } else break :tmpfile;
3443
34333444 const dest_dirname = Dir.path.dirname(dest_path);
34343445 if (dest_dirname) |dirname| {
34353446 // This has a nice side effect of preemptively triggering EISDIR or
......@@ -3456,12 +3467,6 @@ fn dirCreateFileAtomic(
34563467 var path_buffer: [posix.PATH_MAX]u8 = undefined;
34573468 const sub_path_posix = try pathToPosix(dest_dirname orelse ".", &path_buffer);
34583469
3459 const flags: posix.O = .{
3460 .ACCMODE = .RDWR,
3461 .TMPFILE = true,
3462 .CLOEXEC = true,
3463 };
3464
34653470 const syscall: Syscall = try .start();
34663471 while (true) {
34673472 const rc = openat_sym(dir.handle, sub_path_posix, flags, options.permissions.toMode());
lib/std/os/linux.zig+4-3
......@@ -459,13 +459,14 @@ pub const O = switch (native_arch) {
459459 NOFOLLOW: bool = false,
460460 NOATIME: bool = false,
461461 CLOEXEC: bool = false,
462 _20: u1 = 0,
462 TMPFILE0: bool = false,
463463 PATH: bool = false,
464 _22: u10 = 0,
464 _22: u4 = 0,
465 TMPFILE1: bool = false,
466 _27: u5 = 0,
465467
466468 // #define O_RSYNC 04010000
467469 // #define O_SYNC 04010000
468 // #define O_TMPFILE 020200000
469470 // #define O_NDELAY O_NONBLOCK
470471 },
471472 .m68k => packed struct(u32) {