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.
This commit is contained in:
Andrew Kelley
2026-01-04 22:02:56 -08:00
parent 77f6e0690b
commit 75f417108c
2 changed files with 15 additions and 9 deletions
+11 -6
View File
@@ -3430,6 +3430,17 @@ fn dirCreateFileAtomic(
// useless when we have to make up a bogus path name to do the rename()
// anyway.
if (native_os == .linux and !options.replace) tmpfile: {
const flags: posix.O = if (@hasField(posix.O, "TMPFILE")) .{
.ACCMODE = .RDWR,
.TMPFILE = true,
.CLOEXEC = true,
} else if (@hasField(posix.O, "TMPFILE0") and !@hasField(posix.O, "TMPFILE2")) .{
.ACCMODE = .RDWR,
.TMPFILE0 = true,
.TMPFILE1 = true,
.CLOEXEC = true,
} else break :tmpfile;
const dest_dirname = Dir.path.dirname(dest_path);
if (dest_dirname) |dirname| {
// This has a nice side effect of preemptively triggering EISDIR or
@@ -3456,12 +3467,6 @@ fn dirCreateFileAtomic(
var path_buffer: [posix.PATH_MAX]u8 = undefined;
const sub_path_posix = try pathToPosix(dest_dirname orelse ".", &path_buffer);
const flags: posix.O = .{
.ACCMODE = .RDWR,
.TMPFILE = true,
.CLOEXEC = true,
};
const syscall: Syscall = try .start();
while (true) {
const rc = openat_sym(dir.handle, sub_path_posix, flags, options.permissions.toMode());
+4 -3
View File
@@ -459,13 +459,14 @@ pub const O = switch (native_arch) {
NOFOLLOW: bool = false,
NOATIME: bool = false,
CLOEXEC: bool = false,
_20: u1 = 0,
TMPFILE0: bool = false,
PATH: bool = false,
_22: u10 = 0,
_22: u4 = 0,
TMPFILE1: bool = false,
_27: u5 = 0,
// #define O_RSYNC 04010000
// #define O_SYNC 04010000
// #define O_TMPFILE 020200000
// #define O_NDELAY O_NONBLOCK
},
.m68k => packed struct(u32) {