authorgravatar for git@aiotter.comaiotter <git@aiotter.com> 2022-05-06 23:52:21+09:00
committergravatar for git@aiotter.comaiotter <git@aiotter.com> 2022-05-07 00:02:15+09:00
logad7f725dbacb8144bdff7f0ce3bcfaf47725a4bc
treee39c2fb51f4fcb8f41398ed55a66564438d5c78d
parent83d837813999b73771a0e9623ed1c6c5339e4f4c

std.c: Move Darwin-unspecific functions from std/c/darwin.zig to std/c.zig


2 files changed, 17 insertions(+), 23 deletions(-)

lib/std/c.zig+17-10
...@@ -70,26 +70,33 @@ pub usingnamespace switch (builtin.os.tag) {...@@ -70,26 +70,33 @@ pub usingnamespace switch (builtin.os.tag) {
70 pub extern "c" fn closedir(dp: *DIR) c_int;70 pub extern "c" fn closedir(dp: *DIR) c_int;
71 pub extern "c" fn telldir(dp: *DIR) c_long;71 pub extern "c" fn telldir(dp: *DIR) c_long;
72 pub extern "c" fn seekdir(dp: *DIR, loc: c_long) void;72 pub extern "c" fn seekdir(dp: *DIR, loc: c_long) void;
73 },
74};
7573
76pub usingnamespace switch (builtin.os.tag) {
77 .netbsd, .macos, .ios, .watchos, .tvos, .windows => struct {},
78 else => struct {
79 pub extern "c" fn clock_getres(clk_id: c_int, tp: *c.timespec) c_int;
80 pub extern "c" fn clock_gettime(clk_id: c_int, tp: *c.timespec) c_int;74 pub extern "c" fn clock_gettime(clk_id: c_int, tp: *c.timespec) c_int;
81 pub extern "c" fn fstat(fd: c.fd_t, buf: *c.Stat) c_int;75 pub extern "c" fn clock_getres(clk_id: c_int, tp: *c.timespec) c_int;
82 pub extern "c" fn getrusage(who: c_int, usage: *c.rusage) c_int;
83 pub extern "c" fn gettimeofday(noalias tv: ?*c.timeval, noalias tz: ?*c.timezone) c_int;76 pub extern "c" fn gettimeofday(noalias tv: ?*c.timeval, noalias tz: ?*c.timezone) c_int;
84 pub extern "c" fn nanosleep(rqtp: *const c.timespec, rmtp: ?*c.timespec) c_int;77 pub extern "c" fn nanosleep(rqtp: *const c.timespec, rmtp: ?*c.timespec) c_int;
78
79 pub extern "c" fn getrusage(who: c_int, usage: *c.rusage) c_int;
80
85 pub extern "c" fn sched_yield() c_int;81 pub extern "c" fn sched_yield() c_int;
82
86 pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const c.Sigaction, noalias oact: ?*c.Sigaction) c_int;83 pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const c.Sigaction, noalias oact: ?*c.Sigaction) c_int;
87 pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const c.sigset_t, noalias oset: ?*c.sigset_t) c_int;84 pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const c.sigset_t, noalias oset: ?*c.sigset_t) c_int;
85 pub extern "c" fn sigfillset(set: ?*c.sigset_t) void;
86 pub extern "c" fn sigwait(set: ?*c.sigset_t, sig: ?*c_int) c_int;
87
88 pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;88 pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
89
89 pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *c.Stat) c_int;90 pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *c.Stat) c_int;
90 pub extern "c" fn sigfillset(set: ?*c.sigset_t) void;91
91 pub extern "c" fn alarm(seconds: c_uint) c_uint;92 pub extern "c" fn alarm(seconds: c_uint) c_uint;
92 pub extern "c" fn sigwait(set: ?*c.sigset_t, sig: ?*c_int) c_int;93 },
94};
95
96pub usingnamespace switch (builtin.os.tag) {
97 .netbsd, .macos, .ios, .watchos, .tvos, .windows => struct {},
98 else => struct {
99 pub extern "c" fn fstat(fd: c.fd_t, buf: *c.Stat) c_int;
93 pub extern "c" fn readdir(dp: *c.DIR) ?*c.dirent;100 pub extern "c" fn readdir(dp: *c.DIR) ?*c.dirent;
94 },101 },
95};102};
lib/std/c/darwin.zig-13
...@@ -700,19 +700,6 @@ pub extern "c" fn os_unfair_lock_assert_not_owner(o: os_unfair_lock_t) void;...@@ -700,19 +700,6 @@ pub extern "c" fn os_unfair_lock_assert_not_owner(o: os_unfair_lock_t) void;
700700
701// XXX: close -> close$NOCANCEL701// XXX: close -> close$NOCANCEL
702// XXX: getdirentries -> _getdirentries64702// XXX: getdirentries -> _getdirentries64
703pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int;
704pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int;
705pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int;
706pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
707pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;
708pub extern "c" fn sched_yield() c_int;
709pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
710pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
711pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
712pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int;
713pub extern "c" fn sigfillset(set: ?*sigset_t) void;
714pub extern "c" fn alarm(seconds: c_uint) c_uint;
715pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int;
716703
717// See: https://opensource.apple.com/source/xnu/xnu-6153.141.1/bsd/sys/_types.h.auto.html704// See: https://opensource.apple.com/source/xnu/xnu-6153.141.1/bsd/sys/_types.h.auto.html
718// TODO: audit mode_t/pid_t, should likely be u16/i32705// TODO: audit mode_t/pid_t, should likely be u16/i32