Skip to content

Commit 20dc7c0

Browse files
committed
std.os reorganization, avoiding usingnamespace
The main purpose of this branch is to explore avoiding the `usingnamespace` feature of the zig language, specifically with regards to `std.os` and related functionality. If this experiment is successful, it will provide a data point on whether or not it would be practical to entirely remove `usingnamespace` from the language. In this commit, `usingnamespace` has been completely eliminated from the Linux x86_64 compilation path, aside from io_uring. The behavior tests pass, however that's as far as this branch goes. It is very breaking, and a lot more work is needed before it could be considered mergeable. I wanted to put a pull requset up early so that zig programmers have time to provide feedback. This is progress towards closing #6600 since it clarifies where the actual "owner" of each declaration is, and reduces the number of different ways to import the same declarations. One of the main organizational strategies used here is to do namespacing with real namespaces (e.g. structs) rather than by having declarations share a common prefix (the C strategy). It's no coincidence that `usingnamespace` has similar semantics to `#include` and becomes much less necessary when using proper namespaces.
1 parent f1f28af commit 20dc7c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+4454
-4280
lines changed

CMakeLists.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -424,13 +424,9 @@ set(ZIG_STAGE2_SOURCES
424424
"${CMAKE_SOURCE_DIR}/lib/std/meta/trait.zig"
425425
"${CMAKE_SOURCE_DIR}/lib/std/multi_array_list.zig"
426426
"${CMAKE_SOURCE_DIR}/lib/std/os.zig"
427-
"${CMAKE_SOURCE_DIR}/lib/std/os/bits.zig"
428-
"${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux.zig"
429-
"${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux/errno/generic.zig"
430-
"${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux/netlink.zig"
431-
"${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux/prctl.zig"
432-
"${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux/securebits.zig"
433-
"${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux/x86_64.zig"
427+
"${CMAKE_SOURCE_DIR}/lib/std/os/linux.zig"
428+
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/errno/generic.zig"
429+
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/x86_64.zig"
434430
"${CMAKE_SOURCE_DIR}/lib/std/os/linux.zig"
435431
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/io_uring.zig"
436432
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/x86_64.zig"

lib/std/Thread/Mutex.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub const AtomicMutex = struct {
133133
.linux => {
134134
switch (linux.getErrno(linux.futex_wait(
135135
@ptrCast(*const i32, &m.state),
136-
linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAIT,
136+
linux.FUTEX.PRIVATE_FLAG | linux.FUTEX.WAIT,
137137
@enumToInt(new_state),
138138
null,
139139
))) {
@@ -155,7 +155,7 @@ pub const AtomicMutex = struct {
155155
.linux => {
156156
switch (linux.getErrno(linux.futex_wake(
157157
@ptrCast(*const i32, &m.state),
158-
linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAKE,
158+
linux.FUTEX.PRIVATE_FLAG | linux.FUTEX.WAKE,
159159
1,
160160
))) {
161161
.SUCCESS => {},

lib/std/Thread/StaticResetEvent.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ pub const AtomicEvent = struct {
194194
_ = wake_count;
195195
const waiting = std.math.maxInt(i32); // wake_count
196196
const ptr = @ptrCast(*const i32, waiters);
197-
const rc = linux.futex_wake(ptr, linux.FUTEX_WAKE | linux.FUTEX_PRIVATE_FLAG, waiting);
197+
const rc = linux.futex_wake(ptr, linux.FUTEX.WAKE | linux.FUTEX.PRIVATE_FLAG, waiting);
198198
assert(linux.getErrno(rc) == .SUCCESS);
199199
}
200200

@@ -213,7 +213,7 @@ pub const AtomicEvent = struct {
213213
return;
214214
const expected = @intCast(i32, waiting);
215215
const ptr = @ptrCast(*const i32, waiters);
216-
const rc = linux.futex_wait(ptr, linux.FUTEX_WAIT | linux.FUTEX_PRIVATE_FLAG, expected, ts_ptr);
216+
const rc = linux.futex_wait(ptr, linux.FUTEX.WAIT | linux.FUTEX.PRIVATE_FLAG, expected, ts_ptr);
217217
switch (linux.getErrno(rc)) {
218218
.SUCCESS => continue,
219219
.TIMEDOUT => return error.TimedOut,

lib/std/c.zig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ test {
1010
_ = tokenizer;
1111
}
1212

13-
pub usingnamespace @import("os/bits.zig");
14-
1513
pub usingnamespace switch (std.Target.current.os.tag) {
1614
.linux => @import("c/linux.zig"),
1715
.windows => @import("c/windows.zig"),

lib/std/c/darwin.zig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ const builtin = @import("builtin");
44
const macho = std.macho;
55
const native_arch = builtin.target.cpu.arch;
66

7-
usingnamespace @import("../os/bits.zig");
8-
97
extern "c" fn __error() *c_int;
108
pub extern "c" fn NSVersionOfRunTimeLibrary(library_name: [*:0]const u8) u32;
119
pub extern "c" fn _NSGetExecutablePath(buf: [*:0]u8, bufsize: *u32) c_int;

lib/std/c/wasi.zig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
usingnamespace @import("../os/bits.zig");
2-
31
extern threadlocal var errno: c_int;
42

53
pub fn _errno() *c_int {

lib/std/debug.zig

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,8 @@ fn mapWholeFile(file: File) ![]align(mem.page_size) const u8 {
948948
const mapped_mem = try os.mmap(
949949
null,
950950
file_len,
951-
os.PROT_READ,
952-
os.MAP_SHARED,
951+
os.PROT.READ,
952+
os.MAP.SHARED,
953953
file.handle,
954954
0,
955955
);
@@ -1498,12 +1498,12 @@ pub fn attachSegfaultHandler() void {
14981498
var act = os.Sigaction{
14991499
.handler = .{ .sigaction = handleSegfaultLinux },
15001500
.mask = os.empty_sigset,
1501-
.flags = (os.SA_SIGINFO | os.SA_RESTART | os.SA_RESETHAND),
1501+
.flags = (os.SA.SIGINFO | os.SA.RESTART | os.SA.RESETHAND),
15021502
};
15031503

1504-
os.sigaction(os.SIGSEGV, &act, null);
1505-
os.sigaction(os.SIGILL, &act, null);
1506-
os.sigaction(os.SIGBUS, &act, null);
1504+
os.sigaction(os.SIG.SEGV, &act, null);
1505+
os.sigaction(os.SIG.ILL, &act, null);
1506+
os.sigaction(os.SIG.BUS, &act, null);
15071507
}
15081508

15091509
fn resetSegfaultHandler() void {
@@ -1515,13 +1515,13 @@ fn resetSegfaultHandler() void {
15151515
return;
15161516
}
15171517
var act = os.Sigaction{
1518-
.handler = .{ .sigaction = os.SIG_DFL },
1518+
.handler = .{ .sigaction = os.SIG.DFL },
15191519
.mask = os.empty_sigset,
15201520
.flags = 0,
15211521
};
1522-
os.sigaction(os.SIGSEGV, &act, null);
1523-
os.sigaction(os.SIGILL, &act, null);
1524-
os.sigaction(os.SIGBUS, &act, null);
1522+
os.sigaction(os.SIG.SEGV, &act, null);
1523+
os.sigaction(os.SIG.ILL, &act, null);
1524+
os.sigaction(os.SIG.BUS, &act, null);
15251525
}
15261526

15271527
fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_void) callconv(.C) noreturn {
@@ -1542,30 +1542,30 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_v
15421542
nosuspend {
15431543
const stderr = io.getStdErr().writer();
15441544
_ = switch (sig) {
1545-
os.SIGSEGV => stderr.print("Segmentation fault at address 0x{x}\n", .{addr}),
1546-
os.SIGILL => stderr.print("Illegal instruction at address 0x{x}\n", .{addr}),
1547-
os.SIGBUS => stderr.print("Bus error at address 0x{x}\n", .{addr}),
1545+
os.SIG.SEGV => stderr.print("Segmentation fault at address 0x{x}\n", .{addr}),
1546+
os.SIG.ILL => stderr.print("Illegal instruction at address 0x{x}\n", .{addr}),
1547+
os.SIG.BUS => stderr.print("Bus error at address 0x{x}\n", .{addr}),
15481548
else => unreachable,
15491549
} catch os.abort();
15501550
}
15511551

15521552
switch (native_arch) {
15531553
.i386 => {
15541554
const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr));
1555-
const ip = @intCast(usize, ctx.mcontext.gregs[os.REG_EIP]);
1556-
const bp = @intCast(usize, ctx.mcontext.gregs[os.REG_EBP]);
1555+
const ip = @intCast(usize, ctx.mcontext.gregs[os.REG.EIP]);
1556+
const bp = @intCast(usize, ctx.mcontext.gregs[os.REG.EBP]);
15571557
dumpStackTraceFromBase(bp, ip);
15581558
},
15591559
.x86_64 => {
15601560
const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr));
15611561
const ip = switch (native_os) {
1562-
.linux, .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG_RIP]),
1562+
.linux, .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG.RIP]),
15631563
.freebsd => @intCast(usize, ctx.mcontext.rip),
15641564
.openbsd => @intCast(usize, ctx.sc_rip),
15651565
else => unreachable,
15661566
};
15671567
const bp = switch (native_os) {
1568-
.linux, .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG_RBP]),
1568+
.linux, .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG.RBP]),
15691569
.openbsd => @intCast(usize, ctx.sc_rbp),
15701570
.freebsd => @intCast(usize, ctx.mcontext.rbp),
15711571
else => unreachable,

lib/std/fs.zig

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -907,35 +907,35 @@ pub const Dir = struct {
907907
return self.openFileW(path_w.span(), flags);
908908
}
909909

910-
var os_flags: u32 = os.O_CLOEXEC;
910+
var os_flags: u32 = os.O.CLOEXEC;
911911
// Use the O_ locking flags if the os supports them to acquire the lock
912912
// atomically.
913-
const has_flock_open_flags = @hasDecl(os, "O_EXLOCK");
913+
const has_flock_open_flags = @hasDecl(os.O, "EXLOCK");
914914
if (has_flock_open_flags) {
915915
// Note that the O_NONBLOCK flag is removed after the openat() call
916916
// is successful.
917917
const nonblocking_lock_flag: u32 = if (flags.lock_nonblocking)
918-
os.O_NONBLOCK
918+
os.O.NONBLOCK
919919
else
920920
0;
921921
os_flags |= switch (flags.lock) {
922922
.None => @as(u32, 0),
923-
.Shared => os.O_SHLOCK | nonblocking_lock_flag,
924-
.Exclusive => os.O_EXLOCK | nonblocking_lock_flag,
923+
.Shared => os.O.SHLOCK | nonblocking_lock_flag,
924+
.Exclusive => os.O.EXLOCK | nonblocking_lock_flag,
925925
};
926926
}
927-
if (@hasDecl(os, "O_LARGEFILE")) {
928-
os_flags |= os.O_LARGEFILE;
927+
if (@hasDecl(os.O, "LARGEFILE")) {
928+
os_flags |= os.O.LARGEFILE;
929929
}
930930
if (!flags.allow_ctty) {
931-
os_flags |= os.O_NOCTTY;
931+
os_flags |= os.O.NOCTTY;
932932
}
933933
os_flags |= if (flags.write and flags.read)
934-
@as(u32, os.O_RDWR)
934+
@as(u32, os.O.RDWR)
935935
else if (flags.write)
936-
@as(u32, os.O_WRONLY)
936+
@as(u32, os.O.WRONLY)
937937
else
938-
@as(u32, os.O_RDONLY);
938+
@as(u32, os.O.RDONLY);
939939
const fd = if (flags.intended_io_mode != .blocking)
940940
try std.event.Loop.instance.?.openatZ(self.fd, sub_path, os_flags, 0)
941941
else
@@ -947,11 +947,11 @@ pub const Dir = struct {
947947
if (builtin.target.os.tag != .wasi) {
948948
if (!has_flock_open_flags and flags.lock != .None) {
949949
// TODO: integrate async I/O
950-
const lock_nonblocking = if (flags.lock_nonblocking) os.LOCK_NB else @as(i32, 0);
950+
const lock_nonblocking = if (flags.lock_nonblocking) os.LOCK.NB else @as(i32, 0);
951951
try os.flock(fd, switch (flags.lock) {
952952
.None => unreachable,
953-
.Shared => os.LOCK_SH | lock_nonblocking,
954-
.Exclusive => os.LOCK_EX | lock_nonblocking,
953+
.Shared => os.LOCK.SH | lock_nonblocking,
954+
.Exclusive => os.LOCK.EX | lock_nonblocking,
955955
});
956956
}
957957
}
@@ -963,7 +963,7 @@ pub const Dir = struct {
963963
error.PermissionDenied => unreachable,
964964
else => |e| return e,
965965
};
966-
fl_flags &= ~@as(usize, os.O_NONBLOCK);
966+
fl_flags &= ~@as(usize, os.O.NONBLOCK);
967967
_ = os.fcntl(fd, os.F_SETFL, fl_flags) catch |err| switch (err) {
968968
error.FileBusy => unreachable,
969969
error.Locked => unreachable,
@@ -1038,7 +1038,7 @@ pub const Dir = struct {
10381038
/// Same as `createFile` but WASI only.
10391039
pub fn createFileWasi(self: Dir, sub_path: []const u8, flags: File.CreateFlags) File.OpenError!File {
10401040
const w = os.wasi;
1041-
var oflags = w.O_CREAT;
1041+
var oflags = w.O.CREAT;
10421042
var base: w.rights_t = w.RIGHT_FD_WRITE |
10431043
w.RIGHT_FD_DATASYNC |
10441044
w.RIGHT_FD_SEEK |
@@ -1054,10 +1054,10 @@ pub const Dir = struct {
10541054
base |= w.RIGHT_FD_READ;
10551055
}
10561056
if (flags.truncate) {
1057-
oflags |= w.O_TRUNC;
1057+
oflags |= w.O.TRUNC;
10581058
}
10591059
if (flags.exclusive) {
1060-
oflags |= w.O_EXCL;
1060+
oflags |= w.O.EXCL;
10611061
}
10621062
const fd = try os.openatWasi(self.fd, sub_path, 0x0, oflags, 0x0, base, 0x0);
10631063
return File{ .handle = fd };
@@ -1072,24 +1072,24 @@ pub const Dir = struct {
10721072

10731073
// Use the O_ locking flags if the os supports them to acquire the lock
10741074
// atomically.
1075-
const has_flock_open_flags = @hasDecl(os, "O_EXLOCK");
1075+
const has_flock_open_flags = @hasDecl(os.O, "EXLOCK");
10761076
// Note that the O_NONBLOCK flag is removed after the openat() call
10771077
// is successful.
10781078
const nonblocking_lock_flag: u32 = if (has_flock_open_flags and flags.lock_nonblocking)
1079-
os.O_NONBLOCK
1079+
os.O.NONBLOCK
10801080
else
10811081
0;
10821082
const lock_flag: u32 = if (has_flock_open_flags) switch (flags.lock) {
10831083
.None => @as(u32, 0),
1084-
.Shared => os.O_SHLOCK | nonblocking_lock_flag,
1085-
.Exclusive => os.O_EXLOCK | nonblocking_lock_flag,
1084+
.Shared => os.O.SHLOCK | nonblocking_lock_flag,
1085+
.Exclusive => os.O.EXLOCK | nonblocking_lock_flag,
10861086
} else 0;
10871087

1088-
const O_LARGEFILE = if (@hasDecl(os, "O_LARGEFILE")) os.O_LARGEFILE else 0;
1089-
const os_flags = lock_flag | O_LARGEFILE | os.O_CREAT | os.O_CLOEXEC |
1090-
(if (flags.truncate) @as(u32, os.O_TRUNC) else 0) |
1091-
(if (flags.read) @as(u32, os.O_RDWR) else os.O_WRONLY) |
1092-
(if (flags.exclusive) @as(u32, os.O_EXCL) else 0);
1088+
const O_LARGEFILE = if (@hasDecl(os.O, "LARGEFILE")) os.O.LARGEFILE else 0;
1089+
const os_flags = lock_flag | O_LARGEFILE | os.O.CREAT | os.O.CLOEXEC |
1090+
(if (flags.truncate) @as(u32, os.O.TRUNC) else 0) |
1091+
(if (flags.read) @as(u32, os.O.RDWR) else os.O.WRONLY) |
1092+
(if (flags.exclusive) @as(u32, os.O.EXCL) else 0);
10931093
const fd = if (flags.intended_io_mode != .blocking)
10941094
try std.event.Loop.instance.?.openatZ(self.fd, sub_path_c, os_flags, flags.mode)
10951095
else
@@ -1101,11 +1101,11 @@ pub const Dir = struct {
11011101
if (builtin.target.os.tag != .wasi) {
11021102
if (!has_flock_open_flags and flags.lock != .None) {
11031103
// TODO: integrate async I/O
1104-
const lock_nonblocking = if (flags.lock_nonblocking) os.LOCK_NB else @as(i32, 0);
1104+
const lock_nonblocking = if (flags.lock_nonblocking) os.LOCK.NB else @as(i32, 0);
11051105
try os.flock(fd, switch (flags.lock) {
11061106
.None => unreachable,
1107-
.Shared => os.LOCK_SH | lock_nonblocking,
1108-
.Exclusive => os.LOCK_EX | lock_nonblocking,
1107+
.Shared => os.LOCK.SH | lock_nonblocking,
1108+
.Exclusive => os.LOCK.EX | lock_nonblocking,
11091109
});
11101110
}
11111111
}
@@ -1117,7 +1117,7 @@ pub const Dir = struct {
11171117
error.PermissionDenied => unreachable,
11181118
else => |e| return e,
11191119
};
1120-
fl_flags &= ~@as(usize, os.O_NONBLOCK);
1120+
fl_flags &= ~@as(usize, os.O.NONBLOCK);
11211121
_ = os.fcntl(fd, os.F_SETFL, fl_flags) catch |err| switch (err) {
11221122
error.FileBusy => unreachable,
11231123
error.Locked => unreachable,
@@ -1262,7 +1262,7 @@ pub const Dir = struct {
12621262
return self.realpathW(pathname_w.span(), out_buffer);
12631263
}
12641264

1265-
const flags = if (builtin.os.tag == .linux) os.O_PATH | os.O_NONBLOCK | os.O_CLOEXEC else os.O_NONBLOCK | os.O_CLOEXEC;
1265+
const flags = if (builtin.os.tag == .linux) os.O.PATH | os.O.NONBLOCK | os.O.CLOEXEC else os.O.NONBLOCK | os.O.CLOEXEC;
12661266
const fd = os.openatZ(self.fd, pathname, flags, 0) catch |err| switch (err) {
12671267
error.FileLocksNotSupported => unreachable,
12681268
else => |e| return e,
@@ -1423,7 +1423,7 @@ pub const Dir = struct {
14231423
// TODO do we really need all the rights here?
14241424
const inheriting: w.rights_t = w.RIGHT_ALL ^ w.RIGHT_SOCK_SHUTDOWN;
14251425

1426-
const result = os.openatWasi(self.fd, sub_path, symlink_flags, w.O_DIRECTORY, 0x0, base, inheriting);
1426+
const result = os.openatWasi(self.fd, sub_path, symlink_flags, w.O.DIRECTORY, 0x0, base, inheriting);
14271427
const fd = result catch |err| switch (err) {
14281428
error.FileTooBig => unreachable, // can't happen for directories
14291429
error.IsDir => unreachable, // we're providing O_DIRECTORY
@@ -1442,12 +1442,12 @@ pub const Dir = struct {
14421442
const sub_path_w = try os.windows.cStrToPrefixedFileW(sub_path_c);
14431443
return self.openDirW(sub_path_w.span().ptr, args);
14441444
}
1445-
const symlink_flags: u32 = if (args.no_follow) os.O_NOFOLLOW else 0x0;
1445+
const symlink_flags: u32 = if (args.no_follow) os.O.NOFOLLOW else 0x0;
14461446
if (!args.iterate) {
1447-
const O_PATH = if (@hasDecl(os, "O_PATH")) os.O_PATH else 0;
1448-
return self.openDirFlagsZ(sub_path_c, os.O_DIRECTORY | os.O_RDONLY | os.O_CLOEXEC | O_PATH | symlink_flags);
1447+
const O_PATH = if (@hasDecl(os.O, "PATH")) os.O.PATH else 0;
1448+
return self.openDirFlagsZ(sub_path_c, os.O.DIRECTORY | os.O.RDONLY | os.O.CLOEXEC | O_PATH | symlink_flags);
14491449
} else {
1450-
return self.openDirFlagsZ(sub_path_c, os.O_DIRECTORY | os.O_RDONLY | os.O_CLOEXEC | symlink_flags);
1450+
return self.openDirFlagsZ(sub_path_c, os.O.DIRECTORY | os.O.RDONLY | os.O.CLOEXEC | symlink_flags);
14511451
}
14521452
}
14531453

@@ -2132,7 +2132,7 @@ pub fn cwd() Dir {
21322132
} else if (builtin.os.tag == .wasi and !builtin.link_libc) {
21332133
@compileError("WASI doesn't have a concept of cwd(); use std.fs.wasi.PreopenList to get available Dir handles instead");
21342134
} else {
2135-
return Dir{ .fd = os.AT_FDCWD };
2135+
return Dir{ .fd = os.AT.FDCWD };
21362136
}
21372137
}
21382138

lib/std/fs/file.zig

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -329,14 +329,14 @@ pub const File = struct {
329329
os.FILETYPE_REGULAR_FILE => Kind.File,
330330
os.FILETYPE_SOCKET_STREAM, os.FILETYPE_SOCKET_DGRAM => Kind.UnixDomainSocket,
331331
else => Kind.Unknown,
332-
} else switch (st.mode & os.S_IFMT) {
333-
os.S_IFBLK => Kind.BlockDevice,
334-
os.S_IFCHR => Kind.CharacterDevice,
335-
os.S_IFDIR => Kind.Directory,
336-
os.S_IFIFO => Kind.NamedPipe,
337-
os.S_IFLNK => Kind.SymLink,
338-
os.S_IFREG => Kind.File,
339-
os.S_IFSOCK => Kind.UnixDomainSocket,
332+
} else switch (st.mode & os.S.IFMT) {
333+
os.S.IFBLK => Kind.BlockDevice,
334+
os.S.IFCHR => Kind.CharacterDevice,
335+
os.S.IFDIR => Kind.Directory,
336+
os.S.IFIFO => Kind.NamedPipe,
337+
os.S.IFLNK => Kind.SymLink,
338+
os.S.IFREG => Kind.File,
339+
os.S.IFSOCK => Kind.UnixDomainSocket,
340340
else => Kind.Unknown,
341341
},
342342
.atime = @as(i128, atime.tv_sec) * std.time.ns_per_s + atime.tv_nsec,

lib/std/heap.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ const PageAllocator = struct {
304304
const slice = os.mmap(
305305
hint,
306306
alloc_len,
307-
os.PROT_READ | os.PROT_WRITE,
308-
os.MAP_PRIVATE | os.MAP_ANONYMOUS,
307+
os.PROT.READ | os.PROT.WRITE,
308+
os.MAP.PRIVATE | os.MAP.ANONYMOUS,
309309
-1,
310310
0,
311311
) catch return error.OutOfMemory;

0 commit comments

Comments
 (0)