| ... | ... | @@ -366,12 +366,12 @@ const Thread = struct { |
| 366 | 366 | |
| 367 | 367 | fn futexWake(ptr: *const u32, max_waiters: u32) void { |
| 368 | 368 | @branchHint(.cold); |
| 369 | assert(max_waiters != 0); |
| 369 | 370 | |
| 370 | 371 | if (builtin.single_threaded) return; // nothing to wake up |
| 371 | 372 | |
| 372 | 373 | if (builtin.cpu.arch.isWasm()) { |
| 373 | 374 | comptime assert(builtin.cpu.has(.wasm, .atomics)); |
| 374 | | assert(max_waiters != 0); |
| 375 | 375 | const woken_count = asm volatile ( |
| 376 | 376 | \\local.get %[ptr] |
| 377 | 377 | \\local.get %[waiters] |
| ... | ... | @@ -416,7 +416,6 @@ const Thread = struct { |
| 416 | 416 | } |
| 417 | 417 | }, |
| 418 | 418 | .windows => { |
| 419 | | assert(max_waiters != 0); |
| 420 | 419 | switch (max_waiters) { |
| 421 | 420 | 1 => windows.ntdll.RtlWakeAddressSingle(ptr), |
| 422 | 421 | else => windows.ntdll.RtlWakeAddressAll(ptr), |
| ... | ... | @@ -953,7 +952,8 @@ const have_fchown = switch (native_os) { |
| 953 | 952 | }; |
| 954 | 953 | |
| 955 | 954 | const have_fchmod = switch (native_os) { |
| 956 | | .wasi, .windows => false, |
| 955 | .windows => false, |
| 956 | .wasi => builtin.link_libc, |
| 957 | 957 | else => true, |
| 958 | 958 | }; |
| 959 | 959 | |
| ... | ... | @@ -6772,7 +6772,7 @@ fn fileSeekBy(userdata: ?*anyopaque, file: File, offset: i64) File.SeekError!voi |
| 6772 | 6772 | var result: u64 = undefined; |
| 6773 | 6773 | try current_thread.beginSyscall(); |
| 6774 | 6774 | while (true) { |
| 6775 | | switch (posix.errno(posix.system.llseek(fd, offset, &result, posix.SEEK.CUR))) { |
| 6775 | switch (posix.errno(posix.system.llseek(fd, @bitCast(offset), &result, posix.SEEK.CUR))) { |
| 6776 | 6776 | .SUCCESS => { |
| 6777 | 6777 | current_thread.endSyscall(); |
| 6778 | 6778 | return; |
| ... | ... | @@ -7000,7 +7000,7 @@ fn processExecutablePath(userdata: ?*anyopaque, out_buffer: []u8) std.process.Ex |
| 7000 | 7000 | if (rc != 0) return error.NameTooLong; |
| 7001 | 7001 | |
| 7002 | 7002 | var real_path_buf: [posix.PATH_MAX]u8 = undefined; |
| 7003 | | const n = Io.Dir.realPathAbsolute(ioBasic(t), &symlink_path_buf, &real_path_buf) catch |err| switch (err) { |
| 7003 | const n = Io.Dir.realPathFileAbsolute(ioBasic(t), &symlink_path_buf, &real_path_buf) catch |err| switch (err) { |
| 7004 | 7004 | error.NetworkNotFound => unreachable, // Windows-only |
| 7005 | 7005 | else => |e| return e, |
| 7006 | 7006 | }; |
| ... | ... | @@ -7020,11 +7020,32 @@ fn processExecutablePath(userdata: ?*anyopaque, out_buffer: []u8) std.process.Ex |
| 7020 | 7020 | }, |
| 7021 | 7021 | .freebsd, .dragonfly => { |
| 7022 | 7022 | const current_thread = Thread.getCurrent(t); |
| 7023 | | try current_thread.checkCancel(); |
| 7024 | 7023 | var mib: [4]c_int = .{ posix.CTL.KERN, posix.KERN.PROC, posix.KERN.PROC_PATHNAME, -1 }; |
| 7025 | 7024 | var out_len: usize = out_buffer.len; |
| 7026 | | try posix.sysctl(&mib, out_buffer.ptr, &out_len, null, 0); |
| 7027 | | return out_len; |
| 7025 | try current_thread.beginSyscall(); |
| 7026 | while (true) { |
| 7027 | switch (posix.errno(posix.system.sysctl(&mib, mib.len, out_buffer.ptr, &out_len, null, 0))) { |
| 7028 | .SUCCESS => { |
| 7029 | current_thread.endSyscall(); |
| 7030 | return out_len; |
| 7031 | }, |
| 7032 | .INTR => { |
| 7033 | try current_thread.checkCancel(); |
| 7034 | continue; |
| 7035 | }, |
| 7036 | .CANCELED => return current_thread.endSyscallCanceled(), |
| 7037 | else => |e| { |
| 7038 | current_thread.endSyscall(); |
| 7039 | switch (e) { |
| 7040 | .FAULT => |err| return errnoBug(err), |
| 7041 | .PERM => return error.PermissionDenied, |
| 7042 | .NOMEM => return error.SystemResources, |
| 7043 | .NOENT => |err| return errnoBug(err), |
| 7044 | else => |err| return posix.unexpectedErrno(err), |
| 7045 | } |
| 7046 | }, |
| 7047 | } |
| 7048 | } |
| 7028 | 7049 | }, |
| 7029 | 7050 | .netbsd => { |
| 7030 | 7051 | const current_thread = Thread.getCurrent(t); |
| ... | ... | @@ -7043,7 +7064,7 @@ fn processExecutablePath(userdata: ?*anyopaque, out_buffer: []u8) std.process.Ex |
| 7043 | 7064 | if (std.mem.indexOf(u8, argv0, "/") != null) { |
| 7044 | 7065 | // argv[0] is a path (relative or absolute): use realpath(3) directly |
| 7045 | 7066 | var real_path_buf: [posix.PATH_MAX]u8 = undefined; |
| 7046 | | const real_path = Io.Dir.realPathAbsolute(ioBasic(t), std.os.argv[0], &real_path_buf) catch |err| switch (err) { |
| 7067 | const real_path = Io.Dir.realPathFileAbsolute(ioBasic(t), std.os.argv[0], &real_path_buf) catch |err| switch (err) { |
| 7047 | 7068 | error.NetworkNotFound => unreachable, // Windows-only |
| 7048 | 7069 | else => |e| return e, |
| 7049 | 7070 | }; |
| ... | ... | @@ -7063,7 +7084,7 @@ fn processExecutablePath(userdata: ?*anyopaque, out_buffer: []u8) std.process.Ex |
| 7063 | 7084 | }, 0) catch continue; |
| 7064 | 7085 | |
| 7065 | 7086 | var real_path_buf: [posix.PATH_MAX]u8 = undefined; |
| 7066 | | if (Io.Dir.realPathAbsolute(ioBasic(t), resolved_path, &real_path_buf)) |real_path| { |
| 7087 | if (Io.Dir.realPathFileAbsolute(ioBasic(t), resolved_path, &real_path_buf)) |real_path| { |
| 7067 | 7088 | // found a file, and hope it is the right file |
| 7068 | 7089 | if (real_path.len > out_buffer.len) |
| 7069 | 7090 | return error.NameTooLong; |
| ... | ... | @@ -7730,8 +7751,8 @@ fn fileWriteFileStreaming( |
| 7730 | 7751 | .FBIG => return error.FileTooBig, |
| 7731 | 7752 | .IO => return error.InputOutput, |
| 7732 | 7753 | .INTEGRITY => return error.CorruptedData, |
| 7733 | | .ISDIR => return error.IsDir, |
| 7734 | 7754 | .NOSPC => return error.NoSpaceLeft, |
| 7755 | .ISDIR => |err| errnoBug(err), |
| 7735 | 7756 | .BADF => |err| errnoBug(err), |
| 7736 | 7757 | else => |err| posix.unexpectedErrno(err), |
| 7737 | 7758 | }); |
| ... | ... | @@ -7908,11 +7929,11 @@ fn fileWriteFilePositional( |
| 7908 | 7929 | .FBIG => return error.FileTooBig, |
| 7909 | 7930 | .IO => return error.InputOutput, |
| 7910 | 7931 | .INTEGRITY => return error.CorruptedData, |
| 7911 | | .ISDIR => return error.IsDir, |
| 7912 | 7932 | .NOSPC => return error.NoSpaceLeft, |
| 7913 | 7933 | .OVERFLOW => return error.Unseekable, |
| 7914 | 7934 | .NXIO => return error.Unseekable, |
| 7915 | 7935 | .SPIPE => return error.Unseekable, |
| 7936 | .ISDIR => |err| errnoBug(err), |
| 7916 | 7937 | .BADF => |err| errnoBug(err), |
| 7917 | 7938 | else => |err| posix.unexpectedErrno(err), |
| 7918 | 7939 | }); |