| ... | @@ -73,7 +73,6 @@ pub extern "c" fn abort() noreturn; | ... | @@ -73,7 +73,6 @@ pub extern "c" fn abort() noreturn; |
| 73 | pub extern "c" fn exit(code: c_int) noreturn; | 73 | pub extern "c" fn exit(code: c_int) noreturn; |
| 74 | pub extern "c" fn isatty(fd: fd_t) c_int; | 74 | pub extern "c" fn isatty(fd: fd_t) c_int; |
| 75 | pub extern "c" fn close(fd: fd_t) c_int; | 75 | pub extern "c" fn close(fd: fd_t) c_int; |
| 76 | pub extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int; | | |
| 77 | pub extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *Stat, flags: u32) c_int; | 76 | pub extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *Stat, flags: u32) c_int; |
| 78 | pub extern "c" fn lseek(fd: fd_t, offset: off_t, whence: c_int) off_t; | 77 | pub extern "c" fn lseek(fd: fd_t, offset: off_t, whence: c_int) off_t; |
| 79 | pub extern "c" fn open(path: [*:0]const u8, oflag: c_uint, ...) c_int; | 78 | pub extern "c" fn open(path: [*:0]const u8, oflag: c_uint, ...) c_int; |
| ... | @@ -86,7 +85,6 @@ pub extern "c" fn pread(fd: fd_t, buf: [*]u8, nbyte: usize, offset: u64) isize; | ... | @@ -86,7 +85,6 @@ pub extern "c" fn pread(fd: fd_t, buf: [*]u8, nbyte: usize, offset: u64) isize; |
| 86 | pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: u64) isize; | 85 | pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: u64) isize; |
| 87 | pub extern "c" fn writev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint) isize; | 86 | pub extern "c" fn writev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint) isize; |
| 88 | pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: u64) isize; | 87 | pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: u64) isize; |
| 89 | pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int; | | |
| 90 | pub extern "c" fn write(fd: fd_t, buf: [*]const u8, nbyte: usize) isize; | 88 | pub extern "c" fn write(fd: fd_t, buf: [*]const u8, nbyte: usize) isize; |
| 91 | pub extern "c" fn pwrite(fd: fd_t, buf: [*]const u8, nbyte: usize, offset: u64) isize; | 89 | pub extern "c" fn pwrite(fd: fd_t, buf: [*]const u8, nbyte: usize, offset: u64) isize; |
| 92 | pub extern "c" fn mmap(addr: ?*align(page_size) c_void, len: usize, prot: c_uint, flags: c_uint, fd: fd_t, offset: u64) *c_void; | 90 | pub extern "c" fn mmap(addr: ?*align(page_size) c_void, len: usize, prot: c_uint, flags: c_uint, fd: fd_t, offset: u64) *c_void; |
| ... | @@ -114,15 +112,10 @@ pub extern "c" fn dup2(old_fd: fd_t, new_fd: fd_t) c_int; | ... | @@ -114,15 +112,10 @@ pub extern "c" fn dup2(old_fd: fd_t, new_fd: fd_t) c_int; |
| 114 | pub extern "c" fn readlink(noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize; | 112 | pub extern "c" fn readlink(noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize; |
| 115 | pub extern "c" fn readlinkat(dirfd: fd_t, noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize; | 113 | pub extern "c" fn readlinkat(dirfd: fd_t, noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize; |
| 116 | pub extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8; | 114 | pub extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8; |
| 117 | pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; | | |
| 118 | pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int; | | |
| 119 | pub extern "c" fn sigaction(sig: c_int, noalias act: *const Sigaction, noalias oact: ?*Sigaction) c_int; | | |
| 120 | pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int; | | |
| 121 | pub extern "c" fn setreuid(ruid: c_uint, euid: c_uint) c_int; | 115 | pub extern "c" fn setreuid(ruid: c_uint, euid: c_uint) c_int; |
| 122 | pub extern "c" fn setregid(rgid: c_uint, egid: c_uint) c_int; | 116 | pub extern "c" fn setregid(rgid: c_uint, egid: c_uint) c_int; |
| 123 | pub extern "c" fn rmdir(path: [*:0]const u8) c_int; | 117 | pub extern "c" fn rmdir(path: [*:0]const u8) c_int; |
| 124 | pub extern "c" fn getenv(name: [*:0]const u8) ?[*:0]u8; | 118 | pub extern "c" fn getenv(name: [*:0]const u8) ?[*:0]u8; |
| 125 | pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int; | | |
| 126 | pub extern "c" fn sysctl(name: [*]const c_int, namelen: c_uint, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int; | 119 | pub extern "c" fn sysctl(name: [*]const c_int, namelen: c_uint, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int; |
| 127 | pub extern "c" fn sysctlbyname(name: [*:0]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int; | 120 | pub extern "c" fn sysctlbyname(name: [*:0]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int; |
| 128 | pub extern "c" fn sysctlnametomib(name: [*:0]const u8, mibp: ?*c_int, sizep: ?*usize) c_int; | 121 | pub extern "c" fn sysctlnametomib(name: [*:0]const u8, mibp: ?*c_int, sizep: ?*usize) c_int; |
| ... | @@ -133,7 +126,6 @@ pub extern "c" fn uname(buf: *utsname) c_int; | ... | @@ -133,7 +126,6 @@ pub extern "c" fn uname(buf: *utsname) c_int; |
| 133 | | 126 | |
| 134 | pub extern "c" fn gethostname(name: [*]u8, len: usize) c_int; | 127 | pub extern "c" fn gethostname(name: [*]u8, len: usize) c_int; |
| 135 | pub extern "c" fn bind(socket: fd_t, address: ?*const sockaddr, address_len: socklen_t) c_int; | 128 | pub extern "c" fn bind(socket: fd_t, address: ?*const sockaddr, address_len: socklen_t) c_int; |
| 136 | pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int; | | |
| 137 | pub extern "c" fn socketpair(domain: c_uint, sock_type: c_uint, protocol: c_uint, sv: *[2]fd_t) c_int; | 129 | pub extern "c" fn socketpair(domain: c_uint, sock_type: c_uint, protocol: c_uint, sv: *[2]fd_t) c_int; |
| 138 | pub extern "c" fn listen(sockfd: fd_t, backlog: c_uint) c_int; | 130 | pub extern "c" fn listen(sockfd: fd_t, backlog: c_uint) c_int; |
| 139 | pub extern "c" fn getsockname(sockfd: fd_t, noalias addr: *sockaddr, noalias addrlen: *socklen_t) c_int; | 131 | pub extern "c" fn getsockname(sockfd: fd_t, noalias addr: *sockaddr, noalias addrlen: *socklen_t) c_int; |
| ... | @@ -161,12 +153,55 @@ pub extern fn recvfrom( | ... | @@ -161,12 +153,55 @@ pub extern fn recvfrom( |
| 161 | noalias addrlen: ?*socklen_t, | 153 | noalias addrlen: ?*socklen_t, |
| 162 | ) isize; | 154 | ) isize; |
| 163 | | 155 | |
| | 156 | pub usingnamespace switch (builtin.os.tag) { |
| | 157 | .netbsd => struct { |
| | 158 | pub const clock_getres = __clock_getres50; |
| | 159 | pub const clock_gettime = __clock_gettime50; |
| | 160 | pub const fstat = __fstat50; |
| | 161 | pub const getdents = __getdents30; |
| | 162 | pub const getrusage = __getrusage50; |
| | 163 | pub const gettimeofday = __gettimeofday50; |
| | 164 | pub const nanosleep = __nanosleep50; |
| | 165 | pub const sched_yield = __libc_thr_yield; |
| | 166 | pub const sigaction = __sigaction14; |
| | 167 | pub const sigaltstack = __sigaltstack14; |
| | 168 | pub const sigprocmask = __sigprocmask14; |
| | 169 | pub const stat = __stat50; |
| | 170 | }, |
| | 171 | .macosx, .ios, .watchos, .tvos => struct { |
| | 172 | // XXX: close -> close$NOCANCEL |
| | 173 | // XXX: getdirentries -> _getdirentries64 |
| | 174 | pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int; |
| | 175 | pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int; |
| | 176 | pub const fstat = @"fstat$INODE64"; |
| | 177 | pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int; |
| | 178 | pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int; |
| | 179 | pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int; |
| | 180 | pub extern "c" fn sched_yield() c_int; |
| | 181 | pub extern "c" fn sigaction(sig: c_int, noalias act: *const Sigaction, noalias oact: ?*Sigaction) c_int; |
| | 182 | pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; |
| | 183 | pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int; |
| | 184 | pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int; |
| | 185 | }, |
| | 186 | else => struct { |
| | 187 | pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int; |
| | 188 | pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int; |
| | 189 | pub extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int; |
| | 190 | pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int; |
| | 191 | pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int; |
| | 192 | pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int; |
| | 193 | pub extern "c" fn sched_yield() c_int; |
| | 194 | pub extern "c" fn sigaction(sig: c_int, noalias act: *const Sigaction, noalias oact: ?*Sigaction) c_int; |
| | 195 | pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; |
| | 196 | pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int; |
| | 197 | pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int; |
| | 198 | }, |
| | 199 | }; |
| | 200 | |
| 164 | pub extern "c" fn kill(pid: pid_t, sig: c_int) c_int; | 201 | pub extern "c" fn kill(pid: pid_t, sig: c_int) c_int; |
| 165 | pub extern "c" fn getdirentries(fd: fd_t, buf_ptr: [*]u8, nbytes: usize, basep: *i64) isize; | 202 | pub extern "c" fn getdirentries(fd: fd_t, buf_ptr: [*]u8, nbytes: usize, basep: *i64) isize; |
| 166 | pub extern "c" fn setgid(ruid: c_uint, euid: c_uint) c_int; | 203 | pub extern "c" fn setgid(ruid: c_uint, euid: c_uint) c_int; |
| 167 | pub extern "c" fn setuid(uid: c_uint) c_int; | 204 | pub extern "c" fn setuid(uid: c_uint) c_int; |
| 168 | pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int; | | |
| 169 | pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int; | | |
| 170 | | 205 | |
| 171 | pub extern "c" fn aligned_alloc(alignment: usize, size: usize) ?*c_void; | 206 | pub extern "c" fn aligned_alloc(alignment: usize, size: usize) ?*c_void; |
| 172 | pub extern "c" fn malloc(usize) ?*c_void; | 207 | pub extern "c" fn malloc(usize) ?*c_void; |
| ... | @@ -229,8 +264,6 @@ pub extern "c" fn dn_expand( | ... | @@ -229,8 +264,6 @@ pub extern "c" fn dn_expand( |
| 229 | length: c_int, | 264 | length: c_int, |
| 230 | ) c_int; | 265 | ) c_int; |
| 231 | | 266 | |
| 232 | pub extern "c" fn sched_yield() c_int; | | |
| 233 | | | |
| 234 | pub const PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{}; | 267 | pub const PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{}; |
| 235 | pub extern "c" fn pthread_mutex_lock(mutex: *pthread_mutex_t) c_int; | 268 | pub extern "c" fn pthread_mutex_lock(mutex: *pthread_mutex_t) c_int; |
| 236 | pub extern "c" fn pthread_mutex_unlock(mutex: *pthread_mutex_t) c_int; | 269 | pub extern "c" fn pthread_mutex_unlock(mutex: *pthread_mutex_t) c_int; |