mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-06 03:08:31 +00:00
Make improvements
- Improve compatibility with Blink virtual machine - Add non-POSIX APIs for joining threads and signal masks - Never ever use anything except 32-bit integers for atomics - Add some `#undef` statements to workaround `ctags` problems
This commit is contained in:
parent
b46ac13504
commit
f2af97711b
114 changed files with 902 additions and 363 deletions
|
@ -159,7 +159,7 @@ static struct AsanMorgue {
|
|||
|
||||
static bool __asan_once(void) {
|
||||
bool want = false;
|
||||
static _Atomic(bool) once;
|
||||
static atomic_int once;
|
||||
return atomic_compare_exchange_strong_explicit(
|
||||
&once, &want, true, memory_order_relaxed, memory_order_relaxed);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
|
||||
const char *(DescribeArchPrctlCode)(char buf[12], int x) {
|
||||
#ifdef DescribeArchPrctlCode
|
||||
#undef DescribeArchPrctlCode
|
||||
#endif
|
||||
|
||||
const char *DescribeArchPrctlCode(char buf[12], int x) {
|
||||
if (x == ARCH_SET_FS) return "ARCH_SET_FS";
|
||||
if (x == ARCH_GET_FS) return "ARCH_GET_FS";
|
||||
if (x == ARCH_SET_GS) return "ARCH_SET_GS";
|
||||
|
|
|
@ -20,11 +20,15 @@
|
|||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/nexgen32e/stackframe.h"
|
||||
|
||||
#ifdef DescribeBacktrace
|
||||
#undef DescribeBacktrace
|
||||
#endif
|
||||
|
||||
#define N 64
|
||||
|
||||
#define append(...) o += ksnprintf(buf + o, N - o, __VA_ARGS__)
|
||||
|
||||
const char *(DescribeBacktrace)(char buf[N], struct StackFrame *fr) {
|
||||
const char *DescribeBacktrace(char buf[N], struct StackFrame *fr) {
|
||||
int o = 0;
|
||||
bool gotsome = false;
|
||||
while (fr) {
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/cap.h"
|
||||
|
||||
#ifdef DescribeCapability
|
||||
#undef DescribeCapability
|
||||
#endif
|
||||
|
||||
static const struct thatispacked {
|
||||
unsigned char x;
|
||||
const char *s;
|
||||
|
@ -69,7 +73,7 @@ static const struct thatispacked {
|
|||
{CAP_CHECKPOINT_RESTORE, "CHECKPOINT_RESTORE"}, //
|
||||
};
|
||||
|
||||
const char *(DescribeCapability)(char buf[32], int x) {
|
||||
const char *DescribeCapability(char buf[32], int x) {
|
||||
int i;
|
||||
for (i = 0; i < ARRAYLEN(kCapabilityName); ++i) {
|
||||
if (kCapabilityName[i].x == x) {
|
||||
|
|
|
@ -19,9 +19,13 @@
|
|||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
|
||||
#ifdef DescribeClockName
|
||||
#undef DescribeClockName
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Describes clock_gettime() clock argument.
|
||||
*/
|
||||
const char *(DescribeClockName)(char buf[32], int x) {
|
||||
const char *DescribeClockName(char buf[32], int x) {
|
||||
return DescribeMagnum(buf, kClockNames, "CLOCK_", x);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/sysv/consts/at.h"
|
||||
|
||||
const char *(DescribeDirfd)(char buf[12], int dirfd) {
|
||||
#ifdef DescribeDirfd
|
||||
#undef DescribeDirfd
|
||||
#endif
|
||||
|
||||
const char *DescribeDirfd(char buf[12], int dirfd) {
|
||||
if (dirfd == AT_FDCWD) return "AT_FDCWD";
|
||||
FormatInt32(buf, dirfd);
|
||||
return buf;
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
#include "libc/nt/enum/processaccess.h"
|
||||
#include "libc/sysv/consts/dn.h"
|
||||
|
||||
#ifdef DescribeDnotifyFlags
|
||||
#undef DescribeDnotifyFlags
|
||||
#endif
|
||||
|
||||
static const struct DescribeFlags kDnotifyFlags[] = {
|
||||
{DN_ACCESS, "ACCESS"}, //
|
||||
{DN_MODIFY, "MODIFY"}, //
|
||||
|
@ -31,7 +35,7 @@ static const struct DescribeFlags kDnotifyFlags[] = {
|
|||
{DN_MULTISHOT, "MULTISHOT"}, //
|
||||
};
|
||||
|
||||
const char *(DescribeDnotifyFlags)(char buf[80], int x) {
|
||||
const char *DescribeDnotifyFlags(char buf[80], int x) {
|
||||
return DescribeFlags(buf, 80, kDnotifyFlags, ARRAYLEN(kDnotifyFlags), "DN_",
|
||||
x);
|
||||
}
|
||||
|
|
|
@ -1,28 +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 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/fmt/itoa.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
const char *(DescribeErrno)(char buf[12], int x) {
|
||||
const char *s;
|
||||
if ((s = _strerrno(x))) return s;
|
||||
FormatInt32(buf, x);
|
||||
return buf;
|
||||
}
|
|
@ -20,12 +20,22 @@
|
|||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
const char *(DescribeErrnoResult)(char buf[12], int ax) {
|
||||
#ifdef DescribeErrno
|
||||
#undef DescribeErrno
|
||||
#endif
|
||||
|
||||
const char *DescribeErrno(char buf[20], int ax) {
|
||||
char *p = buf;
|
||||
const char *s;
|
||||
if (ax > -4095u && (s = _strerrno(-ax))) {
|
||||
if (ax < 0) {
|
||||
*p++ = '-';
|
||||
ax = -ax;
|
||||
}
|
||||
if ((s = _strerrno(ax))) {
|
||||
stpcpy(p, s);
|
||||
return s;
|
||||
} else {
|
||||
FormatInt32(buf, ax);
|
||||
FormatInt32(p, ax);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,11 @@
|
|||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
const char *(DescribeFcntlCmd)(char buf[20], int x) {
|
||||
#ifdef DescribeFcntlCmd
|
||||
#undef DescribeFcntlCmd
|
||||
#endif
|
||||
|
||||
const char *DescribeFcntlCmd(char buf[20], int x) {
|
||||
const char *s;
|
||||
if (x >= 0 && (s = GetMagnumStr(kFcntlCmds, x))) {
|
||||
buf[0] = 'F';
|
||||
|
|
|
@ -17,8 +17,7 @@ const char *DescribeCapability(char[32], int);
|
|||
const char *DescribeClockName(char[32], int);
|
||||
const char *DescribeDirfd(char[12], int);
|
||||
const char *DescribeDnotifyFlags(char[80], int);
|
||||
const char *DescribeErrno(char[12], int);
|
||||
const char *DescribeErrnoResult(char[12], int);
|
||||
const char *DescribeErrno(char[20], int);
|
||||
const char *DescribeFcntlCmd(char[20], int);
|
||||
const char *DescribeFlockType(char[12], int);
|
||||
const char *DescribeFrame(char[32], int);
|
||||
|
@ -71,8 +70,7 @@ const char *DescribeWhichPrio(char[12], int);
|
|||
#define DescribeClockName(x) DescribeClockName(alloca(32), x)
|
||||
#define DescribeDirfd(x) DescribeDirfd(alloca(12), x)
|
||||
#define DescribeDnotifyFlags(x) DescribeDnotifyFlags(alloca(80), x)
|
||||
#define DescribeErrno(x) DescribeErrno(alloca(12), x)
|
||||
#define DescribeErrnoResult(x) DescribeErrnoResult(alloca(12), x)
|
||||
#define DescribeErrno(x) DescribeErrno(alloca(20), x)
|
||||
#define DescribeFcntlCmd(x) DescribeFcntlCmd(alloca(20), x)
|
||||
#define DescribeFlockType(x) DescribeFlockType(alloca(12), x)
|
||||
#define DescribeFrame(x) DescribeFrame(alloca(32), x)
|
||||
|
|
|
@ -24,11 +24,15 @@
|
|||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/sysv/consts/f.h"
|
||||
|
||||
#ifdef DescribeFlock
|
||||
#undef DescribeFlock
|
||||
#endif
|
||||
|
||||
#define N 300
|
||||
|
||||
#define append(...) o += ksnprintf(buf + o, N - o, __VA_ARGS__)
|
||||
|
||||
const char *(DescribeFlock)(char buf[N], int cmd, const struct flock *l) {
|
||||
const char *DescribeFlock(char buf[N], int cmd, const struct flock *l) {
|
||||
int o = 0;
|
||||
|
||||
if (!l) return "NULL";
|
||||
|
|
|
@ -19,7 +19,11 @@
|
|||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/sysv/consts/f.h"
|
||||
|
||||
const char *(DescribeFlockType)(char buf[12], int x) {
|
||||
#ifdef DescribeFlockType
|
||||
#undef DescribeFlockType
|
||||
#endif
|
||||
|
||||
const char *DescribeFlockType(char buf[12], int x) {
|
||||
if (x == F_RDLCK) return "F_RDLCK";
|
||||
if (x == F_WRLCK) return "F_WRLCK";
|
||||
if (x == F_UNLCK) return "F_UNLCK";
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/winargs.internal.h"
|
||||
|
||||
#ifdef DescribeFrame
|
||||
#undef DescribeFrame
|
||||
#endif
|
||||
|
||||
#define ADDR(x) ((int64_t)((uint64_t)(x) << 32) >> 16)
|
||||
#define UNSHADOW(x) ((int64_t)(MAX(0, (x)-0x7fff8000)) << 3)
|
||||
#define FRAME(x) ((int)((x) >> 16))
|
||||
|
@ -74,7 +78,7 @@ static const char *GetFrameName(int x) {
|
|||
}
|
||||
}
|
||||
|
||||
const char *(DescribeFrame)(char buf[32], int x) {
|
||||
const char *DescribeFrame(char buf[32], int x) {
|
||||
char *p;
|
||||
if (IsShadowFrame(x)) {
|
||||
ksnprintf(buf, 32, "%s %s %.8x", GetFrameName(x),
|
||||
|
|
|
@ -21,7 +21,11 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/futex.h"
|
||||
|
||||
const char *(DescribeFutexOp)(char buf[64], int x) {
|
||||
#ifdef DescribeFutexOp
|
||||
#undef DescribeFutexOp
|
||||
#endif
|
||||
|
||||
const char *DescribeFutexOp(char buf[64], int x) {
|
||||
|
||||
bool priv = false;
|
||||
if (x & FUTEX_PRIVATE_FLAG) {
|
||||
|
|
|
@ -24,10 +24,14 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
#ifdef DescribeGidList
|
||||
#undef DescribeGidList
|
||||
#endif
|
||||
|
||||
#define N 128
|
||||
|
||||
const char *(DescribeGidList)(char buf[N], int rc, int size,
|
||||
const uint32_t list[]) {
|
||||
const char *DescribeGidList(char buf[N], int rc, int size,
|
||||
const uint32_t list[]) {
|
||||
if ((rc == -1) || (size < 0)) return "n/a";
|
||||
if (!size) return "{}";
|
||||
if (!list) return "NULL";
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
|
||||
const char *(DescribeHow)(char buf[12], int how) {
|
||||
#ifdef DescribeHow
|
||||
#undef DescribeHow
|
||||
#endif
|
||||
|
||||
const char *DescribeHow(char buf[12], int how) {
|
||||
if (how == SIG_BLOCK) return "SIG_BLOCK";
|
||||
if (how == SIG_UNBLOCK) return "SIG_UNBLOCK";
|
||||
if (how == SIG_SETMASK) return "SIG_SETMASK";
|
||||
|
|
|
@ -24,12 +24,16 @@
|
|||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
#ifdef DescribeIovec
|
||||
#undef DescribeIovec
|
||||
#endif
|
||||
|
||||
#define N 300
|
||||
|
||||
#define append(...) o += ksnprintf(buf + o, N - o, __VA_ARGS__)
|
||||
|
||||
const char *(DescribeIovec)(char buf[N], ssize_t rc, const struct iovec *iov,
|
||||
int iovlen) {
|
||||
const char *DescribeIovec(char buf[N], ssize_t rc, const struct iovec *iov,
|
||||
int iovlen) {
|
||||
const char *d;
|
||||
int i, j, o = 0;
|
||||
|
||||
|
|
|
@ -22,7 +22,11 @@
|
|||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
|
||||
const char *(DescribeMapFlags)(char buf[64], int x) {
|
||||
#ifdef DescribeMapFlags
|
||||
#undef DescribeMapFlags
|
||||
#endif
|
||||
|
||||
const char *DescribeMapFlags(char buf[64], int x) {
|
||||
const struct DescribeFlags kMapFlags[] = {
|
||||
{MAP_STACK, "STACK"}, // order matters
|
||||
{MAP_PRIVATE, "PRIVATE"}, //
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
|
||||
#ifdef DescribeMapping
|
||||
#undef DescribeMapping
|
||||
#endif
|
||||
|
||||
static char DescribeMapType(int flags) {
|
||||
switch (flags & MAP_TYPE) {
|
||||
case MAP_FILE:
|
||||
|
@ -44,7 +48,7 @@ char *DescribeProt(char p[4], int prot) {
|
|||
return p;
|
||||
}
|
||||
|
||||
const char *(DescribeMapping)(char p[8], int prot, int flags) {
|
||||
const char *DescribeMapping(char p[8], int prot, int flags) {
|
||||
/* asan runtime depends on this function */
|
||||
DescribeProt(p, prot);
|
||||
p[3] = DescribeMapType(flags);
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/nt/enum/consolemodeflags.h"
|
||||
|
||||
#ifdef DescribeNtConsoleInFlags
|
||||
#undef DescribeNtConsoleInFlags
|
||||
#endif
|
||||
|
||||
static const struct DescribeFlags kConsoleModeInputFlags[] = {
|
||||
{kNtEnableProcessedInput, "ProcessedInput"}, //
|
||||
{kNtEnableLineInput, "LineInput"}, //
|
||||
|
@ -33,7 +37,7 @@ static const struct DescribeFlags kConsoleModeInputFlags[] = {
|
|||
{kNtEnableVirtualTerminalInput, "VirtualTerminalInput"}, //
|
||||
};
|
||||
|
||||
const char *(DescribeNtConsoleInFlags)(char buf[256], uint32_t x) {
|
||||
const char *DescribeNtConsoleInFlags(char buf[256], uint32_t x) {
|
||||
return DescribeFlags(buf, 256, kConsoleModeInputFlags,
|
||||
ARRAYLEN(kConsoleModeInputFlags), "kNtEnable", x);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/nt/enum/consolemodeflags.h"
|
||||
|
||||
#ifdef DescribeNtConsoleOutFlags
|
||||
#undef DescribeNtConsoleOutFlags
|
||||
#endif
|
||||
|
||||
static const struct DescribeFlags kConsoleModeOutputFlags[] = {
|
||||
{kNtEnableProcessedOutput, "EnableProcessedOutput"}, //
|
||||
{kNtEnableWrapAtEolOutput, "EnableWrapAtEolOutput"}, //
|
||||
|
@ -28,7 +32,7 @@ static const struct DescribeFlags kConsoleModeOutputFlags[] = {
|
|||
{kNtEnableLvbGridWorldwide, "EnableLvbGridWorldwide"}, //
|
||||
};
|
||||
|
||||
const char *(DescribeNtConsoleOutFlags)(char buf[128], uint32_t x) {
|
||||
const char *DescribeNtConsoleOutFlags(char buf[128], uint32_t x) {
|
||||
return DescribeFlags(buf, 128, kConsoleModeOutputFlags,
|
||||
ARRAYLEN(kConsoleModeOutputFlags), "kNt", x);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
#include "libc/nt/enum/accessmask.h"
|
||||
#include "libc/nt/enum/filesharemode.h"
|
||||
|
||||
#ifdef DescribeNtFileAccessFlags
|
||||
#undef DescribeNtFileAccessFlags
|
||||
#endif
|
||||
|
||||
static const struct DescribeFlags kFileAccessflags[] = {
|
||||
{kNtFileAllAccess, "FileAllAccess"}, // order matters
|
||||
{kNtFileGenericRead, "FileGenericRead"}, // order matters
|
||||
|
@ -63,7 +67,7 @@ static const struct DescribeFlags kFileAccessflags[] = {
|
|||
{kNtTokenAdjustSessionid, "TokenAdjustSessionid"}, //
|
||||
};
|
||||
|
||||
const char *(DescribeNtFileAccessFlags)(char buf[512], uint32_t x) {
|
||||
const char *DescribeNtFileAccessFlags(char buf[512], uint32_t x) {
|
||||
return DescribeFlags(buf, 512, kFileAccessflags, ARRAYLEN(kFileAccessflags),
|
||||
"kNt", x);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
#include "libc/nt/enum/fileflagandattributes.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
||||
#ifdef DescribeNtFileFlagAttr
|
||||
#undef DescribeNtFileFlagAttr
|
||||
#endif
|
||||
|
||||
static const struct DescribeFlags kFileFlags[] = {
|
||||
{kNtFileAttributeReadonly, "AttributeReadonly"}, //
|
||||
{kNtFileAttributeHidden, "AttributeHidden"}, //
|
||||
|
@ -50,7 +54,7 @@ static const struct DescribeFlags kFileFlags[] = {
|
|||
{kNtFileFlagFirstPipeInstance, "FlagFirstPipeInstance"}, //
|
||||
};
|
||||
|
||||
const char *(DescribeNtFileFlagAttr)(char buf[256], uint32_t x) {
|
||||
const char *DescribeNtFileFlagAttr(char buf[256], uint32_t x) {
|
||||
if (x == -1u) return "-1u";
|
||||
return DescribeFlags(buf, 256, kFileFlags, ARRAYLEN(kFileFlags), "kNtFile",
|
||||
x);
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/nt/enum/filemapflags.h"
|
||||
|
||||
#ifdef DescribeNtFileMapFlags
|
||||
#undef DescribeNtFileMapFlags
|
||||
#endif
|
||||
|
||||
static const struct DescribeFlags kFileMapFlags[] = {
|
||||
{kNtFileMapCopy, "Copy"}, //
|
||||
{kNtFileMapWrite, "Write"}, //
|
||||
|
@ -30,7 +34,7 @@ static const struct DescribeFlags kFileMapFlags[] = {
|
|||
{kNtFileMapLargePages, "LargePages"}, //
|
||||
};
|
||||
|
||||
const char *(DescribeNtFileMapFlags)(char buf[64], uint32_t x) {
|
||||
const char *DescribeNtFileMapFlags(char buf[64], uint32_t x) {
|
||||
return DescribeFlags(buf, 64, kFileMapFlags, ARRAYLEN(kFileMapFlags),
|
||||
"kNtFileMap", x);
|
||||
}
|
||||
|
|
|
@ -20,13 +20,17 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/nt/enum/filesharemode.h"
|
||||
|
||||
#ifdef DescribeNtFileShareFlags
|
||||
#undef DescribeNtFileShareFlags
|
||||
#endif
|
||||
|
||||
static const struct DescribeFlags kFileShareflags[] = {
|
||||
{kNtFileShareRead, "Read"}, //
|
||||
{kNtFileShareWrite, "Write"}, //
|
||||
{kNtFileShareDelete, "Delete"}, //
|
||||
};
|
||||
|
||||
const char *(DescribeNtFileShareFlags)(char buf[64], uint32_t x) {
|
||||
const char *DescribeNtFileShareFlags(char buf[64], uint32_t x) {
|
||||
return DescribeFlags(buf, 64, kFileShareflags, ARRAYLEN(kFileShareflags),
|
||||
"kNtFileShare", x);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
#include "libc/nt/enum/filetype.h"
|
||||
#include "libc/sysv/consts/mremap.h"
|
||||
|
||||
#ifdef DescribeNtFiletypeFlags
|
||||
#undef DescribeNtFiletypeFlags
|
||||
#endif
|
||||
|
||||
static const struct DescribeFlags kFiletypeFlags[] = {
|
||||
{kNtFileTypeRemote, "Remote"}, //
|
||||
{kNtFileTypePipe, "Pipe"}, // order matters
|
||||
|
@ -28,7 +32,7 @@ static const struct DescribeFlags kFiletypeFlags[] = {
|
|||
{kNtFileTypeChar, "Char"}, //
|
||||
};
|
||||
|
||||
const char *(DescribeNtFiletypeFlags)(char buf[64], uint32_t x) {
|
||||
const char *DescribeNtFiletypeFlags(char buf[64], uint32_t x) {
|
||||
return DescribeFlags(buf, 64, kFiletypeFlags, ARRAYLEN(kFiletypeFlags),
|
||||
"kNtFileType", x);
|
||||
}
|
||||
|
|
|
@ -20,12 +20,16 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/nt/enum/filelockflags.h"
|
||||
|
||||
#ifdef DescribeNtLockFileFlags
|
||||
#undef DescribeNtLockFileFlags
|
||||
#endif
|
||||
|
||||
static const struct DescribeFlags kNtLockFileFlags[] = {
|
||||
{kNtLockfileFailImmediately, "FailImmediately"}, //
|
||||
{kNtLockfileExclusiveLock, "ExclusiveLock"}, //
|
||||
};
|
||||
|
||||
const char *(DescribeNtLockFileFlags)(char buf[64], uint32_t x) {
|
||||
const char *DescribeNtLockFileFlags(char buf[64], uint32_t x) {
|
||||
return DescribeFlags(buf, 64, kNtLockFileFlags, ARRAYLEN(kNtLockFileFlags),
|
||||
"kNtLockfile", x);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/nt/enum/movefileexflags.h"
|
||||
|
||||
#ifdef DescribeNtMovFileInpFlags
|
||||
#undef DescribeNtMovFileInpFlags
|
||||
#endif
|
||||
|
||||
static const struct DescribeFlags kMoveFileInputFlags[] = {
|
||||
{kNtMovefileReplaceExisting, "ReplaceExisting"}, //
|
||||
{kNtMovefileCopyAllowed, "CopyAllowed"}, //
|
||||
|
@ -29,7 +33,7 @@ static const struct DescribeFlags kMoveFileInputFlags[] = {
|
|||
{kNtMovefileFailIfNotTrackable, "FailIfNotTrackable"}, //
|
||||
};
|
||||
|
||||
const char *(DescribeNtMovFileInpFlags)(char buf[256], uint32_t x) {
|
||||
const char *DescribeNtMovFileInpFlags(char buf[256], uint32_t x) {
|
||||
return DescribeFlags(buf, 256, kMoveFileInputFlags,
|
||||
ARRAYLEN(kMoveFileInputFlags), "kNtMovefile", x);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/nt/enum/pageflags.h"
|
||||
|
||||
#ifdef DescribeNtPageFlags
|
||||
#undef DescribeNtPageFlags
|
||||
#endif
|
||||
|
||||
static const struct DescribeFlags kPageFlags[] = {
|
||||
{kNtPageNoaccess, "PageNoaccess"}, //
|
||||
{kNtPageReadonly, "PageReadonly"}, //
|
||||
|
@ -41,6 +45,6 @@ static const struct DescribeFlags kPageFlags[] = {
|
|||
{kNtSecWritecombine, "SecWritecombine"}, //
|
||||
};
|
||||
|
||||
const char *(DescribeNtPageFlags)(char buf[64], uint32_t x) {
|
||||
const char *DescribeNtPageFlags(char buf[64], uint32_t x) {
|
||||
return DescribeFlags(buf, 64, kPageFlags, ARRAYLEN(kPageFlags), "kNt", x);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
#include "libc/nt/enum/filemapflags.h"
|
||||
#include "libc/nt/ipc.h"
|
||||
|
||||
#ifdef DescribeNtPipeModeFlags
|
||||
#undef DescribeNtPipeModeFlags
|
||||
#endif
|
||||
|
||||
static const struct DescribeFlags kPipeModeFlags[] = {
|
||||
{kNtPipeNowait, "Nowait"}, // 0x0000000001
|
||||
{kNtPipeReadmodeMessage, "ReadmodeMessage"}, // 0x0000000002
|
||||
|
@ -32,7 +36,7 @@ static const struct DescribeFlags kPipeModeFlags[] = {
|
|||
//{kNtPipeTypeByte, "TypeByte"}, // 0x00000000
|
||||
};
|
||||
|
||||
const char *(DescribeNtPipeModeFlags)(char buf[64], uint32_t x) {
|
||||
const char *DescribeNtPipeModeFlags(char buf[64], uint32_t x) {
|
||||
return DescribeFlags(buf, 64, kPipeModeFlags, ARRAYLEN(kPipeModeFlags),
|
||||
"kNtPipe", x);
|
||||
}
|
||||
|
|
|
@ -21,13 +21,17 @@
|
|||
#include "libc/nt/enum/filemapflags.h"
|
||||
#include "libc/nt/ipc.h"
|
||||
|
||||
#ifdef DescribeNtPipeOpenFlags
|
||||
#undef DescribeNtPipeOpenFlags
|
||||
#endif
|
||||
|
||||
static const struct DescribeFlags kPipeOpenFlags[] = {
|
||||
{kNtPipeAccessDuplex, "Duplex"}, // 0x00000003
|
||||
{kNtPipeAccessOutbound, "Outbound"}, // 0x00000002
|
||||
{kNtPipeAccessInbound, "Inbound"}, // 0x00000001
|
||||
};
|
||||
|
||||
const char *(DescribeNtPipeOpenFlags)(char buf[64], uint32_t x) {
|
||||
const char *DescribeNtPipeOpenFlags(char buf[64], uint32_t x) {
|
||||
return DescribeFlags(buf, 64, kPipeOpenFlags, ARRAYLEN(kPipeOpenFlags),
|
||||
"kNtPipeAccess", x);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/nt/enum/processaccess.h"
|
||||
|
||||
#ifdef DescribeNtProcAccessFlags
|
||||
#undef DescribeNtProcAccessFlags
|
||||
#endif
|
||||
|
||||
static const struct DescribeFlags kProcessAccessflags[] = {
|
||||
{kNtProcessAllAccess, "AllAccess"}, //
|
||||
{kNtProcessCreateProcess, "CreateProcess"}, //
|
||||
|
@ -37,7 +41,7 @@ static const struct DescribeFlags kProcessAccessflags[] = {
|
|||
{kNtProcessSynchronize, "Synchronize"}, //
|
||||
};
|
||||
|
||||
const char *(DescribeNtProcAccessFlags)(char buf[256], uint32_t x) {
|
||||
const char *DescribeNtProcAccessFlags(char buf[256], uint32_t x) {
|
||||
return DescribeFlags(buf, 256, kProcessAccessflags,
|
||||
ARRAYLEN(kProcessAccessflags), "kNtProcess", x);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
#include "libc/nt/enum/startf.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
|
||||
#ifdef DescribeNtStartFlags
|
||||
#undef DescribeNtStartFlags
|
||||
#endif
|
||||
|
||||
static const struct DescribeFlags kNtStartFlags[] = {
|
||||
{kNtStartfUseshowwindow, "Useshowwindow"}, //
|
||||
{kNtStartfUsesize, "Usesize"}, //
|
||||
|
@ -38,7 +42,7 @@ static const struct DescribeFlags kNtStartFlags[] = {
|
|||
{kNtStartfUntrustedsource, "Untrustedsource"}, //
|
||||
};
|
||||
|
||||
const char *(DescribeNtStartFlags)(char buf[128], uint32_t x) {
|
||||
const char *DescribeNtStartFlags(char buf[128], uint32_t x) {
|
||||
return DescribeFlags(buf, 128, kNtStartFlags, ARRAYLEN(kNtStartFlags),
|
||||
"kNtStartf", x);
|
||||
}
|
||||
|
|
|
@ -20,12 +20,16 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/nt/enum/symboliclink.h"
|
||||
|
||||
#ifdef DescribeNtSymlinkFlags
|
||||
#undef DescribeNtSymlinkFlags
|
||||
#endif
|
||||
|
||||
static const struct DescribeFlags kSymbolicLinkflags[] = {
|
||||
{kNtSymbolicLinkFlagDirectory, "Directory"}, //
|
||||
{kNtSymbolicLinkFlagAllowUnprivilegedCreate, "AllowUnprivilegedCreate"}, //
|
||||
};
|
||||
|
||||
const char *(DescribeNtSymlinkFlags)(char buf[64], uint32_t x) {
|
||||
const char *DescribeNtSymlinkFlags(char buf[64], uint32_t x) {
|
||||
return DescribeFlags(buf, 64, kSymbolicLinkflags,
|
||||
ARRAYLEN(kSymbolicLinkflags), "kNtSymbolicLinkFlag", x);
|
||||
}
|
||||
|
|
|
@ -23,12 +23,16 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/sysv/consts/sol.h"
|
||||
|
||||
#ifdef DescribeOpenFlags
|
||||
#undef DescribeOpenFlags
|
||||
#endif
|
||||
|
||||
#define N (PAGESIZE / 2 / sizeof(struct DescribeFlags))
|
||||
|
||||
/**
|
||||
* Describes clock_gettime() clock argument.
|
||||
*/
|
||||
const char *(DescribeOpenFlags)(char buf[128], int x) {
|
||||
const char *DescribeOpenFlags(char buf[128], int x) {
|
||||
char *s;
|
||||
int i, n;
|
||||
struct DescribeFlags d[N];
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
#include "libc/nt/enum/filesharemode.h"
|
||||
#include "libc/sysv/consts/personality.h"
|
||||
|
||||
#ifdef DescribePersonalityFlags
|
||||
#undef DescribePersonalityFlags
|
||||
#endif
|
||||
|
||||
static const struct DescribeFlags kPersonalityFlags[] = {
|
||||
{ADDR_COMPAT_LAYOUT, "ADDR_COMPAT_LAYOUT"}, //
|
||||
{READ_IMPLIES_EXEC, "READ_IMPLIES_EXEC"}, //
|
||||
|
@ -36,7 +40,7 @@ static const struct DescribeFlags kPersonalityFlags[] = {
|
|||
{UNAME26, "UNAME26"}, //
|
||||
};
|
||||
|
||||
const char *(DescribePersonalityFlags)(char buf[128], int x) {
|
||||
const char *DescribePersonalityFlags(char buf[128], int x) {
|
||||
return DescribeFlags(buf, 128, kPersonalityFlags, ARRAYLEN(kPersonalityFlags),
|
||||
"", x);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,11 @@
|
|||
#include "libc/nt/enum/filemapflags.h"
|
||||
#include "libc/sysv/consts/poll.h"
|
||||
|
||||
const char *(DescribePollFlags)(char buf[64], int x) {
|
||||
#ifdef DescribePollFlags
|
||||
#undef DescribePollFlags
|
||||
#endif
|
||||
|
||||
const char *DescribePollFlags(char buf[64], int x) {
|
||||
const struct DescribeFlags kPollFlags[] = {
|
||||
{POLLIN, "IN"}, // order matters
|
||||
{POLLOUT, "OUT"}, // order matters
|
||||
|
|
|
@ -20,12 +20,16 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
|
||||
#ifdef DescribeProtFlags
|
||||
#undef DescribeProtFlags
|
||||
#endif
|
||||
|
||||
static const struct DescribeFlags kProtFlags[] = {
|
||||
{PROT_READ, "READ"}, //
|
||||
{PROT_WRITE, "WRITE"}, //
|
||||
{PROT_EXEC, "EXEC"}, //
|
||||
};
|
||||
|
||||
const char *(DescribeProtFlags)(char buf[48], int x) {
|
||||
const char *DescribeProtFlags(char buf[48], int x) {
|
||||
return DescribeFlags(buf, 48, kProtFlags, ARRAYLEN(kProtFlags), "PROT_", x);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/sysv/consts/ptrace.h"
|
||||
|
||||
const char *(DescribePtrace)(char buf[12], int x) {
|
||||
#ifdef DescribePtrace
|
||||
#undef DescribePtrace
|
||||
#endif
|
||||
|
||||
const char *DescribePtrace(char buf[12], int x) {
|
||||
if (x == -1) return "-1";
|
||||
if (x == PTRACE_TRACEME) return "PTRACE_TRACEME";
|
||||
if (x == PTRACE_PEEKDATA) return "PTRACE_PEEKDATA";
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/sysv/consts/ptrace.h"
|
||||
|
||||
const char *(DescribePtraceEvent)(char buf[32], int x) {
|
||||
#ifdef DescribePtraceEvent
|
||||
#undef DescribePtraceEvent
|
||||
#endif
|
||||
|
||||
const char *DescribePtraceEvent(char buf[32], int x) {
|
||||
if (x == PTRACE_EVENT_FORK) return "PTRACE_EVENT_FORK";
|
||||
if (x == PTRACE_EVENT_VFORK) return "PTRACE_EVENT_VFORK";
|
||||
if (x == PTRACE_EVENT_CLONE) return "PTRACE_EVENT_CLONE";
|
||||
|
|
|
@ -20,12 +20,16 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/sysv/consts/mremap.h"
|
||||
|
||||
#ifdef DescribeRemapFlags
|
||||
#undef DescribeRemapFlags
|
||||
#endif
|
||||
|
||||
static const struct DescribeFlags kRemapFlags[] = {
|
||||
{MREMAP_MAYMOVE, "MAYMOVE"}, //
|
||||
{MREMAP_FIXED, "FIXED"}, //
|
||||
};
|
||||
|
||||
const char *(DescribeRemapFlags)(char buf[48], int x) {
|
||||
const char *DescribeRemapFlags(char buf[48], int x) {
|
||||
return DescribeFlags(buf, 48, kRemapFlags, ARRAYLEN(kRemapFlags), "MREMAP_",
|
||||
x);
|
||||
}
|
||||
|
|
|
@ -19,10 +19,14 @@
|
|||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
|
||||
#ifdef DescribeRlimitName
|
||||
#undef DescribeRlimitName
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Describes setrlimit() / getrlimit() argument.
|
||||
*/
|
||||
const char *(DescribeRlimitName)(char buf[20], int x) {
|
||||
const char *DescribeRlimitName(char buf[20], int x) {
|
||||
if (x == 127) return "n/a";
|
||||
return DescribeMagnum(buf, kRlimitNames, "RLIMIT_", x);
|
||||
}
|
||||
|
|
|
@ -21,10 +21,14 @@
|
|||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
#ifdef DescribeSchedParam
|
||||
#undef DescribeSchedParam
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Describes clock_gettime() clock argument.
|
||||
*/
|
||||
const char *(DescribeSchedParam)(char buf[32], const struct sched_param *x) {
|
||||
const char *DescribeSchedParam(char buf[32], const struct sched_param *x) {
|
||||
char *p;
|
||||
if (!x) return "0";
|
||||
p = buf;
|
||||
|
|
|
@ -23,10 +23,14 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/sched.h"
|
||||
|
||||
#ifdef DescribeSchedPolicy
|
||||
#undef DescribeSchedPolicy
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Describes clock_gettime() clock argument.
|
||||
*/
|
||||
const char *(DescribeSchedPolicy)(char buf[48], int x) {
|
||||
const char *DescribeSchedPolicy(char buf[48], int x) {
|
||||
char *p = buf;
|
||||
if (x == -1) {
|
||||
goto DoNumber;
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
#include "libc/sysv/consts/sicode.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
|
||||
#ifdef DescribeSiCode
|
||||
#undef DescribeSiCode
|
||||
#endif
|
||||
|
||||
static bool IsSiUser(int si_code) {
|
||||
if (!IsOpenbsd()) {
|
||||
return si_code == SI_USER;
|
||||
|
@ -38,7 +42,7 @@ static void NameIt(char p[17], const char *s, int si_code) {
|
|||
/**
|
||||
* Returns symbolic name for siginfo::si_code value.
|
||||
*/
|
||||
const char *(DescribeSiCode)(char b[17], int sig, int si_code) {
|
||||
const char *DescribeSiCode(char b[17], int sig, int si_code) {
|
||||
NameIt(b, "SI_", si_code);
|
||||
if (si_code == SI_QUEUE) {
|
||||
strcpy(b + 3, "QUEUE"); /* sent by sigqueue(2) */
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
#include "libc/mem/alloca.h"
|
||||
#include "libc/sysv/consts/sa.h"
|
||||
|
||||
#ifdef DescribeSigaction
|
||||
#undef DescribeSigaction
|
||||
#endif
|
||||
|
||||
static const char *DescribeSigHandler(char buf[64], void f(int)) {
|
||||
if (f == SIG_ERR) return "SIG_ERR";
|
||||
if (f == SIG_DFL) return "SIG_DFL";
|
||||
|
@ -54,8 +58,7 @@ static const char *DescribeSigFlags(char buf[64], int x) {
|
|||
|
||||
#define append(...) o += ksnprintf(buf + o, N - o, __VA_ARGS__)
|
||||
|
||||
const char *(DescribeSigaction)(char buf[N], int rc,
|
||||
const struct sigaction *sa) {
|
||||
const char *DescribeSigaction(char buf[N], int rc, const struct sigaction *sa) {
|
||||
int o = 0;
|
||||
char b64[64];
|
||||
|
||||
|
|
|
@ -22,8 +22,12 @@
|
|||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
|
||||
const char *(DescribeSigaltstk)(char buf[128], int rc,
|
||||
const struct sigaltstack *ss) {
|
||||
#ifdef DescribeSigaltstk
|
||||
#undef DescribeSigaltstk
|
||||
#endif
|
||||
|
||||
const char *DescribeSigaltstk(char buf[128], int rc,
|
||||
const struct sigaltstack *ss) {
|
||||
if (rc == -1) return "n/a";
|
||||
if (!ss) return "NULL";
|
||||
if ((!IsAsan() && kisdangerous(ss)) ||
|
||||
|
|
|
@ -26,11 +26,15 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
|
||||
#ifdef DescribeSiginfo
|
||||
#undef DescribeSiginfo
|
||||
#endif
|
||||
|
||||
#define N 300
|
||||
|
||||
#define append(...) i += ksnprintf(buf + i, N - i, __VA_ARGS__)
|
||||
|
||||
const char *(DescribeSiginfo)(char buf[N], int rc, const siginfo_t *si) {
|
||||
const char *DescribeSiginfo(char buf[N], int rc, const siginfo_t *si) {
|
||||
int i = 0;
|
||||
|
||||
if (rc == -1) return "n/a";
|
||||
|
|
|
@ -26,11 +26,15 @@
|
|||
#include "libc/sysv/consts/limits.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
|
||||
#ifdef DescribeSigset
|
||||
#undef DescribeSigset
|
||||
#endif
|
||||
|
||||
#define N 128
|
||||
|
||||
#define append(...) o += ksnprintf(buf + o, N - o, __VA_ARGS__)
|
||||
|
||||
const char *(DescribeSigset)(char buf[N], int rc, const sigset_t *ss) {
|
||||
const char *DescribeSigset(char buf[N], int rc, const sigset_t *ss) {
|
||||
bool gotsome;
|
||||
const char *s;
|
||||
int sig, o = 0;
|
||||
|
|
|
@ -21,10 +21,14 @@
|
|||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/sysv/consts/timer.h"
|
||||
|
||||
#ifdef DescribeSleepFlags
|
||||
#undef DescribeSleepFlags
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Describes clock_nanosleep() flags argument.
|
||||
*/
|
||||
const char *(DescribeSleepFlags)(char buf[16], int x) {
|
||||
const char *DescribeSleepFlags(char buf[16], int x) {
|
||||
switch (x) {
|
||||
case 0:
|
||||
return "0";
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/sysv/consts/af.h"
|
||||
|
||||
const char *(DescribeSocketFamily)(char buf[12], int family) {
|
||||
#ifdef DescribeSocketFamily
|
||||
#undef DescribeSocketFamily
|
||||
#endif
|
||||
|
||||
const char *DescribeSocketFamily(char buf[12], int family) {
|
||||
if (family == AF_UNIX) return "AF_UNIX";
|
||||
if (family == AF_INET) return "AF_INET";
|
||||
if (family == AF_INET6) return "AF_INET6";
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/sysv/consts/ipproto.h"
|
||||
|
||||
const char *(DescribeSocketProtocol)(char buf[12], int family) {
|
||||
#ifdef DescribeSocketProtocol
|
||||
#undef DescribeSocketProtocol
|
||||
#endif
|
||||
|
||||
const char *DescribeSocketProtocol(char buf[12], int family) {
|
||||
if (family == IPPROTO_IP) return "IPPROTO_IP";
|
||||
if (family == IPPROTO_ICMP) return "IPPROTO_ICMP";
|
||||
if (family == IPPROTO_TCP) return "IPPROTO_TCP";
|
||||
|
|
|
@ -21,7 +21,11 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/sock.h"
|
||||
|
||||
const char *(DescribeSocketType)(char buf[64], int type) {
|
||||
#ifdef DescribeSocketType
|
||||
#undef DescribeSocketType
|
||||
#endif
|
||||
|
||||
const char *DescribeSocketType(char buf[64], int type) {
|
||||
int x;
|
||||
char *p;
|
||||
p = buf;
|
||||
|
|
|
@ -20,10 +20,14 @@
|
|||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/sysv/consts/sol.h"
|
||||
|
||||
#ifdef DescribeSockLevel
|
||||
#undef DescribeSockLevel
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Describes setsockopt() level arguments.
|
||||
*/
|
||||
const char *(DescribeSockLevel)(char buf[12], int x) {
|
||||
const char *DescribeSockLevel(char buf[12], int x) {
|
||||
if (x == SOL_IP) return "SOL_IP";
|
||||
if (x == SOL_TCP) return "SOL_TCP";
|
||||
if (x == SOL_UDP) return "SOL_UDP";
|
||||
|
|
|
@ -22,10 +22,14 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/sol.h"
|
||||
|
||||
#ifdef DescribeSockOptname
|
||||
#undef DescribeSockOptname
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Describes setsockopt() optname arguments.
|
||||
*/
|
||||
const char *(DescribeSockOptname)(char buf[32], int l, int x) {
|
||||
const char *DescribeSockOptname(char buf[32], int l, int x) {
|
||||
int i;
|
||||
char *s, *p;
|
||||
const struct MagnumStr *ms;
|
||||
|
|
|
@ -22,11 +22,15 @@
|
|||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
|
||||
#ifdef DescribeStat
|
||||
#undef DescribeStat
|
||||
#endif
|
||||
|
||||
#define N 300
|
||||
|
||||
#define append(...) o += ksnprintf(buf + o, N - o, __VA_ARGS__)
|
||||
|
||||
const char *(DescribeStat)(char buf[N], int rc, const struct stat *st) {
|
||||
const char *DescribeStat(char buf[N], int rc, const struct stat *st) {
|
||||
int o = 0;
|
||||
|
||||
if (rc == -1) return "n/a";
|
||||
|
|
|
@ -24,11 +24,15 @@
|
|||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/sysv/consts/st.h"
|
||||
|
||||
#ifdef DescribeStatfs
|
||||
#undef DescribeStatfs
|
||||
#endif
|
||||
|
||||
#define N 300
|
||||
|
||||
#define append(...) i += ksnprintf(buf + i, N - i, __VA_ARGS__)
|
||||
|
||||
const char *(DescribeStatfs)(char buf[N], int rc, const struct statfs *f) {
|
||||
const char *DescribeStatfs(char buf[N], int rc, const struct statfs *f) {
|
||||
int i = 0;
|
||||
char ibuf[21];
|
||||
int64_t flags;
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
const char *(DescribeStdioState)(char buf[12], int x) {
|
||||
#ifdef DescribeStdioState
|
||||
#undef DescribeStdioState
|
||||
#endif
|
||||
|
||||
const char *DescribeStdioState(char buf[12], int x) {
|
||||
if (!x) return "";
|
||||
if (x == -1) return "EOF";
|
||||
if (x > 0) return _strerrno(x);
|
||||
|
|
|
@ -21,11 +21,15 @@
|
|||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
|
||||
#ifdef DescribeStringList
|
||||
#undef DescribeStringList
|
||||
#endif
|
||||
|
||||
#define N 300
|
||||
|
||||
#define append(...) o += ksnprintf(buf + o, N - o, __VA_ARGS__)
|
||||
|
||||
const char *(DescribeStringList)(char buf[N], char *const list[]) {
|
||||
const char *DescribeStringList(char buf[N], char *const list[]) {
|
||||
int i, o = 0;
|
||||
|
||||
if (!list) return "NULL";
|
||||
|
|
|
@ -23,8 +23,11 @@
|
|||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
const char *(DescribeTimespec)(char buf[45], int rc,
|
||||
const struct timespec *ts) {
|
||||
#ifdef DescribeTimespec
|
||||
#undef DescribeTimespec
|
||||
#endif
|
||||
|
||||
const char *DescribeTimespec(char buf[45], int rc, const struct timespec *ts) {
|
||||
if (rc == -1) return "n/a";
|
||||
if (!ts) return "NULL";
|
||||
if ((!IsAsan() && kisdangerous(ts)) ||
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
|
||||
const char *(DescribeWhence)(char buf[12], int whence) {
|
||||
#ifdef DescribeWhence
|
||||
#undef DescribeWhence
|
||||
#endif
|
||||
|
||||
const char *DescribeWhence(char buf[12], int whence) {
|
||||
if (whence == SEEK_SET) return "SEEK_SET";
|
||||
if (whence == SEEK_CUR) return "SEEK_CUR";
|
||||
if (whence == SEEK_END) return "SEEK_END";
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/sysv/consts/prio.h"
|
||||
|
||||
const char *(DescribeWhichPrio)(char buf[12], int x) {
|
||||
#ifdef DescribeWhichPrio
|
||||
#undef DescribeWhichPrio
|
||||
#endif
|
||||
|
||||
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";
|
||||
|
|
|
@ -20,11 +20,19 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/thread/thread.h"
|
||||
|
||||
void(__fds_lock)(void) {
|
||||
#ifdef __fds_lock
|
||||
#undef __fds_lock
|
||||
#endif
|
||||
|
||||
#ifdef __fds_unlock
|
||||
#undef __fds_unlock
|
||||
#endif
|
||||
|
||||
void __fds_lock(void) {
|
||||
pthread_mutex_lock(&__fds_lock_obj);
|
||||
}
|
||||
|
||||
void(__fds_unlock)(void) {
|
||||
void __fds_unlock(void) {
|
||||
pthread_mutex_unlock(&__fds_lock_obj);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,14 +20,22 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/thread/thread.h"
|
||||
|
||||
#ifdef __mmi_lock
|
||||
#undef __mmi_lock
|
||||
#endif
|
||||
|
||||
#ifdef __mmi_unlock
|
||||
#undef __mmi_unlock
|
||||
#endif
|
||||
|
||||
// this lock currently needs to be (1) recursive and (2) not nsync
|
||||
|
||||
extern pthread_mutex_t __mmi_lock_obj;
|
||||
|
||||
void(__mmi_lock)(void) {
|
||||
void __mmi_lock(void) {
|
||||
pthread_mutex_lock(&__mmi_lock_obj);
|
||||
}
|
||||
|
||||
void(__mmi_unlock)(void) {
|
||||
void __mmi_unlock(void) {
|
||||
pthread_mutex_unlock(&__mmi_lock_obj);
|
||||
}
|
||||
|
|
|
@ -18,13 +18,17 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/psrad.h"
|
||||
|
||||
#ifdef psradv
|
||||
#undef psradv
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Divides shorts by two powers.
|
||||
*
|
||||
* @note arithmetic shift right will sign extend negatives
|
||||
* @mayalias
|
||||
*/
|
||||
void(psradv)(int32_t a[4], const int32_t b[4], const uint64_t c[2]) {
|
||||
void psradv(int32_t a[4], const int32_t b[4], const uint64_t c[2]) {
|
||||
unsigned i;
|
||||
unsigned char k;
|
||||
k = c[0] > 31 ? 31 : c[0];
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
#ifdef psubusb
|
||||
#undef psubusb
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Subtracts unsigned 8-bit integers w/ saturation.
|
||||
*
|
||||
|
@ -29,7 +33,7 @@
|
|||
* @param 𝑐 [r/o] supplies second input vector
|
||||
* @mayalias
|
||||
*/
|
||||
void(psubusb)(uint8_t a[16], const uint8_t b[16], const uint8_t c[16]) {
|
||||
void psubusb(uint8_t a[16], const uint8_t b[16], const uint8_t c[16]) {
|
||||
unsigned i;
|
||||
uint8_t r[16];
|
||||
for (i = 0; i < 16; ++i) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
void(psubw)(int16_t[8], const int16_t[8], const int16_t[8]);
|
||||
void psubw(int16_t[8], const int16_t[8], const int16_t[8]);
|
||||
|
||||
#define psubw(A, B, C) \
|
||||
INTRIN_SSEVEX_X_X_X_(psubw, SSE2, "psubw", INTRIN_NONCOMMUTATIVE, A, B, C)
|
||||
|
|
|
@ -21,7 +21,11 @@
|
|||
#include "libc/thread/thread.h"
|
||||
#include "libc/thread/tls.h"
|
||||
|
||||
void _pthread_cleanup_pop(struct _pthread_cleanup_buffer *cb, int execute) {
|
||||
#ifdef pthread_cleanup_pop
|
||||
#undef pthread_cleanup_pop
|
||||
#endif
|
||||
|
||||
void pthread_cleanup_pop(struct _pthread_cleanup_buffer *cb, int execute) {
|
||||
struct PosixThread *pt;
|
||||
if (__tls_enabled && (pt = (struct PosixThread *)__get_tls()->tib_pthread)) {
|
||||
_unassert(cb == pt->cleanup);
|
||||
|
|
|
@ -20,8 +20,12 @@
|
|||
#include "libc/thread/thread.h"
|
||||
#include "libc/thread/tls.h"
|
||||
|
||||
void _pthread_cleanup_push(struct _pthread_cleanup_buffer *cb,
|
||||
void (*routine)(void *), void *arg) {
|
||||
#ifdef pthread_cleanup_push
|
||||
#undef pthread_cleanup_push
|
||||
#endif
|
||||
|
||||
void pthread_cleanup_push(struct _pthread_cleanup_buffer *cb,
|
||||
void (*routine)(void *), void *arg) {
|
||||
struct PosixThread *pt;
|
||||
cb->__routine = routine;
|
||||
cb->__arg = arg;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/intrin/atomic.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/thread/thread.h"
|
||||
|
||||
#ifdef pthread_spin_lock
|
||||
|
@ -44,10 +45,22 @@
|
|||
*/
|
||||
errno_t pthread_spin_lock(pthread_spinlock_t *spin) {
|
||||
int x;
|
||||
#if defined(SYSDEBUG) && _LOCKTRACE
|
||||
for (;;) {
|
||||
x = atomic_exchange_explicit(&spin->_lock, 1, memory_order_acquire);
|
||||
if (!x) {
|
||||
LOCKTRACE("pthread_spin_lock(%t)", spin);
|
||||
break;
|
||||
}
|
||||
_unassert(x == 1);
|
||||
LOCKTRACE("pthread_spin_lock(%t) trying...", spin);
|
||||
}
|
||||
#else
|
||||
for (;;) {
|
||||
x = atomic_exchange_explicit(&spin->_lock, 1, memory_order_acquire);
|
||||
if (!x) break;
|
||||
_unassert(x == 1);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/atomic.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/thread/thread.h"
|
||||
|
||||
#ifdef pthread_spin_unlock
|
||||
|
@ -33,6 +34,7 @@
|
|||
* @see pthread_spin_lock
|
||||
*/
|
||||
errno_t pthread_spin_unlock(pthread_spinlock_t *spin) {
|
||||
LOCKTRACE("pthread_spin_unlock(%t)", spin);
|
||||
atomic_store_explicit(&spin->_lock, 0, memory_order_release);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue