| ... | @@ -2531,29 +2531,15 @@ pub const FStatError = error{ | ... | @@ -2531,29 +2531,15 @@ pub const FStatError = error{ |
| 2531 | | 2531 | |
| 2532 | pub fn fstat(fd: fd_t) FStatError!Stat { | 2532 | pub fn fstat(fd: fd_t) FStatError!Stat { |
| 2533 | var stat: Stat = undefined; | 2533 | var stat: Stat = undefined; |
| 2534 | if (comptime std.Target.current.isDarwin()) { | | |
| 2535 | switch (darwin.getErrno(darwin.@"fstat$INODE64"(fd, &stat))) { | | |
| 2536 | 0 => return stat, | | |
| 2537 | EINVAL => unreachable, | | |
| 2538 | EBADF => unreachable, // Always a race condition. | | |
| 2539 | ENOMEM => return error.SystemResources, | | |
| 2540 | EACCES => return error.AccessDenied, | | |
| 2541 | else => |err| return unexpectedErrno(err), | | |
| 2542 | } | | |
| 2543 | } | | |
| 2544 | | 2534 | |
| 2545 | if (std.Target.current.os.tag == .netbsd) { | 2535 | const symbol_name = if (comptime std.Target.current.isDarwin()) |
| 2546 | switch (errno(system.__fstat50(fd, &stat))) { | 2536 | "fstat$INODE64" |
| 2547 | 0 => return stat, | 2537 | else if (std.Target.current.os.tag == .netbsd) |
| 2548 | EINVAL => unreachable, | 2538 | "__fstat50" |
| 2549 | EBADF => unreachable, // Always a race condition. | 2539 | else |
| 2550 | ENOMEM => return error.SystemResources, | 2540 | "fstat"; |
| 2551 | EACCES => return error.AccessDenied, | | |
| 2552 | else => |err| return unexpectedErrno(err), | | |
| 2553 | } | | |
| 2554 | } | | |
| 2555 | | 2541 | |
| 2556 | switch (errno(system.fstat(fd, &stat))) { | 2542 | switch (errno(@field(system, symbol_name)(fd, &stat))) { |
| 2557 | 0 => return stat, | 2543 | 0 => return stat, |
| 2558 | EINVAL => unreachable, | 2544 | EINVAL => unreachable, |
| 2559 | EBADF => unreachable, // Always a race condition. | 2545 | EBADF => unreachable, // Always a race condition. |
| ... | @@ -3413,16 +3399,12 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void { | ... | @@ -3413,16 +3399,12 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void { |
| 3413 | return; | 3399 | return; |
| 3414 | } | 3400 | } |
| 3415 | | 3401 | |
| 3416 | if (std.Target.current.os.tag == .netbsd) { | 3402 | const symbol_name = if (std.Target.current.os.tag == .netbsd) |
| 3417 | switch (errno(system.__clock_gettime50(clk_id, tp))) { | 3403 | "__clock_gettime50" |
| 3418 | 0 => return, | 3404 | else |
| 3419 | EFAULT => unreachable, | 3405 | "clock_gettime"; |
| 3420 | EINVAL => return error.UnsupportedClock, | | |
| 3421 | else => |err| return unexpectedErrno(err), | | |
| 3422 | } | | |
| 3423 | } | | |
| 3424 | | 3406 | |
| 3425 | switch (errno(system.clock_gettime(clk_id, tp))) { | 3407 | switch (errno(@field(system, symbol_name)(clk_id, tp))) { |
| 3426 | 0 => return, | 3408 | 0 => return, |
| 3427 | EFAULT => unreachable, | 3409 | EFAULT => unreachable, |
| 3428 | EINVAL => return error.UnsupportedClock, | 3410 | EINVAL => return error.UnsupportedClock, |
| ... | @@ -3444,16 +3426,12 @@ pub fn clock_getres(clk_id: i32, res: *timespec) ClockGetTimeError!void { | ... | @@ -3444,16 +3426,12 @@ pub fn clock_getres(clk_id: i32, res: *timespec) ClockGetTimeError!void { |
| 3444 | return; | 3426 | return; |
| 3445 | } | 3427 | } |
| 3446 | | 3428 | |
| 3447 | if (std.Target.current.os.tag == .netbsd) { | 3429 | const symbol_name = if (std.Target.current.os.tag == .netbsd) |
| 3448 | switch (errno(system.__clock_getres50(clk_id, res))) { | 3430 | "__clock_getres50" |
| 3449 | 0 => return, | 3431 | else |
| 3450 | EFAULT => unreachable, | 3432 | "clock_getres"; |
| 3451 | EINVAL => return error.UnsupportedClock, | | |
| 3452 | else => |err| return unexpectedErrno(err), | | |
| 3453 | } | | |
| 3454 | } | | |
| 3455 | | 3433 | |
| 3456 | switch (errno(system.clock_getres(clk_id, res))) { | 3434 | switch (errno(@field(system, symbol_name)(clk_id, res))) { |
| 3457 | 0 => return, | 3435 | 0 => return, |
| 3458 | EFAULT => unreachable, | 3436 | EFAULT => unreachable, |
| 3459 | EINVAL => return error.UnsupportedClock, | 3437 | EINVAL => return error.UnsupportedClock, |
| ... | @@ -3519,21 +3497,12 @@ pub const SigaltstackError = error{ | ... | @@ -3519,21 +3497,12 @@ pub const SigaltstackError = error{ |
| 3519 | } || UnexpectedError; | 3497 | } || UnexpectedError; |
| 3520 | | 3498 | |
| 3521 | pub fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) SigaltstackError!void { | 3499 | pub fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) SigaltstackError!void { |
| 3522 | if (builtin.os.tag == .windows or builtin.os.tag == .uefi or builtin.os.tag == .wasi) | 3500 | const symbol_name = if (std.Target.current.os.tag == .netbsd) |
| 3523 | @compileError("std.os.sigaltstack not available for this target"); | 3501 | "__sigaltstack14" |
| 3524 | | 3502 | else |
| 3525 | if (std.Target.current.os.tag == .netbsd) { | 3503 | "sigaltstack"; |
| 3526 | switch (errno(system.__sigaltstack14(ss, old_ss))) { | | |
| 3527 | 0 => return, | | |
| 3528 | EFAULT => unreachable, | | |
| 3529 | EINVAL => unreachable, | | |
| 3530 | ENOMEM => return error.SizeTooSmall, | | |
| 3531 | EPERM => return error.PermissionDenied, | | |
| 3532 | else => |err| return unexpectedErrno(err), | | |
| 3533 | } | | |
| 3534 | } | | |
| 3535 | | 3504 | |
| 3536 | switch (errno(system.sigaltstack(ss, old_ss))) { | 3505 | switch (errno(@field(system, symbol_name)(ss, old_ss))) { |
| 3537 | 0 => return, | 3506 | 0 => return, |
| 3538 | EFAULT => unreachable, | 3507 | EFAULT => unreachable, |
| 3539 | EINVAL => unreachable, | 3508 | EINVAL => unreachable, |