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-04 23:45:17-08:00
log75f417108c20f6bf8403202b6ec177f69497bcd8
treee9c393f9a36a153de7a6f5d77e141fce95db703e
parent77f6e0690bcbe6cd1e780c0c953bb68d809c7eea

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(...@@ -3430,6 +3430,17 @@ fn dirCreateFileAtomic(
3430 // useless when we have to make up a bogus path name to do the rename()3430 // useless when we have to make up a bogus path name to do the rename()
3431 // anyway.3431 // anyway.
3432 if (native_os == .linux and !options.replace) tmpfile: {3432 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
3433 const dest_dirname = Dir.path.dirname(dest_path);3444 const dest_dirname = Dir.path.dirname(dest_path);
3434 if (dest_dirname) |dirname| {3445 if (dest_dirname) |dirname| {
3435 // This has a nice side effect of preemptively triggering EISDIR or3446 // This has a nice side effect of preemptively triggering EISDIR or
...@@ -3456,12 +3467,6 @@ fn dirCreateFileAtomic(...@@ -3456,12 +3467,6 @@ fn dirCreateFileAtomic(
3456 var path_buffer: [posix.PATH_MAX]u8 = undefined;3467 var path_buffer: [posix.PATH_MAX]u8 = undefined;
3457 const sub_path_posix = try pathToPosix(dest_dirname orelse ".", &path_buffer);3468 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
3465 const syscall: Syscall = try .start();3470 const syscall: Syscall = try .start();
3466 while (true) {3471 while (true) {
3467 const rc = openat_sym(dir.handle, sub_path_posix, flags, options.permissions.toMode());3472 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) {...@@ -459,13 +459,14 @@ pub const O = switch (native_arch) {
459 NOFOLLOW: bool = false,459 NOFOLLOW: bool = false,
460 NOATIME: bool = false,460 NOATIME: bool = false,
461 CLOEXEC: bool = false,461 CLOEXEC: bool = false,
462 _20: u1 = 0,462 TMPFILE0: bool = false,
463 PATH: bool = false,463 PATH: bool = false,
464 _22: u10 = 0,464 _22: u4 = 0,
465 TMPFILE1: bool = false,
466 _27: u5 = 0,
465467
466 // #define O_RSYNC 04010000468 // #define O_RSYNC 04010000
467 // #define O_SYNC 04010000469 // #define O_SYNC 04010000
468 // #define O_TMPFILE 020200000
469 // #define O_NDELAY O_NONBLOCK470 // #define O_NDELAY O_NONBLOCK
470 },471 },
471 .m68k => packed struct(u32) {472 .m68k => packed struct(u32) {