| author | |
| committer | |
| log | 27344464edea0b6acf4dfc78d71700d67a3f3968 |
| tree | cc6c77072ce3625dc4f1d0c7848e7d10f17149af |
| parent | 2f21c8f5ba2e73c1a674b481fd2a8ce87726c14c |
4 files changed, 64 insertions(+), 6 deletions(-)
lib/std/c/netbsd.zig+9| ... | ... | @@ -1,4 +1,6 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = std.builtin; | |
| 3 | ||
| 2 | 4 | usingnamespace std.c; |
| 3 | 5 | |
| 4 | 6 | extern "c" fn __errno() *c_int; |
| ... | ... | @@ -7,6 +9,13 @@ pub const _errno = __errno; |
| 7 | 9 | pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize; |
| 8 | 10 | pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; |
| 9 | 11 | |
| 12 | pub const dl_iterate_phdr_callback = extern fn (info: *dl_phdr_info, size: usize, data: ?*c_void) c_int; | |
| 13 | pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int; | |
| 14 | ||
| 15 | pub extern "c" fn __fstat50(fd: fd_t, buf: *Stat) c_int; | |
| 16 | pub extern "c" fn __clock_gettime50(clk_id: c_int, tp: *timespec) c_int; | |
| 17 | pub extern "c" fn __clock_getres50(clk_id: c_int, tp: *timespec) c_int; | |
| 18 | ||
| 10 | 19 | pub const pthread_mutex_t = extern struct { |
| 11 | 20 | ptm_magic: c_uint = 0x33330003, |
| 12 | 21 | ptm_errorcheck: padded_spin_t = 0, |
lib/std/debug.zig+2| ... | ... | @@ -654,6 +654,8 @@ pub fn openSelfDebugInfo(allocator: *mem.Allocator) anyerror!DebugInfo { |
| 654 | 654 | switch (builtin.os.tag) { |
| 655 | 655 | .linux, |
| 656 | 656 | .freebsd, |
| 657 | .netbsd, | |
| 658 | .dragonfly, | |
| 657 | 659 | .macosx, |
| 658 | 660 | .windows, |
| 659 | 661 | => return DebugInfo.init(allocator), |
lib/std/os.zig+30| ... | ... | @@ -2542,6 +2542,17 @@ pub fn fstat(fd: fd_t) FStatError!Stat { |
| 2542 | 2542 | } |
| 2543 | 2543 | } |
| 2544 | 2544 | |
| 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 | } | |
| 2555 | ||
| 2545 | 2556 | switch (errno(system.fstat(fd, &stat))) { |
| 2546 | 2557 | 0 => return stat, |
| 2547 | 2558 | EINVAL => unreachable, |
| ... | ... | @@ -3401,6 +3412,16 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void { |
| 3401 | 3412 | } |
| 3402 | 3413 | return; |
| 3403 | 3414 | } |
| 3415 | ||
| 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 | } | |
| 3424 | ||
| 3404 | 3425 | switch (errno(system.clock_gettime(clk_id, tp))) { |
| 3405 | 3426 | 0 => return, |
| 3406 | 3427 | EFAULT => unreachable, |
| ... | ... | @@ -3423,6 +3444,15 @@ pub fn clock_getres(clk_id: i32, res: *timespec) ClockGetTimeError!void { |
| 3423 | 3444 | return; |
| 3424 | 3445 | } |
| 3425 | 3446 | |
| 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 | } | |
| 3455 | ||
| 3426 | 3456 | switch (errno(system.clock_getres(clk_id, res))) { |
| 3427 | 3457 | 0 => return, |
| 3428 | 3458 | EFAULT => unreachable, |
lib/std/os/bits/netbsd.zig+23-6| ... | ... | @@ -1,9 +1,12 @@ |
| 1 | 1 | const std = @import("../../std.zig"); |
| 2 | 2 | const maxInt = std.math.maxInt; |
| 3 | 3 | |
| 4 | pub const fd_t = c_int; | |
| 5 | pub const pid_t = c_int; | |
| 6 | pub const mode_t = c_uint; | |
| 4 | pub const fd_t = i32; | |
| 5 | pub const pid_t = i32; | |
| 6 | pub const mode_t = u32; | |
| 7 | pub const ino_t = u64; | |
| 8 | pub const off_t = i64; | |
| 9 | pub const socklen_t = u32; | |
| 7 | 10 | |
| 8 | 11 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. |
| 9 | 12 | pub const Kevent = extern struct { |
| ... | ... | @@ -68,9 +71,6 @@ pub const msghdr_const = extern struct { |
| 68 | 71 | msg_flags: i32, |
| 69 | 72 | }; |
| 70 | 73 | |
| 71 | pub const off_t = i64; | |
| 72 | pub const ino_t = u64; | |
| 73 | ||
| 74 | 74 | /// Renamed to Stat to not conflict with the stat function. |
| 75 | 75 | /// atime, mtime, and ctime have functions to return `timespec`, |
| 76 | 76 | /// because although this is a POSIX API, the layout and names of |
| ... | ... | @@ -816,6 +816,23 @@ pub fn S_IWHT(m: u32) bool { |
| 816 | 816 | return m & S_IFMT == S_IFWHT; |
| 817 | 817 | } |
| 818 | 818 | |
| 819 | /// Magic value that specify the use of the current working directory | |
| 820 | /// to determine the target of relative file paths in the openat() and | |
| 821 | /// similar syscalls. | |
| 822 | pub const AT_FDCWD = -100; | |
| 823 | ||
| 824 | /// Check access using effective user and group ID | |
| 825 | pub const AT_EACCESS = 0x0100; | |
| 826 | ||
| 827 | /// Do not follow symbolic links | |
| 828 | pub const AT_SYMLINK_NOFOLLOW = 0x0200; | |
| 829 | ||
| 830 | /// Follow symbolic link | |
| 831 | pub const AT_SYMLINK_FOLLOW = 0x0400; | |
| 832 | ||
| 833 | /// Remove directory instead of file | |
| 834 | pub const AT_REMOVEDIR = 0x0800; | |
| 835 | ||
| 819 | 836 | pub const HOST_NAME_MAX = 255; |
| 820 | 837 | |
| 821 | 838 | /// dummy for IP |