Skip to content

Commit 9b3c182

Browse files
committed
windows: Posix mode_t is void, not u0 now
To be consistent with the Wasi mode_t, use 'void'.
1 parent a13c054 commit 9b3c182

File tree

6 files changed

+7
-12
lines changed

6 files changed

+7
-12
lines changed

lib/std/c.zig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,8 @@ pub const mode_t = switch (native_os) {
135135
.emscripten => emscripten.mode_t,
136136
.openbsd, .haiku, .netbsd, .solaris, .illumos => u32,
137137
.freebsd, .macos, .ios, .tvos, .watchos, .visionos => u16,
138-
.wasi => void,
139-
.windows => u0,
140-
else => u0, // TODO: should be void?
138+
.wasi, .windows => void,
139+
else => void,
141140
};
142141

143142
pub const nlink_t = switch (native_os) {

lib/std/fs/Dir.zig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ pub const Handle = posix.fd_t;
44

55
/// Default mode bits for a new directory.
66
pub const default_mode = switch (posix.mode_t) {
7-
void => {}, // wasi-without-libc has no mode suppport
8-
u0 => 0, // Zig's Posix layer doesn't support modes on Windows
7+
void => {},
98
else => 0o755,
109
};
1110

lib/std/fs/File.zig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ pub const Kind = enum {
2828
/// libc implementations use `0o666` inside `fopen` and then rely on the
2929
/// process-scoped "umask" setting to adjust this number for file creation.
3030
pub const default_mode = switch (posix.mode_t) {
31-
void => {}, // WASI-without-libc has no mode support
32-
u0 => 0, // Zig's Posix layer doesn't support modes for Windows
31+
void => {},
3332
else => 0o666,
3433
};
3534

@@ -495,7 +494,7 @@ pub fn stat(self: File) StatError!Stat {
495494
return .{
496495
.inode = info.InternalInformation.IndexNumber,
497496
.size = @as(u64, @bitCast(info.StandardInformation.EndOfFile)),
498-
.mode = 0,
497+
.mode = {},
499498
.kind = if (info.BasicInformation.FileAttributes & windows.FILE_ATTRIBUTE_REPARSE_POINT != 0) reparse_point: {
500499
var tag_info: windows.FILE_ATTRIBUTE_TAG_INFO = undefined;
501500
const tag_rc = windows.ntdll.NtQueryInformationFile(self.handle, &io_status_block, &tag_info, @sizeOf(windows.FILE_ATTRIBUTE_TAG_INFO), .FileAttributeTagInformation);

lib/std/posix/test.zig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ test "chdir smoke test" {
119119

120120
const default_mode = switch (posix.mode_t) {
121121
void => {},
122-
u0 => 0,
123122
else => 0o666,
124123
};
125124

src/link.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ pub const File = struct {
970970
// with 0o755 permissions, but it works appropriately if the system is configured
971971
// more leniently. As another data point, C's fopen seems to open files with the
972972
// 666 mode.
973-
const executable_mode = if (builtin.target.os.tag == .windows) 0 else 0o777;
973+
const executable_mode = if (fs.File.Mode == void) {} else 0o777;
974974
switch (effectiveOutputMode(use_lld, output_mode)) {
975975
.Lib => return switch (link_mode) {
976976
.dynamic => executable_mode,

src/link/Wasm.zig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,7 @@ pub fn createEmpty(
438438
fs.File.default_mode | 0b001_000_000
439439
else
440440
fs.File.default_mode
441-
else
442-
0,
441+
else {},
443442
});
444443
wasm.name = sub_path;
445444

0 commit comments

Comments
 (0)