2020-06-15 14:18:57 +00:00
|
|
|
#ifndef COSMOPOLITAN_LIBC_CALLS_INTERNAL_H_
|
|
|
|
#define COSMOPOLITAN_LIBC_CALLS_INTERNAL_H_
|
|
|
|
#include "libc/calls/calls.h"
|
2021-02-06 07:45:34 +00:00
|
|
|
#include "libc/calls/internal.h"
|
2020-11-28 20:01:51 +00:00
|
|
|
#include "libc/calls/struct/iovec.h"
|
2020-09-07 04:39:00 +00:00
|
|
|
#include "libc/calls/struct/itimerval.h"
|
2021-09-04 05:19:41 +00:00
|
|
|
#include "libc/calls/struct/metastat.internal.h"
|
2022-04-18 07:01:26 +00:00
|
|
|
#include "libc/calls/struct/rlimit.h"
|
2021-04-18 18:34:59 +00:00
|
|
|
#include "libc/calls/struct/rusage.h"
|
2021-02-06 07:45:34 +00:00
|
|
|
#include "libc/calls/struct/sigaction-xnu.internal.h"
|
2022-04-13 05:11:00 +00:00
|
|
|
#include "libc/calls/struct/siginfo-xnu.internal.h"
|
2021-04-18 18:34:59 +00:00
|
|
|
#include "libc/calls/struct/siginfo.h"
|
|
|
|
#include "libc/calls/struct/sigval.h"
|
2021-09-04 05:19:41 +00:00
|
|
|
#include "libc/calls/struct/stat.h"
|
2020-09-07 04:39:00 +00:00
|
|
|
#include "libc/calls/struct/timespec.h"
|
|
|
|
#include "libc/calls/struct/timeval.h"
|
2022-03-16 20:33:13 +00:00
|
|
|
#include "libc/calls/struct/winsize.h"
|
2021-10-14 00:27:13 +00:00
|
|
|
#include "libc/calls/ucontext.h"
|
2020-06-15 14:18:57 +00:00
|
|
|
#include "libc/dce.h"
|
|
|
|
#include "libc/limits.h"
|
2021-03-01 07:42:35 +00:00
|
|
|
#include "libc/macros.internal.h"
|
2021-02-06 07:45:34 +00:00
|
|
|
#include "libc/nt/struct/context.h"
|
2021-01-25 21:08:05 +00:00
|
|
|
#include "libc/nt/struct/ntexceptionpointers.h"
|
2022-04-15 06:39:48 +00:00
|
|
|
#include "libc/nt/struct/overlapped.h"
|
2020-06-15 14:18:57 +00:00
|
|
|
#include "libc/nt/struct/securityattributes.h"
|
|
|
|
#include "libc/nt/struct/startupinfo.h"
|
2020-08-25 11:23:25 +00:00
|
|
|
#include "libc/nt/struct/systeminfo.h"
|
2021-02-06 07:45:34 +00:00
|
|
|
#include "libc/nt/struct/win32fileattributedata.h"
|
2020-06-15 14:18:57 +00:00
|
|
|
#include "libc/runtime/runtime.h"
|
2020-09-07 04:39:00 +00:00
|
|
|
#include "libc/time/struct/timezone.h"
|
|
|
|
#include "libc/time/struct/utimbuf.h"
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
#define kSigactionMinRva 8 /* >SIG_{ERR,DFL,IGN,...} */
|
|
|
|
|
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
|
|
COSMOPOLITAN_C_START_
|
|
|
|
|
|
|
|
#define kIoMotion ((const int8_t[3]){1, 0, 0})
|
|
|
|
|
|
|
|
struct IoctlPtmGet {
|
|
|
|
int theduxfd;
|
|
|
|
int workerfd;
|
|
|
|
char theduxname[16];
|
|
|
|
char workername[16];
|
|
|
|
};
|
|
|
|
|
2021-02-02 16:14:45 +00:00
|
|
|
enum FdKind {
|
|
|
|
kFdEmpty,
|
|
|
|
kFdFile,
|
|
|
|
kFdSocket,
|
|
|
|
kFdProcess,
|
|
|
|
kFdConsole,
|
|
|
|
kFdSerial,
|
|
|
|
kFdZip,
|
|
|
|
kFdEpoll,
|
2021-02-03 18:50:08 +00:00
|
|
|
kFdReserved
|
2021-02-02 16:14:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Fd {
|
2021-02-08 12:04:42 +00:00
|
|
|
enum FdKind kind;
|
|
|
|
unsigned flags;
|
2022-04-15 06:39:48 +00:00
|
|
|
unsigned mode;
|
2021-02-02 16:14:45 +00:00
|
|
|
int64_t handle;
|
|
|
|
int64_t extra;
|
2022-04-15 06:39:48 +00:00
|
|
|
struct NtStdinWorker *worker;
|
2022-03-25 14:11:44 +00:00
|
|
|
bool zombie;
|
2021-02-02 16:14:45 +00:00
|
|
|
};
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
struct Fds {
|
2021-02-06 07:45:34 +00:00
|
|
|
size_t f; /* lowest free slot */
|
|
|
|
size_t n; /* monotonic capacity */
|
2021-02-05 17:44:54 +00:00
|
|
|
struct Fd *p;
|
2020-06-15 14:18:57 +00:00
|
|
|
struct Fd __init_p[OPEN_MAX];
|
|
|
|
};
|
|
|
|
|
|
|
|
extern const struct Fd kEmptyFd;
|
|
|
|
|
2021-01-25 21:08:05 +00:00
|
|
|
hidden extern int __vforked;
|
2022-05-17 11:14:28 +00:00
|
|
|
hidden extern int __fds_lock;
|
|
|
|
hidden extern int __sig_lock;
|
2022-03-25 14:11:44 +00:00
|
|
|
hidden extern bool __time_critical;
|
2021-01-28 23:49:15 +00:00
|
|
|
hidden extern unsigned __sighandrvas[NSIG];
|
2022-03-25 14:11:44 +00:00
|
|
|
hidden extern unsigned __sighandflags[NSIG];
|
2020-11-13 09:27:49 +00:00
|
|
|
hidden extern struct Fds g_fds;
|
|
|
|
hidden extern const struct NtSecurityAttributes kNtIsInheritable;
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2022-04-15 06:39:48 +00:00
|
|
|
int __reservefd(int) hidden;
|
2022-05-17 11:14:28 +00:00
|
|
|
int __reservefd_unlocked(int) hidden;
|
2021-02-03 14:22:51 +00:00
|
|
|
void __releasefd(int) hidden;
|
2022-05-17 11:14:28 +00:00
|
|
|
void __releasefd_unlocked(int) hidden;
|
2020-11-28 20:01:51 +00:00
|
|
|
int __ensurefds(int) hidden;
|
2022-05-17 11:14:28 +00:00
|
|
|
int __ensurefds_unlocked(int) hidden;
|
2022-04-15 06:39:48 +00:00
|
|
|
int64_t __getfdhandleactual(int) hidden;
|
2022-04-24 16:59:22 +00:00
|
|
|
void __printfds(void) hidden;
|
2021-01-28 03:34:02 +00:00
|
|
|
|
|
|
|
forceinline bool __isfdopen(int fd) {
|
|
|
|
return 0 <= fd && fd < g_fds.n && g_fds.p[fd].kind != kFdEmpty;
|
|
|
|
}
|
|
|
|
|
2021-02-02 16:14:45 +00:00
|
|
|
forceinline bool __isfdkind(int fd, int kind) {
|
2021-01-28 03:34:02 +00:00
|
|
|
return 0 <= fd && fd < g_fds.n && g_fds.p[fd].kind == kind;
|
|
|
|
}
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2022-04-08 03:30:04 +00:00
|
|
|
forceinline size_t _clampio(size_t size) {
|
2020-06-15 14:18:57 +00:00
|
|
|
if (!IsTrustworthy()) {
|
|
|
|
return MIN(size, 0x7ffff000);
|
|
|
|
} else {
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define i32 int32_t
|
|
|
|
#define i64 int64_t
|
|
|
|
#define u32 uint32_t
|
|
|
|
#define u64 uint64_t
|
|
|
|
#define sigset struct sigset
|
|
|
|
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
|
|
│ cosmopolitan § syscalls » system five » synthetic jump slots ─╬─│┼
|
|
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
|
2021-02-07 14:11:44 +00:00
|
|
|
axdx_t __sys_pipe(i32[hasatleast 2], i32) hidden;
|
|
|
|
axdx_t sys_fork(void) hidden;
|
|
|
|
axdx_t sys_getpid(void) hidden;
|
|
|
|
axdx_t sys_gettimeofday(struct timeval *, struct timezone *, void *) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
char *sys_getcwd(char *, u64) hidden;
|
|
|
|
char *sys_getcwd_xnu(char *, u64) hidden;
|
|
|
|
i32 __sys_dup3(i32, i32, i32) hidden;
|
|
|
|
i32 __sys_execve(const char *, char *const[], char *const[]) hidden;
|
2021-08-26 04:35:58 +00:00
|
|
|
i32 __sys_fcntl(i32, i32, ...) hidden;
|
|
|
|
i32 __sys_fstat(i32, void *) hidden;
|
|
|
|
i32 __sys_fstatat(i32, const char *, void *, i32) hidden;
|
2021-04-18 18:34:59 +00:00
|
|
|
i32 __sys_getrusage(i32, struct rusage *) hidden;
|
2021-10-14 00:27:13 +00:00
|
|
|
i32 __sys_munmap(void *, u64) hidden;
|
2021-03-08 18:07:02 +00:00
|
|
|
i32 __sys_openat(i32, const char *, i32, u32) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i32 __sys_pipe2(i32[hasatleast 2], u32) hidden;
|
2022-04-20 16:56:53 +00:00
|
|
|
i32 __sys_sigprocmask(i32, const sigset *, sigset *, u64) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i32 __sys_utimensat(i32, const char *, const struct timespec *, i32) hidden;
|
2021-04-18 18:34:59 +00:00
|
|
|
i32 __sys_wait4(i32, i32 *, i32, struct rusage *) hidden;
|
2022-05-16 20:20:08 +00:00
|
|
|
i32 sys_arch_prctl(i32, i64) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i32 sys_chdir(const char *) hidden;
|
2022-04-18 07:01:26 +00:00
|
|
|
i32 sys_chroot(const char *) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i32 sys_clock_gettime(i32, struct timespec *) hidden;
|
|
|
|
i32 sys_close(i32) hidden;
|
|
|
|
i32 sys_dup(i32) hidden;
|
|
|
|
i32 sys_dup2(i32, i32) hidden;
|
|
|
|
i32 sys_dup3(i32, i32, i32) hidden;
|
|
|
|
i32 sys_execve(const char *, char *const[], char *const[]) hidden;
|
|
|
|
i32 sys_faccessat(i32, const char *, i32, u32) hidden;
|
|
|
|
i32 sys_fadvise(i32, i64, i64, i32) hidden;
|
|
|
|
i32 sys_fchdir(i32) hidden;
|
|
|
|
i32 sys_fchmod(i32, u32) hidden;
|
|
|
|
i32 sys_fchmodat(i32, const char *, u32, u32) hidden;
|
|
|
|
i32 sys_fchown(i64, u32, u32) hidden;
|
|
|
|
i32 sys_fchownat(i32, const char *, u32, u32, u32) hidden;
|
2021-05-14 12:36:58 +00:00
|
|
|
i32 sys_fcntl(i32, i32, u64) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i32 sys_fdatasync(i32) hidden;
|
|
|
|
i32 sys_flock(i32, i32) hidden;
|
|
|
|
i32 sys_fstat(i32, struct stat *) hidden;
|
|
|
|
i32 sys_fstatat(i32, const char *, struct stat *, i32) hidden;
|
|
|
|
i32 sys_fsync(i32) hidden;
|
2021-02-07 14:11:44 +00:00
|
|
|
i32 sys_ftruncate(i32, i64, i64) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i32 sys_futimes(i32, const struct timeval *) hidden;
|
|
|
|
i32 sys_futimesat(i32, const char *, const struct timeval *) hidden;
|
2022-05-13 00:52:13 +00:00
|
|
|
i32 sys_getcontext(void *) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i32 sys_getitimer(i32, struct itimerval *) hidden;
|
2021-08-16 22:26:31 +00:00
|
|
|
i32 sys_getpgid(i32) hidden;
|
2022-04-16 17:40:23 +00:00
|
|
|
i32 sys_getpgrp(void) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i32 sys_getppid(void) hidden;
|
|
|
|
i32 sys_getpriority(i32, u32) hidden;
|
2022-04-28 16:42:36 +00:00
|
|
|
i32 sys_getresgid(u32 *, u32 *, u32 *);
|
|
|
|
i32 sys_getresuid(u32 *, u32 *, u32 *);
|
2021-02-04 03:35:29 +00:00
|
|
|
i32 sys_getrlimit(i32, struct rlimit *) hidden;
|
|
|
|
i32 sys_getrusage(i32, struct rusage *) hidden;
|
2022-04-24 16:59:22 +00:00
|
|
|
i32 sys_getsid(int) hidden;
|
2021-08-12 07:42:14 +00:00
|
|
|
i32 sys_ioctl(i32, u64, ...) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i32 sys_kill(i32, i32, i32) hidden;
|
|
|
|
i32 sys_linkat(i32, const char *, i32, const char *, i32) hidden;
|
2021-02-07 14:11:44 +00:00
|
|
|
i32 sys_lseek(i32, i64, i64, i64) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i32 sys_lutimes(const char *, const struct timeval *) hidden;
|
|
|
|
i32 sys_madvise(void *, size_t, i32) hidden;
|
|
|
|
i32 sys_memfd_create(const char *, u32) hidden;
|
2022-05-14 11:33:58 +00:00
|
|
|
i32 sys_mincore(void *, u64, unsigned char *) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i32 sys_mkdirat(i32, const char *, u32) hidden;
|
|
|
|
i32 sys_mkfifo(const char *, u32) hidden;
|
|
|
|
i32 sys_mknod(const char *, u32, u64) hidden;
|
|
|
|
i32 sys_mprotect(void *, u64, i32) hidden;
|
|
|
|
i32 sys_msync(void *, u64, i32) hidden;
|
|
|
|
i32 sys_munmap(void *, u64) hidden;
|
|
|
|
i32 sys_nanosleep(const struct timespec *, struct timespec *) hidden;
|
2021-03-08 18:07:02 +00:00
|
|
|
i32 sys_openat(i32, const char *, i32, u32) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i32 sys_pause(void) hidden;
|
|
|
|
i32 sys_pipe(i32[hasatleast 2]) hidden;
|
|
|
|
i32 sys_pipe2(i32[hasatleast 2], u32) hidden;
|
2022-04-28 16:42:36 +00:00
|
|
|
i32 sys_pledge(const char *, const char *) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i32 sys_posix_openpt(i32) hidden;
|
|
|
|
i32 sys_renameat(i32, const char *, i32, const char *) hidden;
|
|
|
|
i32 sys_sched_setaffinity(i32, u64, const void *) hidden;
|
|
|
|
i32 sys_sched_yield(void) hidden;
|
2022-04-15 06:39:48 +00:00
|
|
|
i32 sys_setgid(i32) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i32 sys_setitimer(i32, const struct itimerval *, struct itimerval *) hidden;
|
2022-04-12 12:20:17 +00:00
|
|
|
i32 sys_setpgid(i32, i32) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i32 sys_setpriority(i32, u32, i32) hidden;
|
2022-04-24 16:59:22 +00:00
|
|
|
i32 sys_setregid(u32, u32) hidden;
|
2022-04-28 16:42:36 +00:00
|
|
|
i32 sys_setresgid(u32, u32, u32) hidden;
|
|
|
|
i32 sys_setresuid(u32, u32, u32) hidden;
|
2022-04-24 16:59:22 +00:00
|
|
|
i32 sys_setreuid(u32, u32) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i32 sys_setrlimit(i32, const struct rlimit *) hidden;
|
|
|
|
i32 sys_setsid(void) hidden;
|
2022-04-15 06:39:48 +00:00
|
|
|
i32 sys_setuid(i32) hidden;
|
2021-02-05 17:44:54 +00:00
|
|
|
i32 sys_sigaction(i32, const void *, void *, i64, i64) hidden;
|
2021-10-14 00:27:13 +00:00
|
|
|
i32 sys_sigaltstack(const void *, void *) hidden;
|
2022-04-20 16:56:53 +00:00
|
|
|
i32 sys_sigprocmask(i32, const sigset *, sigset *) hidden;
|
2021-04-18 18:34:59 +00:00
|
|
|
i32 sys_sigqueue(i32, i32, const union sigval) hidden;
|
|
|
|
i32 sys_sigqueueinfo(i32, const siginfo_t *) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i32 sys_sigsuspend(const sigset *, u64) hidden;
|
|
|
|
i32 sys_symlinkat(const char *, i32, const char *) hidden;
|
|
|
|
i32 sys_sync(void) hidden;
|
|
|
|
i32 sys_sync_file_range(i32, i64, i64, u32) hidden;
|
|
|
|
i32 sys_sysinfo(struct sysinfo *) hidden;
|
2022-05-13 00:52:13 +00:00
|
|
|
i32 sys_tgkill(i32, i32, i32) hidden;
|
|
|
|
i32 sys_tkill(i32, i32, void *) hidden;
|
2021-02-07 14:11:44 +00:00
|
|
|
i32 sys_truncate(const char *, u64, u64) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i32 sys_uname(char *) hidden;
|
|
|
|
i32 sys_unlinkat(i32, const char *, i32) hidden;
|
|
|
|
i32 sys_utime(const char *, const struct utimbuf *) hidden;
|
|
|
|
i32 sys_utimensat(i32, const char *, const struct timespec *, i32) hidden;
|
|
|
|
i32 sys_utimes(const char *, const struct timeval *) hidden;
|
|
|
|
i32 sys_wait4(i32, i32 *, i32, struct rusage *) hidden;
|
|
|
|
i64 sys_copy_file_range(i32, long *, i32, long *, u64, u32) hidden;
|
|
|
|
i64 sys_getrandom(void *, u64, u32) hidden;
|
2021-02-07 14:11:44 +00:00
|
|
|
i64 sys_pread(i32, void *, u64, i64, i64) hidden;
|
|
|
|
i64 sys_preadv(i32, struct iovec *, i32, i64, i64) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i64 sys_ptrace(int, i32, void *, void *) hidden;
|
2021-02-07 14:11:44 +00:00
|
|
|
i64 sys_pwrite(i32, const void *, u64, i64, i64) hidden;
|
|
|
|
i64 sys_pwritev(i32, const struct iovec *, i32, i64, i64) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i64 sys_read(i32, void *, u64) hidden;
|
2021-08-18 21:21:30 +00:00
|
|
|
i64 sys_readlink(const char *, char *, u64) hidden;
|
|
|
|
i64 sys_readlinkat(int, const char *, char *, u64) hidden;
|
2022-05-12 14:22:57 +00:00
|
|
|
i64 sys_sched_getaffinity(i32, u64, void *) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i64 sys_sendfile(i32, i32, i64 *, u64) hidden;
|
|
|
|
i64 sys_splice(i32, i64 *, i32, i64 *, u64, u32) hidden;
|
|
|
|
i64 sys_vmsplice(i32, const struct iovec *, i64, u32) hidden;
|
|
|
|
i64 sys_write(i32, const void *, u64) hidden;
|
2022-04-16 17:40:23 +00:00
|
|
|
u32 sys_getegid(void) hidden;
|
2022-04-15 06:39:48 +00:00
|
|
|
u32 sys_geteuid(void) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
u32 sys_getgid(void) hidden;
|
|
|
|
u32 sys_gettid(void) hidden;
|
|
|
|
u32 sys_getuid(void) hidden;
|
2022-04-13 15:49:17 +00:00
|
|
|
u32 sys_umask(u32) hidden;
|
2021-02-24 04:23:19 +00:00
|
|
|
void *__sys_mmap(void *, u64, u32, u32, i64, i64, i64) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
void *sys_mremap(void *, u64, u64, i32, void *) hidden;
|
2021-02-22 00:26:36 +00:00
|
|
|
void sys_exit(int) hidden;
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
|
|
│ cosmopolitan § syscalls » system five » support ─╬─│┼
|
|
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
|
|
|
|
void __onfork(void) hidden;
|
2022-04-26 04:16:05 +00:00
|
|
|
void *__vdsofunc(const char *) hidden;
|
|
|
|
void *__get_clock_gettime(void) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
i32 __fixupnewfd(i32, i32) hidden;
|
2020-06-15 14:18:57 +00:00
|
|
|
void __restore_rt() hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
int sys_utimensat_xnu(int, const char *, const struct timespec *, int) hidden;
|
|
|
|
int sys_nanosleep_xnu(const struct timespec *, struct timespec *) hidden;
|
2021-09-04 05:19:41 +00:00
|
|
|
void __stat2cosmo(struct stat *restrict, const union metastat *) hidden;
|
2021-02-05 17:44:54 +00:00
|
|
|
void __restore_rt_netbsd(void) hidden;
|
2022-04-13 05:11:00 +00:00
|
|
|
void __sigenter_xnu(void *, i32, i32, struct siginfo_xnu *,
|
2021-02-26 02:30:17 +00:00
|
|
|
struct __darwin_ucontext *) hidden;
|
2021-02-07 14:11:44 +00:00
|
|
|
int gethostname_linux(char *, size_t) hidden;
|
|
|
|
int gethostname_bsd(char *, size_t) hidden;
|
2022-03-21 10:46:16 +00:00
|
|
|
int gethostname_nt(char *, size_t, int) hidden;
|
2021-03-08 18:07:02 +00:00
|
|
|
size_t __iovec_size(const struct iovec *, size_t) hidden;
|
2021-04-18 18:34:59 +00:00
|
|
|
void __rusage2linux(struct rusage *) hidden;
|
Improve ZIP filesystem and change its prefix
The ZIP filesystem has a breaking change. You now need to use /zip/ to
open() / opendir() / etc. assets within the ZIP structure of your APE
binary, instead of the previous convention of using zip: or zip! URIs.
This is needed because Python likes to use absolute paths, and having
ZIP paths encoded like URIs simply broke too many things.
Many more system calls have been updated to be able to operate on ZIP
files and file descriptors. In particular fcntl() and ioctl() since
Python would do things like ask if a ZIP file is a terminal and get
confused when the old implementation mistakenly said yes, because the
fastest way to guarantee native file descriptors is to dup(2). This
change also improves the async signal safety of zipos and ensures it
doesn't maintain any open file descriptors beyond that which the user
has opened.
This change makes a lot of progress towards adding magic numbers that
are specific to platforms other than Linux. The philosophy here is that,
if you use an operating system like FreeBSD, then you should be able to
take advantage of FreeBSD exclusive features, even if we don't polyfill
them on other platforms. For example, you can now open() a file with the
O_VERIFY flag. If your program runs on other platforms, then Cosmo will
automatically set O_VERIFY to zero. This lets you safely use it without
the need for #ifdef or ifstatements which detract from readability.
One of the blindspots of the ASAN memory hardening we use to offer Rust
like assurances has always been that memory passed to the kernel via
system calls (e.g. writev) can't be checked automatically since the
kernel wasn't built with MODE=asan. This change makes more progress
ensuring that each system call will verify the soundness of memory
before it's passed to the kernel. The code for doing these checks is
fast, particularly for buffers, where it can verify 64 bytes a cycle.
- Correct O_LOOP definition on NT
- Introduce program_executable_name
- Add ASAN guards to more system calls
- Improve termios compatibility with BSDs
- Fix bug in Windows auxiliary value encoding
- Add BSD and XNU specific errnos and open flags
- Add check to ensure build doesn't talk to internet
2021-08-22 08:04:18 +00:00
|
|
|
int __notziposat(int, const char *);
|
2021-04-24 20:58:34 +00:00
|
|
|
ssize_t WritevUninterruptible(int, struct iovec *, int);
|
2021-05-14 12:36:58 +00:00
|
|
|
void flock2cosmo(uintptr_t);
|
|
|
|
void cosmo2flock(uintptr_t);
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
int sys_sendfile_xnu(int32_t infd, int32_t outfd, int64_t offset,
|
|
|
|
int64_t *out_opt_sbytes, const void *opt_hdtr,
|
|
|
|
int32_t flags) asm("sys_sendfile") hidden;
|
|
|
|
int sys_sendfile_freebsd(int32_t infd, int32_t outfd, int64_t offset,
|
|
|
|
size_t nbytes, const void *opt_hdtr,
|
|
|
|
int64_t *out_opt_sbytes,
|
|
|
|
int32_t flags) asm("sys_sendfile") hidden;
|
|
|
|
|
2020-06-15 14:18:57 +00:00
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
|
|
│ cosmopolitan § syscalls » windows nt » veneers ─╬─│┼
|
|
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
|
2021-02-04 03:35:29 +00:00
|
|
|
bool32 sys_isatty_nt(int) hidden;
|
|
|
|
char *sys_getcwd_nt(char *, size_t) hidden;
|
|
|
|
i64 sys_lseek_nt(int, i64, int) hidden;
|
|
|
|
int sys_chdir_nt(const char *) hidden;
|
2021-02-08 12:04:42 +00:00
|
|
|
int sys_close_epoll_nt(int) hidden;
|
2021-02-06 07:45:34 +00:00
|
|
|
int sys_close_nt(struct Fd *) hidden;
|
2022-04-15 06:39:48 +00:00
|
|
|
int sys_dup_nt(int, int, int, int) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
int sys_execve_nt(const char *, char *const[], char *const[]) hidden;
|
|
|
|
int sys_faccessat_nt(int, const char *, int, uint32_t) hidden;
|
|
|
|
int sys_fadvise_nt(int, u64, u64, int) hidden;
|
|
|
|
int sys_fchdir_nt(int) hidden;
|
2021-09-28 05:58:51 +00:00
|
|
|
int sys_fchmodat_nt(int, const char *, uint32_t, int) hidden;
|
2021-05-14 12:36:58 +00:00
|
|
|
int sys_fcntl_nt(int, int, uintptr_t) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
int sys_fdatasync_nt(int) hidden;
|
|
|
|
int sys_flock_nt(int, int) hidden;
|
|
|
|
int sys_fork_nt(void) hidden;
|
|
|
|
int sys_fstat_nt(i64, struct stat *) hidden;
|
Improve ZIP filesystem and change its prefix
The ZIP filesystem has a breaking change. You now need to use /zip/ to
open() / opendir() / etc. assets within the ZIP structure of your APE
binary, instead of the previous convention of using zip: or zip! URIs.
This is needed because Python likes to use absolute paths, and having
ZIP paths encoded like URIs simply broke too many things.
Many more system calls have been updated to be able to operate on ZIP
files and file descriptors. In particular fcntl() and ioctl() since
Python would do things like ask if a ZIP file is a terminal and get
confused when the old implementation mistakenly said yes, because the
fastest way to guarantee native file descriptors is to dup(2). This
change also improves the async signal safety of zipos and ensures it
doesn't maintain any open file descriptors beyond that which the user
has opened.
This change makes a lot of progress towards adding magic numbers that
are specific to platforms other than Linux. The philosophy here is that,
if you use an operating system like FreeBSD, then you should be able to
take advantage of FreeBSD exclusive features, even if we don't polyfill
them on other platforms. For example, you can now open() a file with the
O_VERIFY flag. If your program runs on other platforms, then Cosmo will
automatically set O_VERIFY to zero. This lets you safely use it without
the need for #ifdef or ifstatements which detract from readability.
One of the blindspots of the ASAN memory hardening we use to offer Rust
like assurances has always been that memory passed to the kernel via
system calls (e.g. writev) can't be checked automatically since the
kernel wasn't built with MODE=asan. This change makes more progress
ensuring that each system call will verify the soundness of memory
before it's passed to the kernel. The code for doing these checks is
fast, particularly for buffers, where it can verify 64 bytes a cycle.
- Correct O_LOOP definition on NT
- Introduce program_executable_name
- Add ASAN guards to more system calls
- Improve termios compatibility with BSDs
- Fix bug in Windows auxiliary value encoding
- Add BSD and XNU specific errnos and open flags
- Add check to ensure build doesn't talk to internet
2021-08-22 08:04:18 +00:00
|
|
|
int sys_fstatat_nt(int, const char *, struct stat *, int) hidden;
|
2021-03-17 05:19:51 +00:00
|
|
|
int sys_ftruncate_nt(i64, u64) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
int sys_getppid_nt(void) hidden;
|
|
|
|
int sys_getpriority_nt(int) hidden;
|
|
|
|
int sys_getrusage_nt(int, struct rusage *) hidden;
|
|
|
|
int sys_gettimeofday_nt(struct timeval *, struct timezone *) hidden;
|
|
|
|
int sys_kill_nt(int, int) hidden;
|
Improve ZIP filesystem and change its prefix
The ZIP filesystem has a breaking change. You now need to use /zip/ to
open() / opendir() / etc. assets within the ZIP structure of your APE
binary, instead of the previous convention of using zip: or zip! URIs.
This is needed because Python likes to use absolute paths, and having
ZIP paths encoded like URIs simply broke too many things.
Many more system calls have been updated to be able to operate on ZIP
files and file descriptors. In particular fcntl() and ioctl() since
Python would do things like ask if a ZIP file is a terminal and get
confused when the old implementation mistakenly said yes, because the
fastest way to guarantee native file descriptors is to dup(2). This
change also improves the async signal safety of zipos and ensures it
doesn't maintain any open file descriptors beyond that which the user
has opened.
This change makes a lot of progress towards adding magic numbers that
are specific to platforms other than Linux. The philosophy here is that,
if you use an operating system like FreeBSD, then you should be able to
take advantage of FreeBSD exclusive features, even if we don't polyfill
them on other platforms. For example, you can now open() a file with the
O_VERIFY flag. If your program runs on other platforms, then Cosmo will
automatically set O_VERIFY to zero. This lets you safely use it without
the need for #ifdef or ifstatements which detract from readability.
One of the blindspots of the ASAN memory hardening we use to offer Rust
like assurances has always been that memory passed to the kernel via
system calls (e.g. writev) can't be checked automatically since the
kernel wasn't built with MODE=asan. This change makes more progress
ensuring that each system call will verify the soundness of memory
before it's passed to the kernel. The code for doing these checks is
fast, particularly for buffers, where it can verify 64 bytes a cycle.
- Correct O_LOOP definition on NT
- Introduce program_executable_name
- Add ASAN guards to more system calls
- Improve termios compatibility with BSDs
- Fix bug in Windows auxiliary value encoding
- Add BSD and XNU specific errnos and open flags
- Add check to ensure build doesn't talk to internet
2021-08-22 08:04:18 +00:00
|
|
|
int sys_linkat_nt(int, const char *, int, const char *) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
int sys_lstat_nt(const char *, struct stat *) hidden;
|
|
|
|
int sys_madvise_nt(void *, size_t, int) hidden;
|
|
|
|
int sys_mkdirat_nt(int, const char *, uint32_t) hidden;
|
2022-04-07 07:15:35 +00:00
|
|
|
int sys_msync_nt(char *, size_t, int) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
int sys_nanosleep_nt(const struct timespec *, struct timespec *) hidden;
|
|
|
|
int sys_pipe_nt(int[hasatleast 2], unsigned) hidden;
|
|
|
|
int sys_renameat_nt(int, const char *, int, const char *) hidden;
|
|
|
|
int sys_sched_yield_nt(void) hidden;
|
|
|
|
int sys_setitimer_nt(int, const struct itimerval *, struct itimerval *) hidden;
|
|
|
|
int sys_setpriority_nt(int) hidden;
|
|
|
|
int sys_symlinkat_nt(const char *, int, const char *) hidden;
|
|
|
|
int sys_sync_nt(void) hidden;
|
|
|
|
int sys_sysinfo_nt(struct sysinfo *) hidden;
|
|
|
|
int sys_truncate_nt(const char *, u64) hidden;
|
|
|
|
int sys_unlinkat_nt(int, const char *, int) hidden;
|
2022-04-18 07:01:26 +00:00
|
|
|
int sys_setrlimit_nt(int, const struct rlimit *) hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
int sys_utimensat_nt(int, const char *, const struct timespec *, int) hidden;
|
Improve ZIP filesystem and change its prefix
The ZIP filesystem has a breaking change. You now need to use /zip/ to
open() / opendir() / etc. assets within the ZIP structure of your APE
binary, instead of the previous convention of using zip: or zip! URIs.
This is needed because Python likes to use absolute paths, and having
ZIP paths encoded like URIs simply broke too many things.
Many more system calls have been updated to be able to operate on ZIP
files and file descriptors. In particular fcntl() and ioctl() since
Python would do things like ask if a ZIP file is a terminal and get
confused when the old implementation mistakenly said yes, because the
fastest way to guarantee native file descriptors is to dup(2). This
change also improves the async signal safety of zipos and ensures it
doesn't maintain any open file descriptors beyond that which the user
has opened.
This change makes a lot of progress towards adding magic numbers that
are specific to platforms other than Linux. The philosophy here is that,
if you use an operating system like FreeBSD, then you should be able to
take advantage of FreeBSD exclusive features, even if we don't polyfill
them on other platforms. For example, you can now open() a file with the
O_VERIFY flag. If your program runs on other platforms, then Cosmo will
automatically set O_VERIFY to zero. This lets you safely use it without
the need for #ifdef or ifstatements which detract from readability.
One of the blindspots of the ASAN memory hardening we use to offer Rust
like assurances has always been that memory passed to the kernel via
system calls (e.g. writev) can't be checked automatically since the
kernel wasn't built with MODE=asan. This change makes more progress
ensuring that each system call will verify the soundness of memory
before it's passed to the kernel. The code for doing these checks is
fast, particularly for buffers, where it can verify 64 bytes a cycle.
- Correct O_LOOP definition on NT
- Introduce program_executable_name
- Add ASAN guards to more system calls
- Improve termios compatibility with BSDs
- Fix bug in Windows auxiliary value encoding
- Add BSD and XNU specific errnos and open flags
- Add check to ensure build doesn't talk to internet
2021-08-22 08:04:18 +00:00
|
|
|
int sys_utimes_nt(const char *, const struct timeval[2]) hidden;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
ssize_t sys_open_nt(int, const char *, u32, i32) dontdiscard hidden;
|
2021-02-04 03:35:29 +00:00
|
|
|
ssize_t sys_read_nt(struct Fd *, const struct iovec *, size_t, ssize_t) hidden;
|
2021-08-18 21:21:30 +00:00
|
|
|
ssize_t sys_readlinkat_nt(int, const char *, char *, size_t) hidden;
|
2022-03-19 10:37:00 +00:00
|
|
|
ssize_t sys_write_nt(int, const struct iovec *, size_t, ssize_t) hidden;
|
2022-03-16 20:33:13 +00:00
|
|
|
int ioctl_tiocgwinsz_nt(struct Fd *, struct winsize *) hidden;
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
|
|
│ cosmopolitan § syscalls » windows nt » support ─╬─│┼
|
|
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
|
2022-04-28 16:42:36 +00:00
|
|
|
bool __is_linux_2_6_23(void) hidden;
|
2022-04-18 07:01:26 +00:00
|
|
|
int64_t __fix_enotdir(int64_t, char16_t *) hidden;
|
2022-04-20 16:56:53 +00:00
|
|
|
int64_t __fix_enotdir3(int64_t, char16_t *, char16_t *) hidden;
|
2022-03-25 14:11:44 +00:00
|
|
|
bool _check_interrupts(bool, struct Fd *) hidden;
|
|
|
|
void _check_sigchld(void) hidden;
|
|
|
|
void _check_sigalrm(void) hidden;
|
|
|
|
int __sample_pids(int[hasatleast 64], int64_t[hasatleast 64], bool) hidden;
|
2021-10-02 15:17:04 +00:00
|
|
|
bool isdirectory_nt(const char *) hidden;
|
|
|
|
bool isregularfile_nt(const char *) hidden;
|
|
|
|
bool issymlink_nt(const char *) hidden;
|
2020-06-15 14:18:57 +00:00
|
|
|
bool32 ntsetprivilege(i64, const char16_t *, u32) hidden;
|
2021-10-02 15:17:04 +00:00
|
|
|
char16_t *CreatePipeName(char16_t *) hidden;
|
2022-04-28 16:42:36 +00:00
|
|
|
int __mkntpath(const char *, char16_t[hasatleast PATH_MAX]) hidden;
|
|
|
|
int __mkntpath2(const char *, char16_t[hasatleast PATH_MAX], int) hidden;
|
|
|
|
int __mkntpathat(int, const char *, int, char16_t[hasatleast PATH_MAX]) hidden;
|
2021-10-02 15:17:04 +00:00
|
|
|
int sys_clock_gettime_nt(int, struct timespec *) hidden;
|
|
|
|
int ntaccesscheck(const char16_t *, u32) paramsnonnull() hidden;
|
|
|
|
int sys_getsetpriority_nt(int, int, int, int (*)(int));
|
|
|
|
int64_t __winerr(void) nocallback privileged;
|
|
|
|
int64_t ntreturn(uint32_t);
|
2021-02-26 02:30:17 +00:00
|
|
|
ssize_t sys_readv_nt(struct Fd *, const struct iovec *, int) hidden;
|
2022-03-19 10:37:00 +00:00
|
|
|
ssize_t sys_writev_nt(int, const struct iovec *, int) hidden;
|
2021-10-02 15:17:04 +00:00
|
|
|
unsigned __wincrash_nt(struct NtExceptionPointers *);
|
|
|
|
void *GetProcAddressModule(const char *, const char *) hidden;
|
|
|
|
void WinMainForked(void) hidden;
|
2022-04-12 12:20:17 +00:00
|
|
|
void _ntcontext2linux(struct ucontext *, const struct NtContext *) hidden;
|
|
|
|
void _ntlinux2context(struct NtContext *, const ucontext_t *) hidden;
|
2022-04-15 06:39:48 +00:00
|
|
|
struct NtOverlapped *_offset2overlap(int64_t, int64_t,
|
|
|
|
struct NtOverlapped *) hidden;
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2021-01-17 01:52:15 +00:00
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
|
|
│ cosmopolitan § syscalls » metal ─╬─│┼
|
|
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
|
2021-02-26 02:30:17 +00:00
|
|
|
int sys_fstat_metal(int, struct stat *);
|
|
|
|
int sys_openat_metal(int, const char *, int, unsigned);
|
|
|
|
ssize_t sys_readv_metal(struct Fd *, const struct iovec *, int) hidden;
|
|
|
|
ssize_t sys_writev_metal(struct Fd *, const struct iovec *, int) hidden;
|
2021-01-17 01:52:15 +00:00
|
|
|
|
2020-11-28 20:01:51 +00:00
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
|
|
│ cosmopolitan § syscalls » drivers ─╬─│┼
|
|
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
|
2021-02-26 02:30:17 +00:00
|
|
|
ssize_t sys_readv_serial(struct Fd *, const struct iovec *, int) hidden;
|
|
|
|
ssize_t sys_writev_serial(struct Fd *, const struct iovec *, int) hidden;
|
2020-11-28 20:01:51 +00:00
|
|
|
|
2020-06-15 14:18:57 +00:00
|
|
|
#undef sigset
|
|
|
|
#undef i32
|
|
|
|
#undef i64
|
|
|
|
#undef u32
|
|
|
|
#undef u64
|
|
|
|
COSMOPOLITAN_C_END_
|
|
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
|
|
#endif /* COSMOPOLITAN_LIBC_CALLS_INTERNAL_H_ */
|