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