aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/node/syscall.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/node/syscall.zig')
-rw-r--r--src/bun.js/node/syscall.zig30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/bun.js/node/syscall.zig b/src/bun.js/node/syscall.zig
index 7b10a3028..77bd5b13d 100644
--- a/src/bun.js/node/syscall.zig
+++ b/src/bun.js/node/syscall.zig
@@ -202,7 +202,7 @@ pub fn openat(dirfd: bun.FileDescriptor, file_path: [:0]const u8, flags: JSC.Nod
.SUCCESS => .{ .result = @intCast(bun.FileDescriptor, rc) },
else => |err| .{
.err = .{
- .errno = @truncate(Syscall.Error.Int, @enumToInt(err)),
+ .errno = @truncate(Syscall.Error.Int, @intFromEnum(err)),
.syscall = .open,
},
},
@@ -218,7 +218,7 @@ pub fn openat(dirfd: bun.FileDescriptor, file_path: [:0]const u8, flags: JSC.Nod
else => |err| {
return Maybe(std.os.fd_t){
.err = .{
- .errno = @truncate(Syscall.Error.Int, @enumToInt(err)),
+ .errno = @truncate(Syscall.Error.Int, @intFromEnum(err)),
.syscall = .open,
},
};
@@ -253,14 +253,14 @@ pub fn closeAllowingStdoutAndStderr(fd: std.os.fd_t) ?Syscall.Error {
if (comptime Environment.isMac) {
// This avoids the EINTR problem.
return switch (system.getErrno(system.@"close$NOCANCEL"(fd))) {
- .BADF => Syscall.Error{ .errno = @enumToInt(os.E.BADF), .syscall = .close },
+ .BADF => Syscall.Error{ .errno = @intFromEnum(os.E.BADF), .syscall = .close },
else => null,
};
}
if (comptime Environment.isLinux) {
return switch (linux.getErrno(linux.close(fd))) {
- .BADF => Syscall.Error{ .errno = @enumToInt(os.E.BADF), .syscall = .close },
+ .BADF => Syscall.Error{ .errno = @intFromEnum(os.E.BADF), .syscall = .close },
else => null,
};
}
@@ -546,7 +546,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) Maybe([]u8) {
.macos, .ios, .watchos, .tvos => {
// On macOS, we can use F.GETPATH fcntl command to query the OS for
// the path to the file descriptor.
- @memset(out_buffer, 0, MAX_PATH_BYTES);
+ @memset(out_buffer[0..MAX_PATH_BYTES], 0);
if (Maybe([]u8).errnoSys(system.fcntl(fd, os.F.GETPATH, out_buffer), .fcntl)) |err| {
return err;
}
@@ -594,7 +594,7 @@ fn mmap(
const fail = std.c.MAP.FAILED;
if (rc == fail) {
return Maybe([]align(mem.page_size) u8){
- .err = .{ .errno = @truncate(Syscall.Error.Int, @enumToInt(std.c.getErrno(@bitCast(i64, @ptrToInt(fail))))), .syscall = .mmap },
+ .err = .{ .errno = @truncate(Syscall.Error.Int, @intFromEnum(std.c.getErrno(@bitCast(i64, @intFromPtr(fail))))), .syscall = .mmap },
};
}
@@ -643,16 +643,16 @@ pub fn munmap(memory: []align(mem.page_size) const u8) Maybe(void) {
pub const Error = struct {
const max_errno_value = brk: {
const errno_values = std.enums.values(os.E);
- var err = @enumToInt(os.E.SUCCESS);
+ var err = @intFromEnum(os.E.SUCCESS);
for (errno_values) |errn| {
- err = @max(err, @enumToInt(errn));
+ err = @max(err, @intFromEnum(errn));
}
break :brk err;
};
pub const Int: type = std.math.IntFittingRange(0, max_errno_value + 5);
errno: Int,
- syscall: Syscall.Tag = @intToEnum(Syscall.Tag, 0),
+ syscall: Syscall.Tag = @enumFromInt(Syscall.Tag, 0),
path: []const u8 = "",
fd: i32 = -1,
@@ -661,7 +661,7 @@ pub const Error = struct {
}
pub fn fromCode(errno: os.E, syscall: Syscall.Tag) Error {
- return .{ .errno = @truncate(Int, @enumToInt(errno)), .syscall = syscall };
+ return .{ .errno = @truncate(Int, @intFromEnum(errno)), .syscall = syscall };
}
pub fn format(self: Error, comptime fmt: []const u8, opts: std.fmt.FormatOptions, writer: anytype) !void {
@@ -672,16 +672,16 @@ pub const Error = struct {
pub const retry = Error{
.errno = if (Environment.isLinux)
- @intCast(Int, @enumToInt(os.E.AGAIN))
+ @intCast(Int, @intFromEnum(os.E.AGAIN))
else if (Environment.isMac)
- @intCast(Int, @enumToInt(os.E.WOULDBLOCK))
+ @intCast(Int, @intFromEnum(os.E.WOULDBLOCK))
else
- @intCast(Int, @enumToInt(os.E.INTR)),
+ @intCast(Int, @intFromEnum(os.E.INTR)),
.syscall = .retry,
};
pub inline fn getErrno(this: Error) os.E {
- return @intToEnum(os.E, this.errno);
+ return @enumFromInt(os.E, this.errno);
}
pub inline fn withPath(this: Error, path: anytype) Error {
@@ -726,7 +726,7 @@ pub const Error = struct {
// errno label
if (this.errno > 0 and this.errno < C.SystemErrno.max) {
- const system_errno = @intToEnum(C.SystemErrno, this.errno);
+ const system_errno = @enumFromInt(C.SystemErrno, this.errno);
err.code = JSC.ZigString.init(@tagName(system_errno));
if (C.SystemErrno.labels.get(system_errno)) |label| {
err.message = JSC.ZigString.init(label);