mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
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:
+11
-6
@@ -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());
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user