Skip to content

Commit d98770c

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

File tree

6 files changed

+7
-11
lines changed

6 files changed

+7
-11
lines changed

lib/std/c.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ pub const mode_t = switch (native_os) {
136136
.openbsd, .haiku, .netbsd, .solaris, .illumos => u32,
137137
.wasi => u32, // NOTE: wasi-without-libc maps mode_t to 'void'
138138
.freebsd, .macos, .ios, .tvos, .watchos, .visionos => u16,
139-
.windows => u0,
140-
else => u0, // TODO: should be void?
139+
.windows => void,
140+
else => void,
141141
};
142142

143143
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
@@ -994,7 +994,7 @@ pub const File = struct {
994994
// with 0o755 permissions, but it works appropriately if the system is configured
995995
// more leniently. As another data point, C's fopen seems to open files with the
996996
// 666 mode.
997-
const executable_mode = if (builtin.target.os.tag == .windows) 0 else 0o777;
997+
const executable_mode = if (fs.File.Mode == void) {} else 0o777;
998998
switch (effectiveOutputMode(use_lld, output_mode)) {
999999
.Lib => return switch (link_mode) {
10001000
.dynamic => executable_mode,

src/link/Wasm.zig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,7 @@ pub fn createEmpty(
440440
fs.File.default_mode | 0b001_000_000
441441
else
442442
fs.File.default_mode
443-
else
444-
0,
443+
else {},
445444
});
446445
wasm.name = sub_path;
447446

0 commit comments

Comments
 (0)