mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
Improve cosmo's conformance to libc-test
This change addresses various open source compatibility issues, so that we pass 313/411 of the tests in https://github.com/jart/libc-test where earlier today we were passing about 30/411 of them, due to header toil. Please note that Glibc only passes 341/411 so 313 today is pretty good! - Make the conformance of libc/isystem/ headers nearly perfect - Import more of the remaining math library routines from Musl - Fix inconsistencies with type signatures of calls like umask - Write tests for getpriority/setpriority which work great now - conform to `struct sockaddr *` on remaining socket functions - Import a bunch of uninteresting stdlib functions e.g. rand48 - Introduce readdir_r, scandir, pthread_kill, sigsetjmp, etc.. Follow the instructions in our `tool/scripts/cosmocc` toolchain to run these tests yourself. You use `make CC=cosmocc` on the test repository
This commit is contained in:
parent
467a332e38
commit
e557058ac8
189 changed files with 5091 additions and 884 deletions
2
Makefile
2
Makefile
|
@ -309,7 +309,7 @@ COSMOPOLITAN_OBJECTS = \
|
|||
THIRD_PARTY_GDTOA \
|
||||
THIRD_PARTY_REGEX \
|
||||
LIBC_THREAD \
|
||||
THIRD_PARTY_NSYNC_MALLOC \
|
||||
THIRD_PARTY_NSYNC_MEM \
|
||||
LIBC_MEM \
|
||||
THIRD_PARTY_DLMALLOC \
|
||||
LIBC_RUNTIME \
|
||||
|
|
Binary file not shown.
|
@ -137,7 +137,7 @@ void *Worker(void *id) {
|
|||
setsockopt(server, SOL_TCP, TCP_QUICKACK, &yes, sizeof(yes));
|
||||
errno = 0;
|
||||
|
||||
if (bind(server, &addr, sizeof(addr)) == -1) {
|
||||
if (bind(server, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
|
||||
kprintf("%s() failed %m\n", "socket");
|
||||
goto CloseWorker;
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ int execve(const char *, char *const[], char *const[]);
|
|||
int execvp(const char *, char *const[]);
|
||||
int execvpe(const char *, char *const[], char *const[]);
|
||||
int fexecve(int, char *const[], char *const[]);
|
||||
int faccessat(int, const char *, int, uint32_t);
|
||||
int faccessat(int, const char *, int, int);
|
||||
int fadvise(int, uint64_t, uint64_t, int);
|
||||
int fchdir(int);
|
||||
int fchmod(int, uint32_t) dontthrow;
|
||||
|
@ -95,6 +95,7 @@ int fchownat(int, const char *, uint32_t, uint32_t, int);
|
|||
int fcntl(int, int, ...);
|
||||
int fdatasync(int);
|
||||
int flock(int, int);
|
||||
int lockf(int, int, int64_t);
|
||||
int fork(void);
|
||||
int fsync(int);
|
||||
int ftruncate(int, int64_t);
|
||||
|
@ -148,7 +149,7 @@ int pipe(int[hasatleast 2]);
|
|||
int pipe2(int[hasatleast 2], int);
|
||||
int pivot_root(const char *, const char *);
|
||||
int pledge(const char *, const char *);
|
||||
int posix_fadvise(int, uint64_t, uint64_t, int);
|
||||
int posix_fadvise(int, int64_t, int64_t, int);
|
||||
int posix_madvise(void *, uint64_t, int);
|
||||
int prctl(int, ...);
|
||||
int raise(int);
|
||||
|
@ -162,10 +163,10 @@ int sched_yield(void);
|
|||
int seccomp(unsigned, unsigned, void *);
|
||||
int setegid(uint32_t);
|
||||
int seteuid(uint32_t);
|
||||
int setfsgid(int);
|
||||
int setfsuid(int);
|
||||
int setgid(int);
|
||||
int setgroups(size_t size, const uint32_t list[]);
|
||||
int setfsgid(unsigned);
|
||||
int setfsuid(unsigned);
|
||||
int setgid(unsigned);
|
||||
int setgroups(size_t, const uint32_t[]);
|
||||
int setpgid(int, int);
|
||||
int setpgrp(void);
|
||||
int setpriority(int, unsigned, int);
|
||||
|
@ -174,7 +175,7 @@ int setresgid(uint32_t, uint32_t, uint32_t);
|
|||
int setresuid(uint32_t, uint32_t, uint32_t);
|
||||
int setreuid(uint32_t, uint32_t);
|
||||
int setsid(void);
|
||||
int setuid(int);
|
||||
int setuid(unsigned);
|
||||
int sigignore(int);
|
||||
int siginterrupt(int, int);
|
||||
int symlink(const char *, const char *);
|
||||
|
@ -187,9 +188,9 @@ int tgkill(int, int, int);
|
|||
int tkill(int, int);
|
||||
int tmpfd(void);
|
||||
int touch(const char *, uint32_t);
|
||||
int truncate(const char *, uint64_t);
|
||||
int truncate(const char *, int64_t);
|
||||
int ttyname_r(int, char *, size_t);
|
||||
int umask(int);
|
||||
unsigned umask(unsigned);
|
||||
int unlink(const char *);
|
||||
int unlink_s(const char **);
|
||||
int unlinkat(int, const char *, int);
|
||||
|
@ -204,7 +205,7 @@ long ptrace(int, ...);
|
|||
ssize_t copy_file_range(int, long *, int, long *, size_t, uint32_t);
|
||||
ssize_t copyfd(int, int64_t *, int, int64_t *, size_t, uint32_t);
|
||||
ssize_t getfiledescriptorsize(int);
|
||||
ssize_t lseek(int, int64_t, unsigned);
|
||||
ssize_t lseek(int, int64_t, int);
|
||||
ssize_t pread(int, void *, size_t, int64_t);
|
||||
ssize_t pwrite(int, const void *, size_t, int64_t);
|
||||
ssize_t read(int, void *, size_t);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "libc/calls/termios.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
int cfsetispeed(struct termios *t, int speed) {
|
||||
int cfsetispeed(struct termios *t, unsigned speed) {
|
||||
if (speed) {
|
||||
if (CBAUD) {
|
||||
if (speed & ~CBAUD) return einval();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "libc/sysv/consts/termios.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
int cfsetospeed(struct termios *t, int speed) {
|
||||
int cfsetospeed(struct termios *t, unsigned speed) {
|
||||
if (CBAUD) {
|
||||
if (!(speed & ~CBAUD)) {
|
||||
t->c_cflag &= ~CBAUD;
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
* @note on Linux `flags` is only supported on Linux 5.8+
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
int faccessat(int dirfd, const char *path, int amode, uint32_t flags) {
|
||||
int faccessat(int dirfd, const char *path, int amode, int flags) {
|
||||
int e, rc;
|
||||
struct ZiposUri zipname;
|
||||
if (!path || (IsAsan() && !__asan_is_valid(path, 1))) {
|
||||
|
|
|
@ -16,28 +16,67 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/kntprioritycombos.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/struct/fd.internal.h"
|
||||
#include "libc/calls/syscall-nt.internal.h"
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/nexgen32e/ffs.h"
|
||||
#include "libc/nt/enum/processaccess.h"
|
||||
#include "libc/nt/enum/processcreationflags.h"
|
||||
#include "libc/nt/process.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/nt/thread.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/prio.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
textwindows int sys_getpriority_nt(int ignored) {
|
||||
size_t i;
|
||||
uint32_t tier, lg2tier, wut;
|
||||
if ((tier = GetPriorityClass(GetCurrentProcess())) != 0 &&
|
||||
(wut = GetThreadPriority(GetCurrentThread())) != -1u) {
|
||||
lg2tier = ffs(tier);
|
||||
for (i = 0; i < kNtPriorityCombosLen; ++i) {
|
||||
if (kNtPriorityCombos[i].lg2tier == lg2tier &&
|
||||
kNtPriorityCombos[i].wut == wut) {
|
||||
return kNtPriorityCombos[i].nice;
|
||||
}
|
||||
}
|
||||
abort();
|
||||
} else {
|
||||
return __winerr();
|
||||
textwindows int sys_getpriority_nt(int which, unsigned pid) {
|
||||
int rc;
|
||||
uint32_t tier;
|
||||
int64_t h, closeme = -1;
|
||||
|
||||
if (which != PRIO_PROCESS) {
|
||||
return einval();
|
||||
}
|
||||
|
||||
if (!pid || pid == getpid()) {
|
||||
h = GetCurrentProcess();
|
||||
} else if (__isfdkind(pid, kFdProcess)) {
|
||||
h = g_fds.p[pid].handle;
|
||||
} else {
|
||||
h = OpenProcess(kNtProcessQueryInformation, false, pid);
|
||||
if (!h) return __winerr();
|
||||
closeme = h;
|
||||
}
|
||||
|
||||
if ((tier = GetPriorityClass(h))) {
|
||||
switch (tier) {
|
||||
case kNtRealtimePriorityClass:
|
||||
rc = -16;
|
||||
break;
|
||||
case kNtHighPriorityClass:
|
||||
rc = -10;
|
||||
break;
|
||||
case kNtAboveNormalPriorityClass:
|
||||
rc = -5;
|
||||
break;
|
||||
case kNtNormalPriorityClass:
|
||||
rc = 0;
|
||||
break;
|
||||
case kNtBelowNormalPriorityClass:
|
||||
rc = 5;
|
||||
break;
|
||||
case kNtIdlePriorityClass:
|
||||
rc = 15;
|
||||
break;
|
||||
default:
|
||||
notpossible;
|
||||
}
|
||||
} else {
|
||||
rc = __winerr();
|
||||
}
|
||||
|
||||
if (closeme != -1) {
|
||||
CloseHandle(closeme);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -17,10 +17,13 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/calls/syscall-nt.internal.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/asmflag.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/limits.h"
|
||||
|
||||
/**
|
||||
* Returns nice value of thing.
|
||||
|
@ -29,20 +32,47 @@
|
|||
* to clear `errno` beforehand and see if it changed, in order to truly
|
||||
* determine if an error happened.
|
||||
*
|
||||
* @param which can be PRIO_PROCESS, PRIO_PGRP, PRIO_USER
|
||||
* On Windows, there's only six priority classes. We define them as -16
|
||||
* (realtime), -10 (high), -5 (above), 0 (normal), 5 (below), 15 (idle)
|
||||
* which are the only values that'll roundtrip getpriority/setpriority.
|
||||
*
|
||||
* @param which can be one of:
|
||||
* - `PRIO_PROCESS` is supported universally
|
||||
* - `PRIO_PGRP` is supported on unix
|
||||
* - `PRIO_USER` is supported on unix
|
||||
* @param who is the pid, pgid, or uid (0 means current)
|
||||
* @return value ∈ [-NZERO,NZERO) or -1 w/ errno
|
||||
* @see setpriority(), nice()
|
||||
* @raise EINVAL if `which` was invalid or unsupported
|
||||
* @raise EPERM if access to process was denied
|
||||
* @raise ESRCH if no such process existed
|
||||
* @see setpriority()
|
||||
*/
|
||||
int getpriority(int which, unsigned who) {
|
||||
privileged int getpriority(int which, unsigned who) {
|
||||
int rc;
|
||||
if (!IsWindows()) {
|
||||
if ((rc = sys_getpriority(which, who)) != -1) {
|
||||
rc = 20 - rc;
|
||||
char cf;
|
||||
if (IsLinux()) {
|
||||
asm volatile("syscall"
|
||||
: "=a"(rc)
|
||||
: "0"(140), "D"(which), "S"(who)
|
||||
: "rcx", "r11", "memory");
|
||||
if (rc >= 0) {
|
||||
rc = NZERO - rc;
|
||||
} else {
|
||||
errno = -rc;
|
||||
rc = -1;
|
||||
}
|
||||
} else if (IsBsd()) {
|
||||
asm volatile(CFLAG_ASM("syscall")
|
||||
: CFLAG_CONSTRAINT(cf), "=a"(rc)
|
||||
: "1"((IsXnu() ? 0x2000000 : 0) | 100), "D"(which), "S"(who)
|
||||
: "rcx", "rdx", "r8", "r9", "r10", "r11", "memory");
|
||||
if (cf) {
|
||||
errno = rc;
|
||||
rc = -1;
|
||||
}
|
||||
} else {
|
||||
rc = sys_getsetpriority_nt(which, who, 0, sys_getpriority_nt);
|
||||
rc = sys_getpriority_nt(which, who);
|
||||
}
|
||||
STRACE("getpriority(%d, %u) → %d% m", which, who, rc);
|
||||
STRACE("getpriority(%s, %u) → %d% m", DescribeWhichPrio(which), who, rc);
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/calls/kntprioritycombos.internal.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/nexgen32e/ffs.h"
|
||||
#include "libc/nt/enum/processcreationflags.h"
|
||||
#include "libc/nt/enum/threadpriority.h"
|
||||
|
||||
hidden const struct NtPriorityCombo kNtPriorityCombos[] = {
|
||||
{-20, ffs(kNtHighPriorityClass), kNtThreadPriorityHighest, 15},
|
||||
{-18, ffs(kNtHighPriorityClass), kNtThreadPriorityTimeCritical, 15},
|
||||
{-17, ffs(kNtNormalPriorityClass), kNtThreadPriorityTimeCritical, 15},
|
||||
{-15, ffs(kNtIdlePriorityClass), kNtThreadPriorityTimeCritical, 15},
|
||||
{-13, ffs(kNtHighPriorityClass), kNtThreadPriorityAboveNormal, 14},
|
||||
{-11, ffs(kNtHighPriorityClass), kNtThreadPriorityNormal, 13},
|
||||
{-9, ffs(kNtHighPriorityClass), kNtThreadPriorityBelowNormal, 12},
|
||||
{-7, ffs(kNtNormalPriorityClass), kNtThreadPriorityHighest, 11},
|
||||
{-5, ffs(kNtHighPriorityClass), kNtThreadPriorityLowest, 11},
|
||||
{-3, ffs(kNtNormalPriorityClass), kNtThreadPriorityAboveNormal, 10},
|
||||
{-1, ffs(kNtNormalPriorityClass), kNtThreadPriorityHighest, 9},
|
||||
{0, ffs(kNtNormalPriorityClass), kNtThreadPriorityNormal, 9},
|
||||
{1, ffs(kNtNormalPriorityClass), kNtThreadPriorityAboveNormal, 8},
|
||||
{2, ffs(kNtNormalPriorityClass), kNtThreadPriorityBelowNormal, 8},
|
||||
{3, ffs(kNtNormalPriorityClass), kNtThreadPriorityNormal, 7},
|
||||
{4, ffs(kNtNormalPriorityClass), kNtThreadPriorityLowest, 7},
|
||||
{5, ffs(kNtIdlePriorityClass), kNtThreadPriorityHighest, 6},
|
||||
{6, ffs(kNtNormalPriorityClass), kNtThreadPriorityBelowNormal, 6},
|
||||
{7, ffs(kNtIdlePriorityClass), kNtThreadPriorityAboveNormal, 5},
|
||||
{9, ffs(kNtNormalPriorityClass), kNtThreadPriorityLowest, 5},
|
||||
{11, ffs(kNtIdlePriorityClass), kNtThreadPriorityNormal, 4},
|
||||
{13, ffs(kNtIdlePriorityClass), kNtThreadPriorityBelowNormal, 3},
|
||||
{15, ffs(kNtIdlePriorityClass), kNtThreadPriorityLowest, 2},
|
||||
{17, ffs(kNtHighPriorityClass), kNtThreadPriorityIdle, 1},
|
||||
{18, ffs(kNtNormalPriorityClass), kNtThreadPriorityIdle, 1},
|
||||
{19, ffs(kNtIdlePriorityClass), kNtThreadPriorityIdle, 1},
|
||||
};
|
||||
|
||||
hidden const unsigned kNtPriorityCombosLen = ARRAYLEN(kNtPriorityCombos);
|
18
libc/calls/kntprioritycombos.internal.h
Normal file → Executable file
18
libc/calls/kntprioritycombos.internal.h
Normal file → Executable file
|
@ -1,18 +0,0 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_KNTPRIORITYCOMBOS_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_KNTPRIORITYCOMBOS_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
struct NtPriorityCombo {
|
||||
int8_t nice; /* sorted by this */
|
||||
int8_t lg2tier;
|
||||
int8_t wut;
|
||||
int8_t prio;
|
||||
};
|
||||
|
||||
hidden extern const unsigned kNtPriorityCombosLen;
|
||||
hidden extern const struct NtPriorityCombo kNtPriorityCombos[];
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_KNTPRIORITYCOMBOS_H_ */
|
|
@ -74,7 +74,7 @@
|
|||
* @threadsafe
|
||||
* @vforksafe
|
||||
*/
|
||||
int64_t lseek(int fd, int64_t offset, unsigned whence) {
|
||||
int64_t lseek(int fd, int64_t offset, int whence) {
|
||||
int64_t rc;
|
||||
if (fd < g_fds.n && g_fds.p[fd].kind == kFdZip) {
|
||||
rc = _weaken(__zipos_lseek)(
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/sysv/consts/prio.h"
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ int sys_fadvise_netbsd(int, int, int64_t, int64_t, int) asm("sys_fadvise");
|
|||
* @returnserrno
|
||||
* @threadsafe
|
||||
*/
|
||||
errno_t posix_fadvise(int fd, uint64_t offset, uint64_t len, int advice) {
|
||||
errno_t posix_fadvise(int fd, int64_t offset, int64_t len, int advice) {
|
||||
int rc, e = errno;
|
||||
if (IsLinux()) {
|
||||
rc = sys_fadvise(fd, offset, len, advice);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/sched-sysv.internal.h"
|
||||
#include "libc/calls/struct/cpuset.h"
|
||||
|
@ -32,7 +33,7 @@ static dontinline textwindows int sys_sched_setaffinity_nt(
|
|||
int rc;
|
||||
int64_t h, closeme = -1;
|
||||
|
||||
if (!pid /* || pid == getpid() */) {
|
||||
if (!pid || pid == getpid()) {
|
||||
h = GetCurrentProcess();
|
||||
} else if (__isfdkind(pid, kFdProcess)) {
|
||||
h = g_fds.p[pid].handle;
|
||||
|
|
|
@ -17,15 +17,15 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
|
||||
/**
|
||||
* Sets user id of current process for file system ops.
|
||||
* @return previous filesystem gid
|
||||
*/
|
||||
int setfsgid(int gid) {
|
||||
int setfsgid(unsigned gid) {
|
||||
int rc;
|
||||
if (IsLinux()) {
|
||||
rc = sys_setfsgid(gid);
|
||||
|
|
|
@ -17,15 +17,15 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
|
||||
/**
|
||||
* Sets user id of current process for file system ops.
|
||||
* @return previous filesystem uid
|
||||
*/
|
||||
int setfsuid(int uid) {
|
||||
int setfsuid(unsigned uid) {
|
||||
int rc;
|
||||
if (IsLinux()) {
|
||||
rc = sys_setfsuid(uid);
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
|
||||
/**
|
||||
* Sets group id of current process.
|
||||
|
@ -28,7 +28,7 @@
|
|||
* @raise EINVAL if gid not in legal range
|
||||
* @raise EPERM if lack privileges
|
||||
*/
|
||||
int setgid(int gid) {
|
||||
int setgid(unsigned gid) {
|
||||
int rc;
|
||||
if (IsWindows() && gid == getgid()) {
|
||||
rc = 0;
|
||||
|
|
|
@ -16,37 +16,60 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/calls/kntprioritycombos.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/syscall-nt.internal.h"
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/nt/enum/processaccess.h"
|
||||
#include "libc/nt/enum/processcreationflags.h"
|
||||
#include "libc/nt/process.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/nt/thread.h"
|
||||
#include "libc/sysv/consts/prio.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
static textwindows struct NtPriorityCombo findntprio(int nice) {
|
||||
size_t l, r, m;
|
||||
l = 0;
|
||||
r = kNtPriorityCombosLen;
|
||||
while (l < r) {
|
||||
m = (l + r) >> 1;
|
||||
if (kNtPriorityCombos[m].nice > nice) {
|
||||
r = m;
|
||||
} else {
|
||||
l = m + 1;
|
||||
}
|
||||
}
|
||||
return kNtPriorityCombos[max(0, l - 1)];
|
||||
}
|
||||
|
||||
textwindows int sys_setpriority_nt(int nice) {
|
||||
textwindows int sys_setpriority_nt(int which, unsigned pid, int nice) {
|
||||
int rc;
|
||||
uint32_t tier;
|
||||
struct NtPriorityCombo p;
|
||||
p = findntprio(nice);
|
||||
tier = 1 << (p.lg2tier - 1);
|
||||
if (SetPriorityClass(GetCurrentProcess(), tier) &&
|
||||
SetThreadPriority(GetCurrentThread(), p.wut)) {
|
||||
return p.nice;
|
||||
} else {
|
||||
return __winerr();
|
||||
int64_t h, closeme = -1;
|
||||
|
||||
if (which != PRIO_PROCESS) {
|
||||
return einval();
|
||||
}
|
||||
|
||||
if (!pid || pid == getpid()) {
|
||||
h = GetCurrentProcess();
|
||||
} else if (__isfdkind(pid, kFdProcess)) {
|
||||
h = g_fds.p[pid].handle;
|
||||
} else {
|
||||
h = OpenProcess(kNtProcessSetInformation | kNtProcessQueryInformation,
|
||||
false, pid);
|
||||
if (!h) return __winerr();
|
||||
closeme = h;
|
||||
}
|
||||
|
||||
if (nice <= -15) {
|
||||
tier = kNtRealtimePriorityClass;
|
||||
} else if (nice <= -9) {
|
||||
tier = kNtHighPriorityClass;
|
||||
} else if (nice <= -3) {
|
||||
tier = kNtAboveNormalPriorityClass;
|
||||
} else if (nice <= 3) {
|
||||
tier = kNtNormalPriorityClass;
|
||||
} else if (nice <= 12) {
|
||||
tier = kNtBelowNormalPriorityClass;
|
||||
} else {
|
||||
tier = kNtIdlePriorityClass;
|
||||
}
|
||||
|
||||
if (SetPriorityClass(h, tier)) {
|
||||
rc = 0;
|
||||
} else {
|
||||
rc = __winerr();
|
||||
}
|
||||
|
||||
if (closeme != -1) {
|
||||
CloseHandle(closeme);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -20,22 +20,38 @@
|
|||
#include "libc/calls/syscall-nt.internal.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
|
||||
/**
|
||||
* Sets nice value of thing.
|
||||
*
|
||||
* @param which can be PRIO_PROCESS, PRIO_PGRP, PRIO_USER
|
||||
* On Windows, there's only six priority classes. We define them as -16
|
||||
* (realtime), -10 (high), -5 (above), 0 (normal), 5 (below), 15 (idle)
|
||||
* which are the only values that'll roundtrip getpriority/setpriority.
|
||||
*
|
||||
* @param which can be one of:
|
||||
* - `PRIO_PROCESS` is supported universally
|
||||
* - `PRIO_PGRP` is supported on unix
|
||||
* - `PRIO_USER` is supported on unix
|
||||
* @param who is the pid, pgid, or uid, 0 meaning current
|
||||
* @param value ∈ [-NZERO,NZERO) which is clamped automatically
|
||||
* @return 0 on success or -1 w/ errno
|
||||
* @error EACCES if lower that RLIMIT_NICE
|
||||
* @error EACCES on Linux without CAP_SYS_NICE
|
||||
* @see getpriority(), nice()
|
||||
* @return 0 on success, or -1 w/ errno
|
||||
* @raise EINVAL if `which` was invalid or unsupported
|
||||
* @error EACCES if `value` lower that `RLIMIT_NICE`
|
||||
* @error EACCES on Linux without `CAP_SYS_NICE`
|
||||
* @raise EPERM if access to process was denied
|
||||
* @raise ESRCH if the process didn't exist
|
||||
* @see getpriority()
|
||||
*/
|
||||
int setpriority(int which, unsigned who, int value) {
|
||||
int rc;
|
||||
if (!IsWindows()) {
|
||||
return sys_setpriority(which, who, value);
|
||||
rc = sys_setpriority(which, who, value);
|
||||
} else {
|
||||
return sys_getsetpriority_nt(which, who, value, sys_setpriority_nt);
|
||||
rc = sys_setpriority_nt(which, who, value);
|
||||
}
|
||||
STRACE("setpriority(%s, %u, %d) → %d% m", DescribeWhichPrio(which), who,
|
||||
value, rc);
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
|
||||
/**
|
||||
* Sets user id of current process.
|
||||
|
@ -30,7 +30,7 @@
|
|||
* @raise EAGAIN change would cause `RLIMIT_NPROC` to be exceeded
|
||||
* @raise EPERM if lack privileges
|
||||
*/
|
||||
int setuid(int uid) {
|
||||
int setuid(unsigned uid) {
|
||||
int rc;
|
||||
if (IsWindows() && uid == getuid()) {
|
||||
rc = 0;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/calls/struct/metasigaltstack.h"
|
||||
#include "libc/calls/struct/sigaltstack.h"
|
||||
#include "libc/calls/struct/sigaltstack.internal.h"
|
||||
|
@ -24,6 +23,8 @@
|
|||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/sysv/consts/ss.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
static void sigaltstack2bsd(struct sigaltstack_bsd *bsd,
|
||||
|
@ -76,6 +77,8 @@ static void sigaltstack2linux(struct sigaltstack *linux,
|
|||
* @param neu if non-null will install new signal alt stack
|
||||
* @param old if non-null will receive current signal alt stack
|
||||
* @return 0 on success, or -1 w/ errno
|
||||
* @raise EFAULT if bad memory was supplied
|
||||
* @raise ENOMEM if `neu->ss_size` is less than `MINSIGSTKSZ`
|
||||
*/
|
||||
int sigaltstack(const struct sigaltstack *neu, struct sigaltstack *old) {
|
||||
int rc;
|
||||
|
@ -86,6 +89,8 @@ int sigaltstack(const struct sigaltstack *neu, struct sigaltstack *old) {
|
|||
(neu && (__asan_check(neu, sizeof(*neu)).kind ||
|
||||
__asan_check(neu->ss_sp, neu->ss_size).kind)))) {
|
||||
rc = efault();
|
||||
} else if (neu && neu->ss_size < MINSIGSTKSZ) {
|
||||
rc = enomem();
|
||||
} else if (IsLinux() || IsBsd()) {
|
||||
if (IsLinux()) {
|
||||
a = neu;
|
||||
|
|
|
@ -20,8 +20,13 @@ int closedir(DIR *);
|
|||
int dirfd(DIR *);
|
||||
long telldir(DIR *);
|
||||
struct dirent *readdir(DIR *);
|
||||
int readdir_r(DIR *, struct dirent *, struct dirent **);
|
||||
void rewinddir(DIR *);
|
||||
void seekdir(DIR *, long);
|
||||
int alphasort(const struct dirent **, const struct dirent **);
|
||||
int versionsort(const struct dirent **, const struct dirent **);
|
||||
int scandir(const char *, struct dirent ***, int (*)(const struct dirent *),
|
||||
int (*)(const struct dirent **, const struct dirent **));
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -20,8 +20,7 @@ int sys_fork_nt(void) hidden;
|
|||
int sys_ftruncate_nt(int64_t, uint64_t) hidden;
|
||||
int sys_getloadavg_nt(double *, int) hidden;
|
||||
int sys_getppid_nt(void) hidden;
|
||||
int sys_getpriority_nt(int) hidden;
|
||||
int sys_getsetpriority_nt(int, int, int, int (*)(int));
|
||||
int sys_getpriority_nt(int, unsigned) hidden;
|
||||
int sys_kill_nt(int, int) hidden;
|
||||
int sys_linkat_nt(int, const char *, int, const char *) hidden;
|
||||
int sys_madvise_nt(void *, size_t, int) hidden;
|
||||
|
@ -31,7 +30,7 @@ int sys_open_nt(int, const char *, uint32_t, int32_t) dontdiscard 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_setpriority_nt(int) hidden;
|
||||
int sys_setpriority_nt(int, unsigned, int) hidden;
|
||||
int sys_symlinkat_nt(const char *, int, const char *) hidden;
|
||||
int sys_sync_nt(void) hidden;
|
||||
int sys_truncate_nt(const char *, uint64_t) hidden;
|
||||
|
|
|
@ -31,8 +31,8 @@ int tcflow(int, int);
|
|||
int tcflush(int, int);
|
||||
int tcsendbreak(int, int);
|
||||
void cfmakeraw(struct termios *);
|
||||
int cfsetospeed(struct termios *, int);
|
||||
int cfsetispeed(struct termios *, int);
|
||||
int cfsetospeed(struct termios *, unsigned);
|
||||
int cfsetispeed(struct termios *, unsigned);
|
||||
uint32_t cfgetospeed(const struct termios *);
|
||||
uint32_t cfgetispeed(const struct termios *);
|
||||
|
||||
|
|
|
@ -48,6 +48,10 @@ static textwindows int sys_tkill_nt(int tid, int sig) {
|
|||
* @param tid is thread id
|
||||
* @param sig does nothing on xnu
|
||||
* @return 0 on success, or -1 w/ errno
|
||||
* @raise ESRCH if `tid` was valid but no such thread existed
|
||||
* @raise EAGAIN if `RLIMIT_SIGPENDING` was exceeded
|
||||
* @raise EINVAL if `tid` or `sig` was invalid
|
||||
* @raise EPERM if permission was denied
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
int tkill(int tid, int sig) {
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
* @see ftruncate()
|
||||
* @threadsafe
|
||||
*/
|
||||
int truncate(const char *path, uint64_t length) {
|
||||
int truncate(const char *path, int64_t length) {
|
||||
int rc;
|
||||
struct ZiposUri zipname;
|
||||
if (IsMetal()) {
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
|
||||
/**
|
||||
* Sets file mode creation mask.
|
||||
|
@ -27,7 +27,7 @@
|
|||
* @return previous mask
|
||||
* @note always succeeds
|
||||
*/
|
||||
int umask(int newmask) {
|
||||
unsigned umask(unsigned newmask) {
|
||||
int oldmask;
|
||||
if (!IsWindows()) {
|
||||
oldmask = sys_umask(newmask);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#define cc_t uint8_t
|
||||
#define clock_t int64_t /* uint64_t on xnu */
|
||||
#define dev_t uint64_t /* int32_t on xnu */
|
||||
#define fsblkcnt_t int64_t
|
||||
#define fsblkcnt_t uint64_t
|
||||
#define fsfilcnt_t int64_t /* uint32_t on xnu */
|
||||
#define gid_t uint32_t
|
||||
#define id_t uint32_t /* int32_t on linux/freebsd/etc. */
|
||||
|
@ -36,6 +36,8 @@
|
|||
#define timer_t void*
|
||||
#define uid_t uint32_t
|
||||
#define rlim_t uint64_t /* int64_t on bsd */
|
||||
#define clockid_t int32_t
|
||||
#define nlink_t uint64_t
|
||||
|
||||
#define TIME_T_MAX __INT64_MAX__
|
||||
#define TIME_T_MIN (-TIME_T_MAX - 1)
|
||||
|
|
|
@ -66,7 +66,7 @@ struct addrinfo {
|
|||
|
||||
int getaddrinfo(const char *, const char *, const struct addrinfo *,
|
||||
struct addrinfo **) paramsnonnull((4));
|
||||
int freeaddrinfo(struct addrinfo *);
|
||||
void freeaddrinfo(struct addrinfo *);
|
||||
int getnameinfo(const struct sockaddr *, socklen_t, char *, socklen_t, char *,
|
||||
socklen_t, int);
|
||||
const char *gai_strerror(int);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
* Frees addresses returned by getaddrinfo().
|
||||
* @threadsafe
|
||||
*/
|
||||
int freeaddrinfo(struct addrinfo *ai) {
|
||||
void freeaddrinfo(struct addrinfo *ai) {
|
||||
struct addrinfo *next;
|
||||
while (ai) {
|
||||
/* we assume ai_addr and ai_canonname are shoehorned */
|
||||
|
@ -31,5 +31,4 @@ int freeaddrinfo(struct addrinfo *ai) {
|
|||
free(ai);
|
||||
ai = next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
|
@ -73,7 +74,7 @@ int ResolveDns(const struct ResolvConf *resolvconf, int af, const char *name,
|
|||
SerializeDnsHeader(msg, &h);
|
||||
if ((n = SerializeDnsQuestion(msg + 12, 500, &q)) == -1) return -1;
|
||||
if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) return -1;
|
||||
if (sendto(fd, msg, 12 + n, 0, resolvconf->nameservers.p,
|
||||
if (sendto(fd, msg, 12 + n, 0, (struct sockaddr *)resolvconf->nameservers.p,
|
||||
sizeof(*resolvconf->nameservers.p)) == 12 + n &&
|
||||
(n = read(fd, msg, 512)) >= 12) {
|
||||
DeserializeDnsHeader(&h2, msg);
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/af.h"
|
||||
|
@ -75,7 +76,7 @@ int ResolveDnsReverse(const struct ResolvConf *resolvconf, int af,
|
|||
SerializeDnsHeader(msg, &h);
|
||||
if ((n = SerializeDnsQuestion(msg + 12, 500, &q)) == -1) return -1;
|
||||
if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) return -1;
|
||||
if (sendto(fd, msg, 12 + n, 0, resolvconf->nameservers.p,
|
||||
if (sendto(fd, msg, 12 + n, 0, (struct sockaddr *)resolvconf->nameservers.p,
|
||||
sizeof(*resolvconf->nameservers.p)) == 12 + n &&
|
||||
(n = read(fd, msg, 512)) >= 12) {
|
||||
DeserializeDnsHeader(&h2, msg);
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
*
|
||||
* @param s is a non-null nul-terminated string
|
||||
* @return the decoded signed saturated integer
|
||||
* @raise ERANGE on overflow
|
||||
*/
|
||||
int atoi(const char *s) {
|
||||
int x, c, d;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "libc/errno.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/fmt/strtol.internal.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/tab.internal.h"
|
||||
|
||||
|
@ -34,6 +35,7 @@
|
|||
* on the the prefixes 0 (octal), 0x (hexadecimal), 0b (binary), or
|
||||
* decimal (base 10) by default
|
||||
* @return decoded integer mod 2⁶⁴ negated if leading `-`
|
||||
* @raise ERANGE on overflow
|
||||
*/
|
||||
unsigned long strtoul(const char *s, char **endptr, int base) {
|
||||
char t = 0;
|
||||
|
@ -45,8 +47,12 @@ unsigned long strtoul(const char *s, char **endptr, int base) {
|
|||
if ((c = kBase36[c & 255]) && --c < base) {
|
||||
t |= 1;
|
||||
do {
|
||||
x *= base;
|
||||
x += c;
|
||||
if (__builtin_mul_overflow(x, base, &x) ||
|
||||
__builtin_add_overflow(x, c, &x)) {
|
||||
if (endptr) *endptr = s + 1;
|
||||
errno = ERANGE;
|
||||
return ULONG_MAX;
|
||||
}
|
||||
} while ((c = kBase36[*++s & 255]) && --c < base);
|
||||
}
|
||||
if (t && endptr) *endptr = s;
|
||||
|
|
6
libc/imag.h
Normal file
6
libc/imag.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_IMAG_H_
|
||||
#define COSMOPOLITAN_LIBC_IMAG_H_
|
||||
|
||||
#define I _Complex_I
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_IMAG_H_ */
|
|
@ -60,6 +60,7 @@ const char *DescribeSocketProtocol(char[12], int);
|
|||
const char *DescribeSocketType(char[64], int);
|
||||
const char *DescribeStdioState(char[12], int);
|
||||
const char *DescribeWhence(char[12], int);
|
||||
const char *DescribeWhichPrio(char[12], int);
|
||||
|
||||
#define DescribeArchPrctlCode(x) DescribeArchPrctlCode(alloca(12), x)
|
||||
#define DescribeCapability(x) DescribeCapability(alloca(20), x)
|
||||
|
@ -106,6 +107,7 @@ const char *DescribeWhence(char[12], int);
|
|||
#define DescribeSocketType(x) DescribeSocketType(alloca(64), x)
|
||||
#define DescribeStdioState(x) DescribeStdioState(alloca(12), x)
|
||||
#define DescribeWhence(x) DescribeWhence(alloca(12), x)
|
||||
#define DescribeWhichPrio(x) DescribeWhichPrio(alloca(12), x)
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ Copyright 2022 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
|
@ -16,14 +16,14 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/sysv/consts/prio.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
textwindows int sys_getsetpriority_nt(int which, unsigned who, int value,
|
||||
int (*impl)(int)) {
|
||||
if (which != PRIO_PROCESS && which != PRIO_PGRP) return einval();
|
||||
if (who && who != getpid() && who != gettid()) return esrch();
|
||||
return impl(value);
|
||||
const char *(DescribeWhichPrio)(char buf[12], int x) {
|
||||
if (x == PRIO_PROCESS) return "PRIO_PROCESS";
|
||||
if (x == PRIO_PGRP) return "PRIO_PGRP";
|
||||
if (x == PRIO_USER) return "PRIO_USER";
|
||||
FormatInt32(buf, x);
|
||||
return buf;
|
||||
}
|
|
@ -23,7 +23,7 @@
|
|||
/**
|
||||
* Sets value of TLS slot for current thread.
|
||||
*/
|
||||
int pthread_setspecific(pthread_key_t key, void *val) {
|
||||
int pthread_setspecific(pthread_key_t key, const void *val) {
|
||||
if (0 <= key && key < PTHREAD_KEYS_MAX) {
|
||||
__get_tls()->tib_keys[key] = val;
|
||||
return 0;
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
#ifndef LIBC_ISYSTEM_ARPA_INET_H_
|
||||
#define LIBC_ISYSTEM_ARPA_INET_H_
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#include "libc/sysv/consts/af.h"
|
||||
#include "libc/sysv/consts/inet6.h"
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef LIBC_ISYSTEM_COMPLEX_H_
|
||||
#define LIBC_ISYSTEM_COMPLEX_H_
|
||||
#include "libc/complex.h"
|
||||
#include "libc/imag.h"
|
||||
#include "libc/math.h"
|
||||
#define I _Complex_I
|
||||
#endif
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
#define LIBC_ISYSTEM_DIRENT_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/dirent.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/dt.h"
|
||||
#endif
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
#ifndef LIBC_ISYSTEM_SYS_FCNTL_H_
|
||||
#define LIBC_ISYSTEM_SYS_FCNTL_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/flock.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/at.h"
|
||||
#include "libc/sysv/consts/f.h"
|
||||
#include "libc/sysv/consts/fd.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/posix.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#endif
|
||||
|
|
6
libc/isystem/ftw.h
Normal file
6
libc/isystem/ftw.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_FTW_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_FTW_H_
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#include "third_party/musl/ftw.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_FTW_H_ */
|
4
libc/isystem/glob.h
Normal file
4
libc/isystem/glob.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_GLOB_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_GLOB_H_
|
||||
#include "third_party/musl/glob.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_GLOB_H_ */
|
|
@ -2,4 +2,6 @@
|
|||
#define LIBC_ISYSTEM_INTTYPES_H_
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/inttypes.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/literal.h"
|
||||
#endif /* LIBC_ISYSTEM_INTTYPES_H_ */
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_LANGINFO_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_LANGINFO_H_
|
||||
#include "libc/str/langinfo.h"
|
||||
#include "libc/str/locale.h"
|
||||
#include "libc/str/nltypes.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_LANGINFO_H_ */
|
||||
|
|
4
libc/isystem/libgen.h
Normal file
4
libc/isystem/libgen.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_LIBGEN_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_LIBGEN_H_
|
||||
#include "libc/fmt/conv.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_LIBGEN_H_ */
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef LIBC_ISYSTEM_LIMITS_H_
|
||||
#define LIBC_ISYSTEM_LIMITS_H_
|
||||
#include "libc/thread/thread.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/sysv/consts/_posix.h"
|
||||
#include "libc/sysv/consts/iov.h"
|
||||
#include "libc/sysv/consts/limits.h"
|
||||
#include "libc/sysv/consts/xopen.h"
|
||||
#include "libc/thread/thread.h"
|
||||
#endif
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_NETINET_IN_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_NETINET_IN_H_
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/ip_mreq.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#include "libc/sock/struct/sockaddr6.h"
|
||||
#include "libc/sysv/consts/inaddr.h"
|
||||
#include "libc/sysv/consts/inet6.h"
|
||||
#include "libc/sysv/consts/ip.h"
|
||||
#include "libc/sysv/consts/ipport.h"
|
||||
#include "libc/sysv/consts/ipproto.h"
|
||||
|
|
6
libc/isystem/netinet/tcp.h
Normal file
6
libc/isystem/netinet/tcp.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_NETINET_TCP_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_NETINET_TCP_H_
|
||||
#include "libc/sysv/consts/sol.h"
|
||||
#include "libc/sysv/consts/tcp.h"
|
||||
#include "libc/sysv/consts/tcpopt.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_NETINET_TCP_H_ */
|
4
libc/isystem/netinet/udp.h
Normal file
4
libc/isystem/netinet/udp.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_NETINET_UDP_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_NETINET_UDP_H_
|
||||
#include "libc/sysv/consts/sol.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_NETINET_UDP_H_ */
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef LIBC_ISYSTEM_POLL_H_
|
||||
#define LIBC_ISYSTEM_POLL_H_
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/pollfd.h"
|
||||
#include "libc/sysv/consts/poll.h"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#ifndef LIBC_ISYSTEM_PTHREAD_H_
|
||||
#define LIBC_ISYSTEM_PTHREAD_H_
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/clock.h"
|
||||
#include "libc/thread/thread.h"
|
||||
#include "libc/thread/thread2.h"
|
||||
#endif /* LIBC_ISYSTEM_PTHREAD_H_ */
|
||||
|
|
|
@ -3,5 +3,6 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/cpuset.h"
|
||||
#include "libc/calls/struct/sched_param.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/sched.h"
|
||||
#endif
|
||||
|
|
|
@ -6,4 +6,5 @@
|
|||
#include "libc/calls/struct/siginfo.h"
|
||||
#include "libc/sysv/consts/sa.h"
|
||||
#include "libc/sysv/consts/sicode.h"
|
||||
#include "libc/sysv/consts/ss.h"
|
||||
#endif
|
||||
|
|
5
libc/isystem/spawn.h
Normal file
5
libc/isystem/spawn.h
Normal file
|
@ -0,0 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SPAWN_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SPAWN_H_
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/stdio/spawn.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SPAWN_H_ */
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef LIBC_ISYSTEM_STDINT_H_
|
||||
#define LIBC_ISYSTEM_STDINT_H_
|
||||
#include "libc/inttypes.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/literal.h"
|
||||
#endif
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#ifndef LIBC_ISYSTEM_STDIO_H_
|
||||
#define LIBC_ISYSTEM_STDIO_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/dprintf.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/mem/fmt.h"
|
||||
#include "libc/stdio/lock.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/stdio/temp.h"
|
||||
#include "third_party/musl/tempnam.h"
|
||||
#endif
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
#ifndef LIBC_ISYSTEM_STDLIB_H_
|
||||
#define LIBC_ISYSTEM_STDLIB_H_
|
||||
#include "libc/mem/alg.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/dprintf.h"
|
||||
#include "libc/calls/termios.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/mem/alg.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
#include "libc/stdio/temp.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/exit.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
#include "third_party/getopt/getopt.h"
|
||||
#include "third_party/musl/crypt.h"
|
||||
#include "third_party/musl/rand48.h"
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_STRINGS_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_STRINGS_H_
|
||||
#include "libc/str/locale.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
||||
#include "libc/nexgen32e/ffs.h"
|
||||
#endif
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_STRINGS_H_ */
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef LIBC_ISYSTEM_SYS_SOCKET_H_
|
||||
#define LIBC_ISYSTEM_SYS_SOCKET_H_
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/linger.h"
|
||||
#include "libc/sock/struct/msghdr.h"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_STATVFS_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_STATVFS_H_
|
||||
#include "libc/calls/struct/statvfs.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/st.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_STATVFS_H_ */
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#ifndef LIBC_ISYSTEM_SYS_TIME_H_
|
||||
#define LIBC_ISYSTEM_SYS_TIME_H_
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/calls/struct/itimerval.h"
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sock/select.h"
|
||||
#include "libc/sysv/consts/clock.h"
|
||||
#include "libc/sysv/consts/itimer.h"
|
||||
#include "libc/time/struct/timezone.h"
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_TIMES_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/tms.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_TIMES_H_ */
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
#define LIBC_ISYSTEM_SYS_TYPES_H_
|
||||
#include "libc/calls/makedev.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/thread/thread.h"
|
||||
|
||||
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
||||
#include "libc/intrin/newbie.h"
|
||||
#include "libc/calls/typedef/u.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/intrin/newbie.h"
|
||||
#include "libc/sock/select.h"
|
||||
#include "libc/sysv/consts/endian.h"
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_UIO_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_UIO_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/iovec.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_UIO_H_ */
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_UN_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_UN_H_
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_UN_H_ */
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef LIBC_ISYSTEM_SYS_WAIT_H_
|
||||
#define LIBC_ISYSTEM_SYS_WAIT_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/siginfo.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/w.h"
|
||||
#include "libc/sysv/consts/waitid.h"
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_TERMIOS_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_TERMIOS_H_
|
||||
#include "libc/calls/termios.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/baud.h"
|
||||
#include "libc/sysv/consts/termios.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_TERMIOS_H_ */
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#ifndef LIBC_ISYSTEM_TGMATH_H_
|
||||
#define LIBC_ISYSTEM_TGMATH_H_
|
||||
#include "libc/complex.h"
|
||||
#include "libc/imag.h"
|
||||
#include "libc/math.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
#if __STDC_VERSION__ + 0 >= 201112
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
/* from https://en.cppreference.com/w/c/numeric/tgmath */
|
||||
|
||||
|
@ -268,8 +268,11 @@ COSMOPOLITAN_C_START_
|
|||
: remainder, long double \
|
||||
: remainderl)(x, y)
|
||||
|
||||
#define remquo(x, y) \
|
||||
_Generic((x), float : remquof, default : remquo, long double : remquol)(x, y)
|
||||
#define remquo(x, y, z) \
|
||||
_Generic((x), float \
|
||||
: remquof, default \
|
||||
: remquo, long double \
|
||||
: remquol)(x, y, z)
|
||||
|
||||
#define rint(x) \
|
||||
_Generic((x), float : rintf, default : rint, long double : rintl)(x)
|
||||
|
@ -294,38 +297,36 @@ COSMOPOLITAN_C_START_
|
|||
|
||||
#define carg(x) \
|
||||
_Generic((x), complex float \
|
||||
: cargf, complex default \
|
||||
: cargf, default \
|
||||
: carg, complex long double \
|
||||
: cargl)(x)
|
||||
|
||||
#define conj(x) \
|
||||
_Generic((x), complex float \
|
||||
: conjf, complex default \
|
||||
: conjf, default \
|
||||
: conj, complex long double \
|
||||
: conjl)(x)
|
||||
|
||||
#undef creal
|
||||
#define creal(x) \
|
||||
_Generic((x), complex float \
|
||||
: crealf, complex default \
|
||||
: crealf, default \
|
||||
: creal, complex long double \
|
||||
: creall)(x)
|
||||
|
||||
#undef cimag
|
||||
#define cimag(x) \
|
||||
_Generic((x), complex float \
|
||||
: cimagf, complex default \
|
||||
: cimagf, default \
|
||||
: cimag, complex long double \
|
||||
: cimagl)(x)
|
||||
|
||||
#define cproj(x) \
|
||||
_Generic((x), complex float \
|
||||
: cprojf, complex default \
|
||||
: cprojf, default \
|
||||
: cproj, complex long double \
|
||||
: cprojl)(x)
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
||||
#endif /* C11 */
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* LIBC_ISYSTEM_TGMATH_H_ */
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/clock.h"
|
||||
#include "libc/sysv/consts/sched.h"
|
||||
#include "libc/sysv/consts/timer.h"
|
||||
#include "libc/time/struct/tm.h"
|
||||
#include "libc/time/time.h"
|
||||
#endif
|
||||
|
|
|
@ -3,9 +3,13 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/runtime/pathconf.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/sysconf.h"
|
||||
#include "libc/sysv/consts/f.h"
|
||||
#include "libc/sysv/consts/fileno.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/ok.h"
|
||||
#include "libc/time/time.h"
|
||||
#include "third_party/getopt/getopt.h"
|
||||
#include "third_party/musl/crypt.h"
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#ifndef LIBC_ISYSTEM_WCHAR_H_
|
||||
#define LIBC_ISYSTEM_WCHAR_H_
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/unicode.h"
|
||||
#include "libc/time/time.h"
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#ifndef LIBC_ISYSTEM_WCTYPE_H_
|
||||
#define LIBC_ISYSTEM_WCTYPE_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/str/str.h"
|
||||
#endif
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#define UINT64_MAX __UINT64_MAX__
|
||||
#define INTMAX_MAX __INTMAX_MAX__
|
||||
#define UINTMAX_MAX __UINTMAX_MAX__
|
||||
#define SSIZE_MAX __INT64_MAX__
|
||||
|
||||
#define SCHAR_MIN (-SCHAR_MAX - 1)
|
||||
#define SHRT_MIN (-SHRT_MAX - 1)
|
||||
|
@ -107,22 +108,42 @@
|
|||
#define NL_SETMAX 255
|
||||
#define NL_TEXTMAX 2048
|
||||
|
||||
#define UINT_FAST64_MAX __UINT_FAST64_MAX__
|
||||
#define UINT_FAST8_MAX __UINT_FAST8_MAX__
|
||||
#define INT_FAST32_MAX __INT_FAST32_MAX__
|
||||
#define INT_FAST16_MAX __INT_FAST16_MAX__
|
||||
#define UINT_FAST32_MAX __UINT_FAST32_MAX__
|
||||
#define INT_FAST8_MAX __INT_FAST8_MAX__
|
||||
#define INT_FAST64_MAX __INT_FAST64_MAX__
|
||||
#define UINT_FAST16_MAX __UINT_FAST16_MAX__
|
||||
#define INT_FAST8_MIN (-__INT_FAST8_MAX__ - 1)
|
||||
#define INT_FAST16_MIN (-__INT_FAST16_MAX__ - 1)
|
||||
#define INT_FAST32_MIN (-__INT_FAST32_MAX__ - 1)
|
||||
#define INT_FAST64_MIN (-__INT_FAST64_MAX__ - 1)
|
||||
#define INT_LEAST8_MIN (-__INT_LEAST8_MAX__ - 1)
|
||||
#define INT_LEAST16_MIN (-__INT_LEAST16_MAX__ - 1)
|
||||
#define INT_LEAST32_MIN (-__INT_LEAST32_MAX__ - 1)
|
||||
#define INT_LEAST64_MIN (-__INT_LEAST64_MAX__ - 1)
|
||||
#define INT_FAST8_MAX __INT_FAST8_MAX__
|
||||
#define INT_FAST16_MAX __INT_FAST16_MAX__
|
||||
#define INT_FAST32_MAX __INT_FAST32_MAX__
|
||||
#define INT_FAST64_MAX __INT_FAST64_MAX__
|
||||
#define INT_LEAST8_MAX __INT_LEAST8_MAX__
|
||||
#define INT_LEAST16_MAX __INT_LEAST16_MAX__
|
||||
#define INT_LEAST32_MAX __INT_LEAST32_MAX__
|
||||
#define INT_LEAST64_MAX __INT_LEAST64_MAX__
|
||||
#define UINT_FAST8_MAX __UINT_FAST8_MAX__
|
||||
#define UINT_FAST16_MAX __UINT_FAST16_MAX__
|
||||
#define UINT_FAST32_MAX __UINT_FAST32_MAX__
|
||||
#define UINT_FAST64_MAX __UINT_FAST64_MAX__
|
||||
#define UINT_LEAST8_MAX __UINT_LEAST8_MAX__
|
||||
#define UINT_LEAST16_MAX __UINT_LEAST16_MAX__
|
||||
#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__
|
||||
#define UINT_LEAST64_MAX __UINT_LEAST64_MAX__
|
||||
|
||||
#define UINT_FAST64_MIN (-UINT_FAST64_MAX - 1)
|
||||
#define UINT_FAST8_MIN (-UINT_FAST8_MAX - 1)
|
||||
#define INT_FAST32_MIN (-INT_FAST32_MAX - 1)
|
||||
#define INT_FAST16_MIN (-INT_FAST16_MAX - 1)
|
||||
#define UINT_FAST32_MIN (-UINT_FAST32_MAX - 1)
|
||||
#define INT_FAST8_MIN (-INT_FAST8_MAX - 1)
|
||||
#define INT_FAST64_MIN (-INT_FAST64_MAX - 1)
|
||||
#define UINT_FAST16_MIN (-UINT_FAST16_MAX - 1)
|
||||
#define BC_BASE_MAX 99
|
||||
#define BC_DIM_MAX 2048
|
||||
#define BC_SCALE_MAX 99
|
||||
#define BC_STRING_MAX 1000
|
||||
#define CHARCLASS_NAME_MAX 14
|
||||
#define COLL_WEIGHTS_MAX 2
|
||||
#define EXPR_NEST_MAX 32
|
||||
#define LINE_MAX 4096
|
||||
#define RE_DUP_MAX 255
|
||||
#define LONG_BIT 64
|
||||
#define NZERO 20
|
||||
#define NL_LANGMAX 32
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_LIMITS_H_ */
|
||||
|
|
|
@ -22,6 +22,14 @@
|
|||
#define UINT64_C(c) c##UL
|
||||
#endif
|
||||
|
||||
#if UINTPTR_MAX == UINT64_MAX
|
||||
#define INTMAX_C(c) c##L
|
||||
#define UINTMAX_C(c) c##UL
|
||||
#else
|
||||
#define INTMAX_C(c) c##LL
|
||||
#define UINTMAX_C(c) c##ULL
|
||||
#endif
|
||||
|
||||
#if __SIZEOF_INTMAX__ == 16
|
||||
#define INT128_C(c) ((intmax_t)(c))
|
||||
#define UINT128_C(c) ((uintmax_t)(c))
|
||||
|
|
|
@ -278,6 +278,7 @@ static wontreturn relegated noinstrument void __minicrash(int sig,
|
|||
* @vforksafe
|
||||
*/
|
||||
relegated void __oncrash(int sig, struct siginfo *si, ucontext_t *ctx) {
|
||||
kprintf("oncrash\n");
|
||||
intptr_t rip;
|
||||
int me, owner;
|
||||
int gdbpid, err;
|
||||
|
|
20
libc/math.h
20
libc/math.h
|
@ -64,8 +64,8 @@
|
|||
#define FP_ZERO 2
|
||||
#define FP_SUBNORMAL 3
|
||||
#define FP_NORMAL 4
|
||||
#define FP_ILOGB0 (-2147483647-1)
|
||||
#define FP_ILOGBNAN (-2147483647-1)
|
||||
#define FP_ILOGB0 (-2147483647 - 1)
|
||||
#define FP_ILOGBNAN (-2147483647 - 1)
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
@ -99,6 +99,8 @@ typedef double double_t;
|
|||
#define fpclassify(x) \
|
||||
__builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)
|
||||
|
||||
extern int signgam;
|
||||
|
||||
double acos(double);
|
||||
double acosh(double);
|
||||
double asin(double);
|
||||
|
@ -307,6 +309,20 @@ void sincosl(long double, long double *, long double *);
|
|||
float fsumf(const float *, size_t);
|
||||
double fsum(const double *, size_t);
|
||||
|
||||
double j0(double);
|
||||
double j1(double);
|
||||
double jn(int, double);
|
||||
float j0f(float);
|
||||
float j1f(float);
|
||||
float jnf(int, float);
|
||||
|
||||
double y0(double);
|
||||
double y1(double);
|
||||
double yn(int, double);
|
||||
float y0f(float);
|
||||
float y1f(float);
|
||||
float ynf(int, float);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_MATH_H_ */
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
.privileged
|
||||
|
||||
// Loads previously saved processor state.
|
||||
//
|
||||
|
@ -42,3 +41,4 @@ longjmp:
|
|||
jmp *56(%rdi)
|
||||
.endfn longjmp,globl
|
||||
.alias longjmp,_longjmp
|
||||
.alias longjmp,siglongjmp
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
// Saves caller CPU state to cacheline.
|
||||
// Saves cpu state.
|
||||
//
|
||||
// @param rdi points to jmp_buf
|
||||
// @return rax 0 when set and !0 when longjmp'd
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ Copyright 2022 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
|
@ -16,32 +16,17 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
|
||||
rintf: .leafprologue
|
||||
.profilable
|
||||
movaps %xmm0,%xmm1
|
||||
movss .LC8(%rip),%xmm2
|
||||
andps %xmm2,%xmm1
|
||||
movss .LC7(%rip),%xmm3
|
||||
comiss %xmm1,%xmm3
|
||||
jbe 1f
|
||||
addss %xmm3,%xmm1
|
||||
andnps %xmm0,%xmm2
|
||||
movaps %xmm2,%xmm0
|
||||
subss %xmm3,%xmm1
|
||||
orps %xmm1,%xmm0
|
||||
1: .leafepilogue
|
||||
.endfn rintf,globl
|
||||
|
||||
.rodata.cst4
|
||||
.LC7: .long 1258291200
|
||||
|
||||
.rodata.cst16
|
||||
.LC8: .long 2147483647
|
||||
.long 0
|
||||
.long 0
|
||||
.long 0
|
||||
|
||||
// TODO(jart):
|
||||
// vroundss $4,%xmm0,%xmm0,%xmm0
|
||||
// kudos rich felker for the brilliant design
|
||||
hidden int __sigsetjmp_tail(sigjmp_buf jb, int rc) {
|
||||
_Static_assert(
|
||||
sizeof(sigjmp_buf) == sizeof(jmp_buf) + 8 + 8 + sizeof(sigset_t),
|
||||
"please recompute sigjmp_buf w.r.t. sigset_t");
|
||||
void *p = (char *)jb + sizeof(jmp_buf) + 8 + 8;
|
||||
_npassert(!sigprocmask(SIG_SETMASK, rc ? p : 0, rc ? 0 : p));
|
||||
return rc;
|
||||
}
|
56
libc/runtime/daemon.c
Normal file
56
libc/runtime/daemon.c
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2022 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/paths.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
|
||||
/**
|
||||
* Daemonizes process.
|
||||
*/
|
||||
int daemon(int nochdir, int noclose) {
|
||||
int fd;
|
||||
|
||||
switch (fork()) {
|
||||
case -1:
|
||||
return (-1);
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
_Exit(0);
|
||||
}
|
||||
|
||||
if (setsid() == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!nochdir) {
|
||||
chdir("/");
|
||||
}
|
||||
|
||||
if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR)) != -1) {
|
||||
dup2(fd, 0);
|
||||
dup2(fd, 1);
|
||||
dup2(fd, 2);
|
||||
if (fd > 2) {
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -34,6 +34,7 @@
|
|||
#include "libc/stdalign.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/nrlinux.h"
|
||||
#include "libc/thread/posixthread.internal.h"
|
||||
#include "libc/thread/tls.h"
|
||||
#include "third_party/xed/x86.h"
|
||||
|
||||
|
@ -57,6 +58,7 @@ typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(1)));
|
|||
|
||||
__msabi extern typeof(TlsAlloc) *const __imp_TlsAlloc;
|
||||
|
||||
struct PosixThread _pthread_main;
|
||||
extern unsigned char __tls_mov_nt_rax[];
|
||||
extern unsigned char __tls_add_nt_rax[];
|
||||
_Alignas(TLS_ALIGNMENT) static char __static_tls[5008];
|
||||
|
@ -127,6 +129,7 @@ privileged void __enable_tls(void) {
|
|||
tib->tib_self = tib;
|
||||
tib->tib_self2 = tib;
|
||||
tib->tib_errno = __errno;
|
||||
tib->tib_pthread = (pthread_t)&_pthread_main;
|
||||
if (IsLinux()) {
|
||||
// gnu/systemd guarantees pid==tid for the main thread so we can
|
||||
// avoid issuing a superfluous system call at startup in program
|
||||
|
@ -134,6 +137,9 @@ privileged void __enable_tls(void) {
|
|||
} else {
|
||||
tib->tib_tid = sys_gettid();
|
||||
}
|
||||
_pthread_main.tib = tib;
|
||||
_pthread_main.tid = tib->tib_tid;
|
||||
_pthread_main.flags = PT_MAINTHREAD;
|
||||
__repmovsb(tls, _tdata_start, _TLDZ);
|
||||
|
||||
// ask the operating system to change the x86 segment register
|
||||
|
|
119
libc/runtime/fenv.S
Normal file
119
libc/runtime/fenv.S
Normal file
|
@ -0,0 +1,119 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ │
|
||||
│ Musl Libc │
|
||||
│ Copyright © 2005-2014 Rich Felker, et al. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
feclearexcept:
|
||||
# maintain exceptions in the sse mxcsr, clear x87 exceptions
|
||||
mov %edi,%ecx
|
||||
and $0x3f,%ecx
|
||||
fnstsw %ax
|
||||
test %eax,%ecx
|
||||
jz 1f
|
||||
fnclex
|
||||
1: stmxcsr -8(%rsp)
|
||||
and $0x3f,%eax
|
||||
or %eax,-8(%rsp)
|
||||
test %ecx,-8(%rsp)
|
||||
jz 1f
|
||||
not %ecx
|
||||
and %ecx,-8(%rsp)
|
||||
ldmxcsr -8(%rsp)
|
||||
1: xor %eax,%eax
|
||||
ret
|
||||
.endfn feclearexcept,globl
|
||||
|
||||
feraiseexcept:
|
||||
and $0x3f,%edi
|
||||
stmxcsr -8(%rsp)
|
||||
or %edi,-8(%rsp)
|
||||
ldmxcsr -8(%rsp)
|
||||
xor %eax,%eax
|
||||
ret
|
||||
.endfn feraiseexcept,globl
|
||||
|
||||
__fesetround:
|
||||
push %rax
|
||||
xor %eax,%eax
|
||||
mov %edi,%ecx
|
||||
fnstcw (%rsp)
|
||||
andb $0xf3,1(%rsp)
|
||||
or %ch,1(%rsp)
|
||||
fldcw (%rsp)
|
||||
stmxcsr (%rsp)
|
||||
shl $3,%ch
|
||||
andb $0x9f,1(%rsp)
|
||||
or %ch,1(%rsp)
|
||||
ldmxcsr (%rsp)
|
||||
pop %rcx
|
||||
ret
|
||||
.endfn __fesetround,globl,hidden
|
||||
|
||||
fegetround:
|
||||
push %rax
|
||||
stmxcsr (%rsp)
|
||||
pop %rax
|
||||
shr $3,%eax
|
||||
and $0xc00,%eax
|
||||
ret
|
||||
.endfn fegetround,globl
|
||||
|
||||
fegetenv:
|
||||
xor %eax,%eax
|
||||
fnstenv (%rdi)
|
||||
stmxcsr 28(%rdi)
|
||||
ret
|
||||
.endfn fegetenv,globl
|
||||
|
||||
fesetenv:
|
||||
xor %eax,%eax
|
||||
inc %rdi
|
||||
jz 1f
|
||||
fldenv -1(%rdi)
|
||||
ldmxcsr 27(%rdi)
|
||||
ret
|
||||
1: push %rax
|
||||
push %rax
|
||||
pushq $0xffff
|
||||
pushq $0x37f
|
||||
fldenv (%rsp)
|
||||
pushq $0x1f80
|
||||
ldmxcsr (%rsp)
|
||||
add $40,%rsp
|
||||
ret
|
||||
.endfn fesetenv,globl
|
||||
|
||||
fetestexcept:
|
||||
and $0x3f,%edi
|
||||
push %rax
|
||||
stmxcsr (%rsp)
|
||||
pop %rsi
|
||||
fnstsw %ax
|
||||
or %esi,%eax
|
||||
and %edi,%eax
|
||||
ret
|
||||
.endfn fetestexcept,globl
|
|
@ -7,16 +7,24 @@
|
|||
#define FE_TOWARDZERO 0x0c00
|
||||
|
||||
#define FE_INVALID 1
|
||||
#define __FE_DENORM 2
|
||||
#define FE_DIVBYZERO 4
|
||||
#define FE_OVERFLOW 8
|
||||
#define FE_UNDERFLOW 16
|
||||
#define FE_INEXACT 32
|
||||
#define FE_ALL_EXCEPT 61
|
||||
#define FE_ALL_EXCEPT 63
|
||||
|
||||
#ifdef __FLT_EVAL_METHOD__
|
||||
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
|
||||
#else
|
||||
#define FLT_EVAL_METHOD 0
|
||||
#endif
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#define FLT_ROUNDS (__flt_rounds())
|
||||
#define FE_DFL_ENV ((const fenv_t *)-1)
|
||||
|
||||
typedef void *fenv_t;
|
||||
typedef uint16_t fexcept_t;
|
||||
|
|
|
@ -7,6 +7,7 @@ COSMOPOLITAN_C_START_
|
|||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
|
||||
typedef long jmp_buf[8];
|
||||
typedef long sigjmp_buf[12];
|
||||
|
||||
extern char **environ; /* CRT */
|
||||
extern int __argc; /* CRT */
|
||||
|
@ -49,6 +50,7 @@ extern size_t __virtualmax;
|
|||
extern bool __isworker;
|
||||
|
||||
void mcount(void);
|
||||
int daemon(int, int);
|
||||
int _freestack(void *);
|
||||
void _bt(const char *, ...);
|
||||
unsigned long getauxval(unsigned long);
|
||||
|
@ -60,6 +62,8 @@ void longjmp(jmp_buf, int) libcesque wontreturn paramsnonnull();
|
|||
axdx_t setlongerjmp(jmp_buf) libcesque returnstwice paramsnonnull();
|
||||
void longerjmp(jmp_buf, intptr_t) libcesque wontreturn paramsnonnull();
|
||||
int _setjmp(jmp_buf) libcesque returnstwice paramsnonnull();
|
||||
int sigsetjmp(sigjmp_buf, int) libcesque returnstwice paramsnonnull();
|
||||
void siglongjmp(sigjmp_buf, int) libcesque wontreturn paramsnonnull();
|
||||
void _longjmp(jmp_buf, int) libcesque wontreturn paramsnonnull();
|
||||
void exit(int) wontreturn;
|
||||
void _exit(int) libcesque wontreturn;
|
||||
|
|
49
libc/runtime/sigsetjmp.S
Normal file
49
libc/runtime/sigsetjmp.S
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ │
|
||||
│ Musl Libc │
|
||||
│ Copyright © 2005-2014 Rich Felker, et al. │
|
||||
│ │
|
||||
│ Permission is hereby granted, free of charge, to any person obtaining │
|
||||
│ a copy of this software and associated documentation files (the │
|
||||
│ "Software"), to deal in the Software without restriction, including │
|
||||
│ without limitation the rights to use, copy, modify, merge, publish, │
|
||||
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
||||
│ permit persons to whom the Software is furnished to do so, subject to │
|
||||
│ the following conditions: │
|
||||
│ │
|
||||
│ The above copyright notice and this permission notice shall be │
|
||||
│ included in all copies or substantial portions of the Software. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
||||
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
||||
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
||||
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
||||
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
||||
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
||||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
// Saves caller CPU state and signal mask.
|
||||
//
|
||||
// @param rdi points to jmp_buf
|
||||
// @param esi if non-zero will cause mask to be saved
|
||||
// @return eax 0 when set and !0 when longjmp'd
|
||||
// @returnstwice
|
||||
sigsetjmp:
|
||||
test %esi,%esi
|
||||
jz setjmp
|
||||
popq 64(%rdi)
|
||||
mov %rbx,72(%rdi)
|
||||
mov %rdi,%rbx
|
||||
call setjmp
|
||||
pushq 64(%rbx)
|
||||
mov %rbx,%rdi
|
||||
mov %eax,%esi
|
||||
mov 72(%rdi),%rbx
|
||||
jmp __sigsetjmp_tail
|
||||
.hidden __sigsetjmp_tail
|
||||
.endfn sigsetjmp,globl
|
|
@ -1,13 +1,147 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_RUNTIME_SYSCONF_H_
|
||||
#define COSMOPOLITAN_LIBC_RUNTIME_SYSCONF_H_
|
||||
|
||||
#define _SC_ARG_MAX 0
|
||||
#define _SC_CHILD_MAX 1
|
||||
#define _SC_CLK_TCK 2
|
||||
#define _SC_OPEN_MAX 4
|
||||
#define _SC_PAGESIZE 30
|
||||
#define _SC_PAGE_SIZE 30
|
||||
#define _SC_NPROCESSORS_ONLN 1002
|
||||
#define _SC_ARG_MAX 0
|
||||
#define _SC_CHILD_MAX 1
|
||||
#define _SC_CLK_TCK 2
|
||||
#define _SC_NGROUPS_MAX 3
|
||||
#define _SC_OPEN_MAX 4
|
||||
#define _SC_STREAM_MAX 5
|
||||
#define _SC_TZNAME_MAX 6
|
||||
#define _SC_JOB_CONTROL 7
|
||||
#define _SC_SAVED_IDS 8
|
||||
#define _SC_REALTIME_SIGNALS 9
|
||||
#define _SC_PRIORITY_SCHEDULING 10
|
||||
#define _SC_TIMERS 11
|
||||
#define _SC_ASYNCHRONOUS_IO 12
|
||||
#define _SC_PRIORITIZED_IO 13
|
||||
#define _SC_SYNCHRONIZED_IO 14
|
||||
#define _SC_FSYNC 15
|
||||
#define _SC_MAPPED_FILES 16
|
||||
#define _SC_MEMLOCK 17
|
||||
#define _SC_MEMLOCK_RANGE 18
|
||||
#define _SC_MEMORY_PROTECTION 19
|
||||
#define _SC_MESSAGE_PASSING 20
|
||||
#define _SC_SEMAPHORES 21
|
||||
#define _SC_SHARED_MEMORY_OBJECTS 22
|
||||
#define _SC_AIO_LISTIO_MAX 23
|
||||
#define _SC_AIO_MAX 24
|
||||
#define _SC_AIO_PRIO_DELTA_MAX 25
|
||||
#define _SC_DELAYTIMER_MAX 26
|
||||
#define _SC_MQ_OPEN_MAX 27
|
||||
#define _SC_MQ_PRIO_MAX 28
|
||||
#define _SC_VERSION 29
|
||||
#define _SC_PAGE_SIZE 30
|
||||
#define _SC_PAGESIZE 30 /* !! */
|
||||
#define _SC_RTSIG_MAX 31
|
||||
#define _SC_SEM_NSEMS_MAX 32
|
||||
#define _SC_SEM_VALUE_MAX 33
|
||||
#define _SC_SIGQUEUE_MAX 34
|
||||
#define _SC_TIMER_MAX 35
|
||||
#define _SC_BC_BASE_MAX 36
|
||||
#define _SC_BC_DIM_MAX 37
|
||||
#define _SC_BC_SCALE_MAX 38
|
||||
#define _SC_BC_STRING_MAX 39
|
||||
#define _SC_COLL_WEIGHTS_MAX 40
|
||||
#define _SC_EXPR_NEST_MAX 42
|
||||
#define _SC_LINE_MAX 43
|
||||
#define _SC_RE_DUP_MAX 44
|
||||
#define _SC_2_VERSION 46
|
||||
#define _SC_2_C_BIND 47
|
||||
#define _SC_2_C_DEV 48
|
||||
#define _SC_2_FORT_DEV 49
|
||||
#define _SC_2_FORT_RUN 50
|
||||
#define _SC_2_SW_DEV 51
|
||||
#define _SC_2_LOCALEDEF 52
|
||||
#define _SC_UIO_MAXIOV 60 /* !! */
|
||||
#define _SC_IOV_MAX 60
|
||||
#define _SC_THREADS 67
|
||||
#define _SC_THREAD_SAFE_FUNCTIONS 68
|
||||
#define _SC_GETGR_R_SIZE_MAX 69
|
||||
#define _SC_GETPW_R_SIZE_MAX 70
|
||||
#define _SC_LOGIN_NAME_MAX 71
|
||||
#define _SC_TTY_NAME_MAX 72
|
||||
#define _SC_THREAD_DESTRUCTOR_ITERATIONS 73
|
||||
#define _SC_THREAD_KEYS_MAX 74
|
||||
#define _SC_THREAD_STACK_MIN 75
|
||||
#define _SC_THREAD_THREADS_MAX 76
|
||||
#define _SC_THREAD_ATTR_STACKADDR 77
|
||||
#define _SC_THREAD_ATTR_STACKSIZE 78
|
||||
#define _SC_THREAD_PRIORITY_SCHEDULING 79
|
||||
#define _SC_THREAD_PRIO_INHERIT 80
|
||||
#define _SC_THREAD_PRIO_PROTECT 81
|
||||
#define _SC_THREAD_PROCESS_SHARED 82
|
||||
#define _SC_NPROCESSORS_CONF 83
|
||||
#define _SC_NPROCESSORS_ONLN 84
|
||||
#define _SC_PHYS_PAGES 85
|
||||
#define _SC_AVPHYS_PAGES 86
|
||||
#define _SC_ATEXIT_MAX 87
|
||||
#define _SC_PASS_MAX 88
|
||||
#define _SC_XOPEN_VERSION 89
|
||||
#define _SC_XOPEN_XCU_VERSION 90
|
||||
#define _SC_XOPEN_UNIX 91
|
||||
#define _SC_XOPEN_CRYPT 92
|
||||
#define _SC_XOPEN_ENH_I18N 93
|
||||
#define _SC_XOPEN_SHM 94
|
||||
#define _SC_2_CHAR_TERM 95
|
||||
#define _SC_2_UPE 97
|
||||
#define _SC_XOPEN_XPG2 98
|
||||
#define _SC_XOPEN_XPG3 99
|
||||
#define _SC_XOPEN_XPG4 100
|
||||
#define _SC_NZERO 109
|
||||
#define _SC_XBS5_ILP32_OFF32 125
|
||||
#define _SC_XBS5_ILP32_OFFBIG 126
|
||||
#define _SC_XBS5_LP64_OFF64 127
|
||||
#define _SC_XBS5_LPBIG_OFFBIG 128
|
||||
#define _SC_XOPEN_LEGACY 129
|
||||
#define _SC_XOPEN_REALTIME 130
|
||||
#define _SC_XOPEN_REALTIME_THREADS 131
|
||||
#define _SC_ADVISORY_INFO 132
|
||||
#define _SC_BARRIERS 133
|
||||
#define _SC_CLOCK_SELECTION 137
|
||||
#define _SC_CPUTIME 138
|
||||
#define _SC_THREAD_CPUTIME 139
|
||||
#define _SC_MONOTONIC_CLOCK 149
|
||||
#define _SC_READER_WRITER_LOCKS 153
|
||||
#define _SC_SPIN_LOCKS 154
|
||||
#define _SC_REGEXP 155
|
||||
#define _SC_SHELL 157
|
||||
#define _SC_SPAWN 159
|
||||
#define _SC_SPORADIC_SERVER 160
|
||||
#define _SC_THREAD_SPORADIC_SERVER 161
|
||||
#define _SC_TIMEOUTS 164
|
||||
#define _SC_TYPED_MEMORY_OBJECTS 165
|
||||
#define _SC_2_PBS 168
|
||||
#define _SC_2_PBS_ACCOUNTING 169
|
||||
#define _SC_2_PBS_LOCATE 170
|
||||
#define _SC_2_PBS_MESSAGE 171
|
||||
#define _SC_2_PBS_TRACK 172
|
||||
#define _SC_SYMLOOP_MAX 173
|
||||
#define _SC_STREAMS 174
|
||||
#define _SC_2_PBS_CHECKPOINT 175
|
||||
#define _SC_V6_ILP32_OFF32 176
|
||||
#define _SC_V6_ILP32_OFFBIG 177
|
||||
#define _SC_V6_LP64_OFF64 178
|
||||
#define _SC_V6_LPBIG_OFFBIG 179
|
||||
#define _SC_HOST_NAME_MAX 180
|
||||
#define _SC_TRACE 181
|
||||
#define _SC_TRACE_EVENT_FILTER 182
|
||||
#define _SC_TRACE_INHERIT 183
|
||||
#define _SC_TRACE_LOG 184
|
||||
#define _SC_IPV6 235
|
||||
#define _SC_RAW_SOCKETS 236
|
||||
#define _SC_V7_ILP32_OFF32 237
|
||||
#define _SC_V7_ILP32_OFFBIG 238
|
||||
#define _SC_V7_LP64_OFF64 239
|
||||
#define _SC_V7_LPBIG_OFFBIG 240
|
||||
#define _SC_SS_REPL_MAX 241
|
||||
#define _SC_TRACE_EVENT_NAME_MAX 242
|
||||
#define _SC_TRACE_NAME_MAX 243
|
||||
#define _SC_TRACE_SYS_MAX 244
|
||||
#define _SC_TRACE_USER_EVENT_MAX 245
|
||||
#define _SC_XOPEN_STREAMS 246
|
||||
#define _SC_THREAD_ROBUST_PRIO_INHERIT 247
|
||||
#define _SC_THREAD_ROBUST_PRIO_PROTECT 248
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
|
|
@ -17,11 +17,12 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#include "libc/sock/struct/sockaddr.internal.h"
|
||||
#include "libc/sock/syscall_fd.internal.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
@ -38,7 +39,8 @@
|
|||
* @asyncsignalsafe
|
||||
* @restartable (unless SO_RCVTIMEO)
|
||||
*/
|
||||
int accept4(int fd, void *out_addr, uint32_t *inout_addrsize, int flags) {
|
||||
int accept4(int fd, struct sockaddr *out_addr, uint32_t *inout_addrsize,
|
||||
int flags) {
|
||||
int rc;
|
||||
char addrbuf[72];
|
||||
if (!out_addr || !inout_addrsize ||
|
||||
|
|
|
@ -17,11 +17,12 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#include "libc/sock/struct/sockaddr.internal.h"
|
||||
#include "libc/sock/syscall_fd.internal.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
@ -40,7 +41,7 @@
|
|||
* @error ENETDOWN, EPFNOSUPPORT, etc.
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
int bind(int fd, const void *addr, uint32_t addrsize) {
|
||||
int bind(int fd, const struct sockaddr *addr, uint32_t addrsize) {
|
||||
int rc;
|
||||
if (!addr || (IsAsan() && !__asan_is_valid(addr, addrsize))) {
|
||||
rc = efault();
|
||||
|
|
|
@ -17,11 +17,12 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#include "libc/sock/struct/sockaddr.internal.h"
|
||||
#include "libc/sock/syscall_fd.internal.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
@ -37,7 +38,7 @@
|
|||
* @asyncsignalsafe
|
||||
* @restartable (unless SO_RCVTIMEO)
|
||||
*/
|
||||
int connect(int fd, const void *addr, uint32_t addrsize) {
|
||||
int connect(int fd, const struct sockaddr *addr, uint32_t addrsize) {
|
||||
int rc;
|
||||
if (addr && !(IsAsan() && !__asan_is_valid(addr, addrsize))) {
|
||||
if (!IsWindows()) {
|
||||
|
|
|
@ -17,11 +17,12 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#include "libc/sock/struct/sockaddr.internal.h"
|
||||
#include "libc/sock/syscall_fd.internal.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
@ -31,7 +32,7 @@
|
|||
* @return 0 on success or -1 w/ errno
|
||||
* @see getsockname()
|
||||
*/
|
||||
int getpeername(int fd, void *out_addr, uint32_t *out_addrsize) {
|
||||
int getpeername(int fd, struct sockaddr *out_addr, uint32_t *out_addrsize) {
|
||||
int rc;
|
||||
if (!out_addr || !out_addrsize ||
|
||||
(IsAsan() && (!__asan_is_valid(out_addrsize, 4) ||
|
||||
|
|
|
@ -17,11 +17,12 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#include "libc/sock/struct/sockaddr.internal.h"
|
||||
#include "libc/sock/syscall_fd.internal.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
@ -31,7 +32,7 @@
|
|||
* @return 0 on success or -1 w/ errno
|
||||
* @see getpeername()
|
||||
*/
|
||||
int getsockname(int fd, void *out_addr, uint32_t *out_addrsize) {
|
||||
int getsockname(int fd, struct sockaddr *out_addr, uint32_t *out_addrsize) {
|
||||
int rc;
|
||||
if (!out_addrsize || !out_addrsize ||
|
||||
(IsAsan() && (!__asan_is_valid(out_addrsize, 4) ||
|
||||
|
|
|
@ -17,14 +17,15 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/calls/struct/iovec.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/nt/winsock.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#include "libc/sock/struct/sockaddr.internal.h"
|
||||
#include "libc/sock/syscall_fd.internal.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
@ -47,7 +48,8 @@
|
|||
* @restartable (unless SO_RCVTIMEO)
|
||||
*/
|
||||
ssize_t recvfrom(int fd, void *buf, size_t size, uint32_t flags,
|
||||
void *opt_out_srcaddr, uint32_t *opt_inout_srcaddrsize) {
|
||||
struct sockaddr *opt_out_srcaddr,
|
||||
uint32_t *opt_inout_srcaddrsize) {
|
||||
ssize_t rc;
|
||||
uint32_t sz;
|
||||
union sockaddr_storage_bsd bsd;
|
||||
|
@ -65,7 +67,8 @@ ssize_t recvfrom(int fd, void *buf, size_t size, uint32_t flags,
|
|||
} else {
|
||||
sz = sizeof(bsd);
|
||||
if ((rc = sys_recvfrom(fd, buf, size, flags, &bsd, &sz)) != -1) {
|
||||
sockaddr2linux(&bsd, sz, opt_out_srcaddr, opt_inout_srcaddrsize);
|
||||
sockaddr2linux(&bsd, sz, (void *)opt_out_srcaddr,
|
||||
opt_inout_srcaddrsize);
|
||||
}
|
||||
}
|
||||
} else if (__isfdopen(fd)) {
|
||||
|
|
|
@ -18,14 +18,15 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/calls/struct/iovec.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#include "libc/sock/struct/sockaddr.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
@ -52,7 +53,7 @@
|
|||
* @restartable (unless SO_RCVTIMEO)
|
||||
*/
|
||||
ssize_t sendto(int fd, const void *buf, size_t size, uint32_t flags,
|
||||
const void *opt_addr, uint32_t addrsize) {
|
||||
const struct sockaddr *opt_addr, uint32_t addrsize) {
|
||||
ssize_t rc;
|
||||
uint32_t bsdaddrsize;
|
||||
union sockaddr_storage_bsd bsd;
|
||||
|
|
|
@ -29,21 +29,14 @@ uint32_t *GetHostIps(void);
|
|||
|
||||
int nointernet(void);
|
||||
int socket(int, int, int);
|
||||
int accept4(int, void *, uint32_t *, int);
|
||||
int bind(int, const void *, uint32_t);
|
||||
int connect(int, const void *, uint32_t);
|
||||
int listen(int, int);
|
||||
int shutdown(int, int);
|
||||
int getsockname(int, void *, uint32_t *);
|
||||
int getpeername(int, void *, uint32_t *);
|
||||
ssize_t send(int, const void *, size_t, int);
|
||||
ssize_t recv(int, void *, size_t, int);
|
||||
ssize_t recvfrom(int, void *, size_t, uint32_t, void *, uint32_t *);
|
||||
ssize_t sendfile(int, int, int64_t *, size_t);
|
||||
int getsockopt(int, int, int, void *, uint32_t *);
|
||||
int setsockopt(int, int, int, const void *, uint32_t);
|
||||
int socketpair(int, int, int, int[2]);
|
||||
ssize_t sendto(int, const void *, size_t, uint32_t, const void *, uint32_t);
|
||||
int sockatmark(int);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
|
@ -8,10 +8,11 @@ struct msghdr { /* Linux+NT ABI */
|
|||
void *msg_name; /* optional address */
|
||||
uint32_t msg_namelen; /* size of msg_name */
|
||||
struct iovec *msg_iov; /* scatter/gather array */
|
||||
uint64_t msg_iovlen; /* iovec count */
|
||||
int msg_iovlen; /* iovec count */
|
||||
void *msg_control; /* credentials and stuff */
|
||||
uint64_t msg_controllen; /* size of msg_control */
|
||||
uint32_t msg_flags; /* MSG_XXX */
|
||||
uint32_t msg_controllen; /* size of msg_control */
|
||||
uint32_t __pad0; /* reconcile abi */
|
||||
int msg_flags; /* MSG_XXX */
|
||||
};
|
||||
|
||||
ssize_t recvmsg(int, struct msghdr *, int);
|
||||
|
|
|
@ -36,6 +36,14 @@ struct sockaddr_storage {
|
|||
int inet_aton(const char *, struct in_addr *);
|
||||
char *inet_ntoa(struct in_addr);
|
||||
int accept(int, struct sockaddr *, uint32_t *);
|
||||
int accept4(int, struct sockaddr *, uint32_t *, int);
|
||||
int bind(int, const struct sockaddr *, uint32_t);
|
||||
int connect(int, const struct sockaddr *, uint32_t);
|
||||
int getsockname(int, struct sockaddr *, uint32_t *);
|
||||
int getpeername(int, struct sockaddr *, uint32_t *);
|
||||
ssize_t recvfrom(int, void *, size_t, uint32_t, struct sockaddr *, uint32_t *);
|
||||
ssize_t sendto(int, const void *, size_t, uint32_t, const struct sockaddr *,
|
||||
uint32_t);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ Copyright 2022 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
|
@ -16,12 +16,9 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/calls/struct/dirent.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
// Returns 𝑒^x-1.
|
||||
//
|
||||
// @param 𝑥 is double scalar in low half of %xmm0
|
||||
// @return double scalar in low half of %xmm0
|
||||
expm1: ezlea expm1l,ax
|
||||
jmp _d2ld2
|
||||
.endfn expm1,globl
|
||||
int alphasort(const struct dirent **a, const struct dirent **b) {
|
||||
return strcoll((*a)->d_name, (*b)->d_name);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue