authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2024-03-15 02:28:50-04:00
committergravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2024-03-15 02:28:50-04:00
logd7cf25f5ca40e5cbcd739911e773769a62c2abe1
treec5d52b3729d131e8d1f1aa502ebf283ce7fcae54
parent5ce40e61c6f5c05925aa5116cc6c61fbae8a6263
signaturelock-open Commit is signed but in an unrecognized format.

bsd: debitrot std.c

- follow-up to f4bf061d8a8 - updated std.fs.Dir to use properly named symbols

4 files changed, 87 insertions(+), 58 deletions(-)

lib/std/c.zig+85-17
...@@ -1502,25 +1502,19 @@ pub extern "c" fn closedir(dp: *DIR) c_int;...@@ -1502,25 +1502,19 @@ pub extern "c" fn closedir(dp: *DIR) c_int;
1502pub extern "c" fn telldir(dp: *DIR) c_long;1502pub extern "c" fn telldir(dp: *DIR) c_long;
1503pub extern "c" fn seekdir(dp: *DIR, loc: c_long) void;1503pub extern "c" fn seekdir(dp: *DIR, loc: c_long) void;
15041504
1505pub extern "c" fn clock_gettime(clk_id: c_int, tp: *c.timespec) c_int;
1506pub extern "c" fn clock_getres(clk_id: c_int, tp: *c.timespec) c_int;
1507pub extern "c" fn gettimeofday(noalias tv: ?*c.timeval, noalias tz: ?*c.timezone) c_int;
1508pub extern "c" fn nanosleep(rqtp: *const c.timespec, rmtp: ?*c.timespec) c_int;
1509
1510pub extern "c" fn getrusage(who: c_int, usage: *c.rusage) c_int;
1511
1512pub extern "c" fn sched_yield() c_int;
1513
1514pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const c.Sigaction, noalias oact: ?*c.Sigaction) c_int;
1515pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const c.sigset_t, noalias oset: ?*c.sigset_t) c_int;
1516pub extern "c" fn sigfillset(set: ?*c.sigset_t) void;
1517pub extern "c" fn sigwait(set: ?*c.sigset_t, sig: ?*c_int) c_int;1505pub extern "c" fn sigwait(set: ?*c.sigset_t, sig: ?*c_int) c_int;
15181506
1519pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
1520
1521pub extern "c" fn alarm(seconds: c_uint) c_uint;1507pub extern "c" fn alarm(seconds: c_uint) c_uint;
15221508
1523pub extern "c" fn msync(addr: *align(page_size) const anyopaque, len: usize, flags: c_int) c_int;1509pub const clock_getres = switch (native_os) {
1510 .netbsd => private.__clock_getres50,
1511 else => private.clock_getres,
1512};
1513
1514pub const clock_gettime = switch (native_os) {
1515 .netbsd => private.__clock_gettime50,
1516 else => private.clock_gettime,
1517};
15241518
1525pub const fstat = switch (native_os) {1519pub const fstat = switch (native_os) {
1526 .macos => switch (native_arch) {1520 .macos => switch (native_arch) {
...@@ -1539,6 +1533,31 @@ pub const fstatat = switch (native_os) {...@@ -1539,6 +1533,31 @@ pub const fstatat = switch (native_os) {
1539 else => private.fstatat,1533 else => private.fstatat,
1540};1534};
15411535
1536pub const getdirentries = switch (native_os) {
1537 .macos, .ios, .tvos, .watchos => private.__getdirentries64,
1538 else => private.getdirentries,
1539};
1540
1541pub const getrusage = switch (native_os) {
1542 .netbsd => private.__getrusage50,
1543 else => private.getrusage,
1544};
1545
1546pub const gettimeofday = switch (native_os) {
1547 .netbsd => private.__gettimeofday50,
1548 else => private.gettimeofday,
1549};
1550
1551pub const msync = switch (native_os) {
1552 .netbsd => private.__msync13,
1553 else => private.msync,
1554};
1555
1556pub const nanosleep = switch (native_os) {
1557 .netbsd => private.__nanosleep50,
1558 else => private.nanosleep,
1559};
1560
1542pub const readdir = switch (native_os) {1561pub const readdir = switch (native_os) {
1543 .macos => switch (native_arch) {1562 .macos => switch (native_arch) {
1544 .x86_64 => private.@"readdir$INODE64",1563 .x86_64 => private.@"readdir$INODE64",
...@@ -1549,10 +1568,35 @@ pub const readdir = switch (native_os) {...@@ -1549,10 +1568,35 @@ pub const readdir = switch (native_os) {
1549};1568};
15501569
1551pub const realpath = switch (native_os) {1570pub const realpath = switch (native_os) {
1552 .macos, .ios, .watchos, .tvos => private.@"realpath$DARWIN_EXTSN",1571 .macos, .ios, .tvos, .watchos => private.@"realpath$DARWIN_EXTSN",
1553 else => private.realpath,1572 else => private.realpath,
1554};1573};
15551574
1575pub const sched_yield = switch (native_os) {
1576 .netbsd => private.__libc_thr_yield,
1577 else => private.sched_yield,
1578};
1579
1580pub const sigaction = switch (native_os) {
1581 .netbsd => private.__sigaction14,
1582 else => private.sigaction,
1583};
1584
1585pub const sigfillset = switch (native_os) {
1586 .netbsd => private.__sigfillset14,
1587 else => private.sigfillset,
1588};
1589
1590pub const sigprocmask = switch (native_os) {
1591 .netbsd => private.__sigprocmask14,
1592 else => private.sigprocmask,
1593};
1594
1595pub const socket = switch (native_os) {
1596 .netbsd => private.__socket30,
1597 else => private.socket,
1598};
1599
1556pub const stat = switch (native_os) {1600pub const stat = switch (native_os) {
1557 .macos => switch (native_arch) {1601 .macos => switch (native_arch) {
1558 .x86_64 => private.@"stat$INODE64",1602 .x86_64 => private.@"stat$INODE64",
...@@ -1680,7 +1724,6 @@ pub extern "c" fn recvfrom(...@@ -1680,7 +1724,6 @@ pub extern "c" fn recvfrom(
1680pub extern "c" fn recvmsg(sockfd: c.fd_t, msg: *c.msghdr, flags: u32) isize;1724pub extern "c" fn recvmsg(sockfd: c.fd_t, msg: *c.msghdr, flags: u32) isize;
16811725
1682pub extern "c" fn kill(pid: c.pid_t, sig: c_int) c_int;1726pub extern "c" fn kill(pid: c.pid_t, sig: c_int) c_int;
1683pub extern "c" fn getdirentries(fd: c.fd_t, buf_ptr: [*]u8, nbytes: usize, basep: *i64) isize;
16841727
1685pub extern "c" fn setuid(uid: c.uid_t) c_int;1728pub extern "c" fn setuid(uid: c.uid_t) c_int;
1686pub extern "c" fn setgid(gid: c.gid_t) c_int;1729pub extern "c" fn setgid(gid: c.gid_t) c_int;
...@@ -1878,10 +1921,22 @@ else...@@ -1878,10 +1921,22 @@ else
1878 };1921 };
18791922
1880const private = struct {1923const private = struct {
1924 extern "c" fn clock_getres(clk_id: c_int, tp: *c.timespec) c_int;
1925 extern "c" fn clock_gettime(clk_id: c_int, tp: *c.timespec) c_int;
1881 extern "c" fn fstat(fd: c.fd_t, buf: *c.Stat) c_int;1926 extern "c" fn fstat(fd: c.fd_t, buf: *c.Stat) c_int;
1882 extern "c" fn fstatat(dirfd: c.fd_t, path: [*:0]const u8, buf: *c.Stat, flag: u32) c_int;1927 extern "c" fn fstatat(dirfd: c.fd_t, path: [*:0]const u8, buf: *c.Stat, flag: u32) c_int;
1928 extern "c" fn getdirentries(fd: c.fd_t, buf_ptr: [*]u8, nbytes: usize, basep: *i64) isize;
1929 extern "c" fn getrusage(who: c_int, usage: *c.rusage) c_int;
1930 extern "c" fn gettimeofday(noalias tv: ?*c.timeval, noalias tz: ?*c.timezone) c_int;
1931 extern "c" fn msync(addr: *align(page_size) const anyopaque, len: usize, flags: c_int) c_int;
1932 extern "c" fn nanosleep(rqtp: *const c.timespec, rmtp: ?*c.timespec) c_int;
1883 extern "c" fn readdir(dir: *c.DIR) ?*c.dirent;1933 extern "c" fn readdir(dir: *c.DIR) ?*c.dirent;
1884 extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;1934 extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;
1935 extern "c" fn sched_yield() c_int;
1936 extern "c" fn sigaction(sig: c_int, noalias act: ?*const c.Sigaction, noalias oact: ?*c.Sigaction) c_int;
1937 extern "c" fn sigfillset(set: ?*c.sigset_t) void;
1938 extern "c" fn sigprocmask(how: c_int, noalias set: ?*const c.sigset_t, noalias oset: ?*c.sigset_t) c_int;
1939 extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
1885 extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *c.Stat) c_int;1940 extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *c.Stat) c_int;
18861941
1887 /// macos modernized symbols.1942 /// macos modernized symbols.
...@@ -1894,7 +1949,20 @@ const private = struct {...@@ -1894,7 +1949,20 @@ const private = struct {
18941949
1895 /// macos modernized symbols.1950 /// macos modernized symbols.
1896 extern "c" fn @"realpath$DARWIN_EXTSN"(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;1951 extern "c" fn @"realpath$DARWIN_EXTSN"(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;
1952 extern "c" fn __getdirentries64(fd: c.fd_t, buf_ptr: [*]u8, buf_len: usize, basep: *i64) isize;
18971953
1898 /// netbsd modernized symbols.1954 /// netbsd modernized symbols.
1955 extern "c" fn __clock_getres50(clk_id: c_int, tp: *c.timespec) c_int;
1956 extern "c" fn __clock_gettime50(clk_id: c_int, tp: *c.timespec) c_int;
1899 extern "c" fn __fstat50(fd: c.fd_t, buf: *c.Stat) c_int;1957 extern "c" fn __fstat50(fd: c.fd_t, buf: *c.Stat) c_int;
1958 extern "c" fn __getrusage50(who: c_int, usage: *c.rusage) c_int;
1959 extern "c" fn __gettimeofday50(noalias tv: ?*c.timeval, noalias tz: ?*c.timezone) c_int;
1960 extern "c" fn __libc_thr_yield() c_int;
1961 extern "c" fn __msync13(addr: *align(std.mem.page_size) const anyopaque, len: usize, flags: c_int) c_int;
1962 extern "c" fn __nanosleep50(rqtp: *const c.timespec, rmtp: ?*c.timespec) c_int;
1963 extern "c" fn __sigaction14(sig: c_int, noalias act: ?*const c.Sigaction, noalias oact: ?*c.Sigaction) c_int;
1964 extern "c" fn __sigfillset14(set: ?*c.sigset_t) void;
1965 extern "c" fn __sigprocmask14(how: c_int, noalias set: ?*const c.sigset_t, noalias oset: ?*c.sigset_t) c_int;
1966 extern "c" fn __socket30(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
1967 extern "c" fn __stat50(path: [*:0]const u8, buf: *c.Stat) c_int;
1900};1968};
lib/std/c/darwin.zig-3
...@@ -924,9 +924,6 @@ pub extern "c" fn os_unfair_lock_trylock(o: os_unfair_lock_t) bool;...@@ -924,9 +924,6 @@ pub extern "c" fn os_unfair_lock_trylock(o: os_unfair_lock_t) bool;
924pub extern "c" fn os_unfair_lock_assert_owner(o: os_unfair_lock_t) void;924pub extern "c" fn os_unfair_lock_assert_owner(o: os_unfair_lock_t) void;
925pub extern "c" fn os_unfair_lock_assert_not_owner(o: os_unfair_lock_t) void;925pub extern "c" fn os_unfair_lock_assert_not_owner(o: os_unfair_lock_t) void;
926926
927// XXX: close -> close$NOCANCEL
928// XXX: getdirentries -> _getdirentries64
929
930// See: https://opensource.apple.com/source/xnu/xnu-6153.141.1/bsd/sys/_types.h.auto.html927// See: https://opensource.apple.com/source/xnu/xnu-6153.141.1/bsd/sys/_types.h.auto.html
931// TODO: audit mode_t/pid_t, should likely be u16/i32928// TODO: audit mode_t/pid_t, should likely be u16/i32
932pub const blkcnt_t = i64;929pub const blkcnt_t = i64;
lib/std/c/netbsd.zig-33
...@@ -18,47 +18,14 @@ pub extern "c" fn _lwp_self() lwpid_t;...@@ -18,47 +18,14 @@ pub extern "c" fn _lwp_self() lwpid_t;
18pub extern "c" fn pipe2(fds: *[2]fd_t, flags: std.c.O) c_int;18pub extern "c" fn pipe2(fds: *[2]fd_t, flags: std.c.O) c_int;
19pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void;19pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void;
2020
21pub extern "c" fn __stat50(path: [*:0]const u8, buf: *Stat) c_int;
22pub const stat = __stat50;
23
24pub extern "c" fn __clock_gettime50(clk_id: c_int, tp: *timespec) c_int;
25pub const clock_gettime = __clock_gettime50;
26
27pub extern "c" fn __clock_getres50(clk_id: c_int, tp: *timespec) c_int;
28pub const clock_getres = __clock_getres50;
29
30pub extern "c" fn __getdents30(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int;21pub extern "c" fn __getdents30(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int;
31pub const getdents = __getdents30;22pub const getdents = __getdents30;
3223
33pub extern "c" fn __sigaltstack14(ss: ?*stack_t, old_ss: ?*stack_t) c_int;24pub extern "c" fn __sigaltstack14(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
34pub const sigaltstack = __sigaltstack14;25pub const sigaltstack = __sigaltstack14;
3526
36pub extern "c" fn __nanosleep50(rqtp: *const timespec, rmtp: ?*timespec) c_int;
37pub const nanosleep = __nanosleep50;
38
39pub extern "c" fn __sigaction14(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
40pub const sigaction = __sigaction14;
41
42pub extern "c" fn __sigprocmask14(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
43pub const sigprocmask = __sigaction14;
44
45pub extern "c" fn __socket30(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
46pub const socket = __socket30;
47
48pub extern "c" fn __gettimeofday50(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
49pub const gettimeofday = __gettimeofday50;
50
51pub extern "c" fn __getrusage50(who: c_int, usage: *rusage) c_int;
52pub const getrusage = __getrusage50;
53
54pub extern "c" fn __libc_thr_yield() c_int;
55pub const sched_yield = __libc_thr_yield;
56
57pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int;27pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int;
5828
59pub extern "c" fn __msync13(addr: *align(std.mem.page_size) const anyopaque, len: usize, flags: c_int) c_int;
60pub const msync = __msync13;
61
62pub const pthread_spin_t = switch (builtin.cpu.arch) {29pub const pthread_spin_t = switch (builtin.cpu.arch) {
63 .aarch64, .aarch64_be, .aarch64_32 => u8,30 .aarch64, .aarch64_be, .aarch64_32 => u8,
64 .mips, .mipsel, .mips64, .mips64el => u32,31 .mips, .mipsel, .mips64, .mips64el => u32,
lib/std/fs/Dir.zig+2-5
...@@ -49,7 +49,7 @@ pub const Iterator = switch (builtin.os.tag) {...@@ -49,7 +49,7 @@ pub const Iterator = switch (builtin.os.tag) {
49 posix.lseek_SET(self.dir.fd, 0) catch unreachable; // EBADF here likely means that the Dir was not opened with iteration permissions49 posix.lseek_SET(self.dir.fd, 0) catch unreachable; // EBADF here likely means that the Dir was not opened with iteration permissions
50 self.first_iter = false;50 self.first_iter = false;
51 }51 }
52 const rc = posix.system.__getdirentries64(52 const rc = posix.system.getdirentries(
53 self.dir.fd,53 self.dir.fd,
54 &self.buf,54 &self.buf,
55 self.buf.len,55 self.buf.len,
...@@ -161,10 +161,7 @@ pub const Iterator = switch (builtin.os.tag) {...@@ -161,10 +161,7 @@ pub const Iterator = switch (builtin.os.tag) {
161 posix.lseek_SET(self.dir.fd, 0) catch unreachable; // EBADF here likely means that the Dir was not opened with iteration permissions161 posix.lseek_SET(self.dir.fd, 0) catch unreachable; // EBADF here likely means that the Dir was not opened with iteration permissions
162 self.first_iter = false;162 self.first_iter = false;
163 }163 }
164 const rc = if (builtin.os.tag == .netbsd)164 const rc = posix.system.getdents(self.dir.fd, &self.buf, self.buf.len);
165 posix.system.__getdents30(self.dir.fd, &self.buf, self.buf.len)
166 else
167 posix.system.getdents(self.dir.fd, &self.buf, self.buf.len);
168 switch (posix.errno(rc)) {165 switch (posix.errno(rc)) {
169 .SUCCESS => {},166 .SUCCESS => {},
170 .BADF => unreachable, // Dir is invalid or was opened without iteration ability167 .BADF => unreachable, // Dir is invalid or was opened without iteration ability