const private = struct pub extern "c" fn strdup(s: [*: 0]const c_char) ?[*: 0]c_charpub extern "c" fn _strdup(s: [*: 0]const c_char) ?[*: 0]c_charpub extern "c" fn wcsdup(s: [*: 0]const wchar_t) ?[*: 0]wchar_tpub extern "c" fn _wcsdup(s: [*: 0]const wchar_t) ?[*: 0]wchar_tpub extern "c" fn swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) voidpub extern "c" fn _swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) voidextern "c" fn close(fd: fd_t) c_intextern "c" fn clock_getres(clk_id: clockid_t, tp: *timespec) c_intextern "c" fn clock_gettime(clk_id: clockid_t, tp: *timespec) c_intextern "c" fn copy_file_range(fd_in: fd_t, off_in: ?*i64, fd_out: fd_t, off_out: ?*i64, len: usize, flags: c_uint) isizeextern "c" fn flock(fd: fd_t, operation: c_int) c_intextern "c" fn fork() c_intextern "c" fn fstat(fd: fd_t, buf: *Stat) c_intextern "c" fn fstatat(dirfd: fd_t, path: [*: 0]const u8, buf: *Stat, flag: u32) c_intextern "c" fn getdirentries(fd: fd_t, buf_ptr: [*]u8, nbytes: usize, basep: *i64) isizeextern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) switch(native_os)extern "c" fn getrusage(who: c_int, usage: *rusage) c_intextern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_intextern "c" fn ioctl(fd: fd_t, request: c_int, ...) c_intextern "c" fn msync(addr: *align(page_size) const anyopaque, len: usize, flags: c_int) c_intextern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_intextern "c" fn clock_nanosleep(clockid: clockid_t, flags: TIMER, t: *const timespec, remain: ?*timespec) c_intextern "c" fn pipe2(fds: *[2]fd_t, flags: O) c_intextern "c" fn readdir(dir: *DIR) ?*direntextern "c" fn realpath(noalias file_name: [*: 0]const u8, noalias resolved_name: [*]u8) ?[*: 0]u8extern "c" fn recvmsg(sockfd: fd_t, msg: *msghdr, flags: u32) isizeextern "c" fn sched_yield() c_intextern "c" fn sendfile(out_fd: fd_t, in_fd: fd_t, offset: ?*off_t, count: usize) isizeextern "c" fn sigaction(sig: SIG, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_intextern "c" fn sigdelset(set: ?*sigset_t, signo: SIG) c_intextern "c" fn sigaddset(set: ?*sigset_t, signo: SIG) c_intextern "c" fn sigfillset(set: ?*sigset_t) c_intextern "c" fn sigemptyset(set: ?*sigset_t) c_intextern "c" fn sigismember(set: ?*const sigset_t, signo: SIG) c_intextern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_intextern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_intextern "c" fn socketpair(domain: c_uint, sock_type: c_uint, protocol: c_uint, sv: *[2]fd_t) c_intextern "c" fn sigaltstack(ss: ?*const stack_t, old_ss: ?*stack_t) c_intextern "c" fn sysconf(sc: c_int) c_longextern "c" fn shm_open(name: [*: 0]const u8, flag: c_int, mode: mode_t) c_intextern "c" fn wait4(pid: pid_t, status: ?*c_int, options: c_int, ru: ?*rusage) pid_textern "c" fn pthread_setname_np(thread: pthread_t, name: [*: 0]const u8) c_intextern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isizeextern "c" fn getentropy(buffer: [*]u8, size: usize) c_intextern "c" fn arc4random_buf(buf: [*]u8, len: usize) voidextern "c" fn _msize(?*const anyopaque) usizeextern "c" fn malloc_size(?*const anyopaque) usizeextern "c" fn malloc_usable_size(?*const anyopaque) usizeextern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_intextern "c" fn mlock(addr: *align(page_size) const anyopaque, len: usize) c_intextern "c" fn mlock2(addr: *align(page_size) const anyopaque, len: usize, flags: MLOCK) c_intextern "c" fn munlock(addr: *align(page_size) const anyopaque, len: usize) c_intextern "c" fn mlockall(flags: MCL) c_intextern "c" fn munlockall() c_intextern "c" fn ptrace(request: c_int, pid: pid_t, addr: ?*anyopaque, data: ?*anyopaque) c_longextern "c" fn @"fstat$INODE64"(fd: fd_t, buf: *Stat) c_intextern "c" fn @"fstatat$INODE64"(dirfd: fd_t, path: [*: 0]const u8, buf: *Stat, flag: u32) c_intextern "c" fn @"readdir$INODE64"(dir: *DIR) ?*direntextern "c" fn @"stat$INODE64"(noalias path: [*: 0]const u8, noalias buf: *Stat) c_intextern "c" fn stat(noalias path: [*: 0]const u8, noalias buf: *Stat) c_intextern "c" fn @"realpath$DARWIN_EXTSN"(noalias file_name: [*: 0]const u8, noalias resolved_name: [*]u8) ?[*: 0]u8extern "c" fn __getdirentries64(fd: fd_t, buf_ptr: [*]u8, buf_len: usize, basep: *i64) isizeextern "c" fn pthread_threadid_np(thread: ?pthread_t, thread_id: *u64) c_intextern "c" fn __clock_getres50(clk_id: clockid_t, tp: *timespec) c_intextern "c" fn __clock_gettime50(clk_id: clockid_t, tp: *timespec) c_intextern "c" fn __fstat50(fd: fd_t, buf: *Stat) c_intextern "c" fn __getrusage50(who: c_int, usage: *rusage) c_intextern "c" fn __gettimeofday50(noalias tv: ?*timeval, noalias tz: ?*timezone) c_intextern "c" fn __libc_thr_yield() c_intextern "c" fn __msync13(addr: *align(page_size) const anyopaque, len: usize, flags: c_int) c_intextern "c" fn __nanosleep50(rqtp: *const timespec, rmtp: ?*timespec) c_intextern "c" fn __sigaction14(sig: SIG, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_intextern "c" fn __sigemptyset14(set: ?*sigset_t) c_intextern "c" fn __sigfillset14(set: ?*sigset_t) c_intextern "c" fn __sigprocmask14(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_intextern "c" fn __socket30(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_intextern "c" fn __stat50(path: [*: 0]const u8, buf: *Stat) c_intextern "c" fn __getdents30(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_intextern "c" fn __sigaltstack14(ss: ?*const stack_t, old_ss: ?*stack_t) c_intextern "c" fn __wait450(pid: pid_t, status: ?*c_int, options: c_int, ru: ?*rusage) pid_textern "c" fn __libc_current_sigrtmin() c_intextern "c" fn __libc_current_sigrtmax() c_intextern "c" fn __signal_get_sigrtmin() c_intextern "c" fn __signal_get_sigrtmax() c_intextern "c" fn ___errno() *c_intextern "c" fn __errno() *c_intextern "c" fn __errno_location() *c_intextern "c" fn __error() *c_intextern "c" fn _errno() *c_intfn errnoFromThreadLocal() *c_int11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729const private = struct {
pub extern "c" fn strdup(s: [*:0]const c_char) ?[*:0]c_char;
pub extern "c" fn _strdup(s: [*:0]const c_char) ?[*:0]c_char;
pub extern "c" fn wcsdup(s: [*:0]const wchar_t) ?[*:0]wchar_t;
pub extern "c" fn _wcsdup(s: [*:0]const wchar_t) ?[*:0]wchar_t;
pub extern "c" fn swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) void;
pub extern "c" fn _swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) void;
extern "c" fn close(fd: fd_t) c_int;
extern "c" fn clock_getres(clk_id: clockid_t, tp: *timespec) c_int;
extern "c" fn clock_gettime(clk_id: clockid_t, tp: *timespec) c_int;
extern "c" fn copy_file_range(fd_in: fd_t, off_in: ?*i64, fd_out: fd_t, off_out: ?*i64, len: usize, flags: c_uint) isize;
extern "c" fn flock(fd: fd_t, operation: c_int) c_int;
extern "c" fn fork() c_int;
extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int;
extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, buf: *Stat, flag: u32) c_int;
extern "c" fn getdirentries(fd: fd_t, buf_ptr: [*]u8, nbytes: usize, basep: *i64) isize;
extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) switch (native_os) {
.freebsd => isize,
.illumos => usize,
else => c_int,
};
extern "c" fn getrusage(who: c_int, usage: *rusage) c_int;
extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
extern "c" fn ioctl(fd: fd_t, request: c_int, ...) c_int;
extern "c" fn msync(addr: *align(page_size) const anyopaque, len: usize, flags: c_int) c_int;
extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;
extern "c" fn clock_nanosleep(clockid: clockid_t, flags: TIMER, t: *const timespec, remain: ?*timespec) c_int;
extern "c" fn pipe2(fds: *[2]fd_t, flags: O) c_int;
extern "c" fn readdir(dir: *DIR) ?*dirent;
extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;
extern "c" fn recvmsg(sockfd: fd_t, msg: *msghdr, flags: u32) isize;
extern "c" fn sched_yield() c_int;
extern "c" fn sendfile(out_fd: fd_t, in_fd: fd_t, offset: ?*off_t, count: usize) isize;
extern "c" fn sigaction(sig: SIG, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
extern "c" fn sigdelset(set: ?*sigset_t, signo: SIG) c_int;
extern "c" fn sigaddset(set: ?*sigset_t, signo: SIG) c_int;
extern "c" fn sigfillset(set: ?*sigset_t) c_int;
extern "c" fn sigemptyset(set: ?*sigset_t) c_int;
extern "c" fn sigismember(set: ?*const sigset_t, signo: SIG) c_int;
extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
extern "c" fn socketpair(domain: c_uint, sock_type: c_uint, protocol: c_uint, sv: *[2]fd_t) c_int;
extern "c" fn sigaltstack(ss: ?*const stack_t, old_ss: ?*stack_t) c_int;
extern "c" fn sysconf(sc: c_int) c_long;
extern "c" fn shm_open(name: [*:0]const u8, flag: c_int, mode: mode_t) c_int;
extern "c" fn wait4(pid: pid_t, status: ?*c_int, options: c_int, ru: ?*rusage) pid_t;
extern "c" fn pthread_setname_np(thread: pthread_t, name: [*:0]const u8) c_int;
extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize;
extern "c" fn getentropy(buffer: [*]u8, size: usize) c_int;
extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void;
extern "c" fn _msize(?*const anyopaque) usize;
extern "c" fn malloc_size(?*const anyopaque) usize;
extern "c" fn malloc_usable_size(?*const anyopaque) usize;
extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int;
extern "c" fn mlock(addr: *align(page_size) const anyopaque, len: usize) c_int;
extern "c" fn mlock2(addr: *align(page_size) const anyopaque, len: usize, flags: MLOCK) c_int;
extern "c" fn munlock(addr: *align(page_size) const anyopaque, len: usize) c_int;
extern "c" fn mlockall(flags: MCL) c_int;
extern "c" fn munlockall() c_int;
// linux and https://github.com/SerenityOS/serenity/blob/502caef9a40bccc7459f9835f2174a601106299a/Userland/Libraries/LibC/sys/ptrace.cpp
extern "c" fn ptrace(request: c_int, pid: pid_t, addr: ?*anyopaque, data: ?*anyopaque) c_long;
/// macos modernized symbols.
/// x86_64 links to $INODE64 suffix for 64-bit support.
/// Note these are not necessary on aarch64.
extern "c" fn @"fstat$INODE64"(fd: fd_t, buf: *Stat) c_int;
extern "c" fn @"fstatat$INODE64"(dirfd: fd_t, path: [*:0]const u8, buf: *Stat, flag: u32) c_int;
extern "c" fn @"readdir$INODE64"(dir: *DIR) ?*dirent;
extern "c" fn @"stat$INODE64"(noalias path: [*:0]const u8, noalias buf: *Stat) c_int;
extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int;
/// macos modernized symbols.
extern "c" fn @"realpath$DARWIN_EXTSN"(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;
extern "c" fn __getdirentries64(fd: fd_t, buf_ptr: [*]u8, buf_len: usize, basep: *i64) isize;
extern "c" fn pthread_threadid_np(thread: ?pthread_t, thread_id: *u64) c_int;
/// netbsd modernized symbols.
extern "c" fn __clock_getres50(clk_id: clockid_t, tp: *timespec) c_int;
extern "c" fn __clock_gettime50(clk_id: clockid_t, tp: *timespec) c_int;
extern "c" fn __fstat50(fd: fd_t, buf: *Stat) c_int;
extern "c" fn __getrusage50(who: c_int, usage: *rusage) c_int;
extern "c" fn __gettimeofday50(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
extern "c" fn __libc_thr_yield() c_int;
extern "c" fn __msync13(addr: *align(page_size) const anyopaque, len: usize, flags: c_int) c_int;
extern "c" fn __nanosleep50(rqtp: *const timespec, rmtp: ?*timespec) c_int;
extern "c" fn __sigaction14(sig: SIG, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
extern "c" fn __sigemptyset14(set: ?*sigset_t) c_int;
extern "c" fn __sigfillset14(set: ?*sigset_t) c_int;
extern "c" fn __sigprocmask14(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
extern "c" fn __socket30(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
extern "c" fn __stat50(path: [*:0]const u8, buf: *Stat) c_int;
extern "c" fn __getdents30(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int;
extern "c" fn __sigaltstack14(ss: ?*const stack_t, old_ss: ?*stack_t) c_int;
extern "c" fn __wait450(pid: pid_t, status: ?*c_int, options: c_int, ru: ?*rusage) pid_t;
extern "c" fn __libc_current_sigrtmin() c_int;
extern "c" fn __libc_current_sigrtmax() c_int;
extern "c" fn __signal_get_sigrtmin() c_int;
extern "c" fn __signal_get_sigrtmax() c_int;
// Don't forget to add another clown when an OS picks yet another unique
// symbol name for errno location!
// 🤡🤡🤡🤡🤡🤡
extern "c" fn ___errno() *c_int;
extern "c" fn __errno() *c_int;
extern "c" fn __errno_location() *c_int;
extern "c" fn __error() *c_int;
extern "c" fn _errno() *c_int;
extern threadlocal var errno: c_int;
fn errnoFromThreadLocal() *c_int {
return &private.errno;
}
}
External definitions shared by two or more operating systems.