mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-02 17:28:30 +00:00
Make terminal ui binaries work well everywhere
Here's some screenshots of an emulator tui program that was compiled on Linux, then scp'd it to Windows, Mac, and FreeBSD. https://justine.storage.googleapis.com/blinkenlights-cmdexe.png https://justine.storage.googleapis.com/blinkenlights-imac.png https://justine.storage.googleapis.com/blinkenlights-freebsd.png https://justine.storage.googleapis.com/blinkenlights-lisp.png How is this even possible that we have a nontrivial ui binary that just works on Mac, Windows, Linux, and BSD? Surely a first ever achievement. Fixed many bugs. Bootstrapped John McCarthy's metacircular evaluator on bare metal in half the size of Altair BASIC (about 2.5kb) and ran it in emulator for fun and profit.
This commit is contained in:
parent
680daf1210
commit
9e3e985ae5
276 changed files with 7026 additions and 3790 deletions
|
@ -1,5 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_SYSCALLS_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_SYSCALLS_H_
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/calls/typedef/sighandler_t.h"
|
||||
#include "libc/dce.h"
|
||||
|
@ -58,12 +59,10 @@ struct iovec;
|
|||
struct rlimit;
|
||||
struct rusage;
|
||||
struct sigaction;
|
||||
struct siginfo;
|
||||
struct sigset;
|
||||
struct stat;
|
||||
struct sysinfo;
|
||||
struct tms;
|
||||
struct ucontext;
|
||||
struct utsname;
|
||||
|
||||
typedef int sig_atomic_t;
|
||||
|
@ -210,6 +209,7 @@ size_t getfiledescriptorsize(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 read(int, void *, size_t);
|
||||
ssize_t readansi(int, char *, size_t);
|
||||
ssize_t readlinkat(int, const char *, char *, size_t);
|
||||
ssize_t splice(int, int64_t *, int, int64_t *, size_t, uint32_t);
|
||||
ssize_t vmsplice(int, const struct iovec *, int64_t, uint32_t);
|
||||
|
|
|
@ -17,9 +17,10 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
#include "libc/time/time.h"
|
||||
|
||||
/**
|
||||
* Retrieves last setitimer() value, correcting for remaining time.
|
||||
|
@ -29,9 +30,8 @@
|
|||
*/
|
||||
int getitimer(int which, struct itimerval *curvalue) {
|
||||
if (!IsWindows()) {
|
||||
int getitimer$sysv(int, struct itimerval *) hidden;
|
||||
return getitimer$sysv(which, curvalue);
|
||||
} else {
|
||||
return enosys(); /* TODO(jart): Implement me! */
|
||||
return setitimer$nt(which, NULL, curvalue);
|
||||
}
|
||||
}
|
|
@ -45,7 +45,7 @@ static int mkntcmdline_append(char16_t **p, size_t *i, size_t *n, char16_t c) {
|
|||
* Converts System V argv to Windows-style command line.
|
||||
*
|
||||
* Escaping is performed and it's designed to round-trip with
|
||||
* getdosargv() or getdosargv(). This function does NOT escape
|
||||
* GetDosArgv() or GetDosArgv(). This function does NOT escape
|
||||
* command interpreter syntax, e.g. $VAR (sh), %VAR% (cmd).
|
||||
*
|
||||
* @param argv is an a NULL-terminated array of UTF-8 strings
|
||||
|
|
|
@ -181,6 +181,7 @@ i64 sendfile$sysv(i32, i32, i64 *, u64) hidden;
|
|||
i64 splice$sysv(i32, i64 *, i32, i64 *, u64, u32) hidden;
|
||||
i64 vmsplice$sysv(i32, const struct iovec *, i64, u32) hidden;
|
||||
i64 write$sysv(i32, const void *, u64) hidden;
|
||||
int getitimer$sysv(i32, struct itimerval *) hidden;
|
||||
int setresgid$sysv(uint32_t, uint32_t, uint32_t) hidden;
|
||||
int setresuid$sysv(uint32_t, uint32_t, uint32_t) hidden;
|
||||
u32 getgid$sysv(void) hidden;
|
||||
|
@ -204,6 +205,7 @@ u32 prot2nt(i32, i32) privileged;
|
|||
void __restore_rt() hidden;
|
||||
void __sigenter$xnu(void *, i32, i32, void *, void *) hidden noreturn;
|
||||
int utimensat$xnu(int, const char *, const struct timespec *, int) hidden;
|
||||
int nanosleep$xnu(const struct timespec *, struct timespec *) hidden;
|
||||
void stat2linux(void *) hidden;
|
||||
void xnutrampoline(void *, i32, i32, const struct __darwin_siginfo *,
|
||||
const struct __darwin_ucontext *) hidden noreturn;
|
||||
|
@ -247,6 +249,8 @@ ssize_t read$nt(struct Fd *, const struct iovec *, size_t, ssize_t) hidden;
|
|||
ssize_t write$nt(struct Fd *, const struct iovec *, size_t, ssize_t) hidden;
|
||||
int utimensat$nt(int, const char *, const struct timespec *, int) hidden;
|
||||
int getrusage$nt(int, struct rusage *) hidden;
|
||||
int setitimer$nt(int, const struct itimerval *, struct itimerval *) hidden;
|
||||
int nanosleep$nt(const struct timespec *, struct timespec *) hidden;
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
│ cosmopolitan § syscalls » windows nt » support ─╬─│┼
|
||||
|
@ -257,6 +261,7 @@ void ntcontext2linux(struct ucontext *, const struct NtContext *) hidden;
|
|||
struct NtOverlapped *offset2overlap(int64_t, struct NtOverlapped *) hidden;
|
||||
bool32 ntsetprivilege(i64, const char16_t *, u32) hidden;
|
||||
bool32 onntconsoleevent$nt(u32) hidden;
|
||||
void onntalarm(void *, uint32_t, uint32_t) hidden;
|
||||
int ntaccesscheck(const char16_t *, u32) paramsnonnull() hidden;
|
||||
i64 ntreturn(u32);
|
||||
i64 winerr(void) nocallback privileged;
|
||||
|
|
|
@ -41,15 +41,23 @@ textwindows int ioctl$tcsets$nt(int ignored, uint64_t request,
|
|||
}
|
||||
inmode &=
|
||||
~(kNtEnableLineInput | kNtEnableEchoInput | kNtEnableProcessedInput);
|
||||
if (tio->c_lflag & ICANON) inmode |= kNtEnableLineInput;
|
||||
if (tio->c_lflag & ECHO) inmode |= kNtEnableEchoInput;
|
||||
if (tio->c_lflag & (IEXTEN | ISIG)) inmode |= kNtEnableProcessedInput;
|
||||
inmode |= kNtEnableWindowInput;
|
||||
if (NtGetVersion() >= kNtVersionWindows10) {
|
||||
inmode |= kNtEnableVirtualTerminalInput;
|
||||
}
|
||||
SetConsoleMode(in, inmode);
|
||||
}
|
||||
if (outok) {
|
||||
SetConsoleMode(out, outmode | kNtEnableProcessedOutput |
|
||||
(NtGetVersion() >= kNtVersionWindows10
|
||||
? kNtEnableVirtualTerminalProcessing
|
||||
: 0));
|
||||
outmode |= kNtEnableWrapAtEolOutput;
|
||||
outmode |= kNtEnableProcessedOutput;
|
||||
if (!(tio->c_oflag & OPOST)) outmode |= kNtDisableNewlineAutoReturn;
|
||||
if (NtGetVersion() >= kNtVersionWindows10) {
|
||||
outmode |= kNtEnableVirtualTerminalProcessing;
|
||||
}
|
||||
SetConsoleMode(out, outmode);
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
|
|
|
@ -28,25 +28,36 @@
|
|||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
textwindows int ioctl$tiocgwinsz$nt(int fd, struct winsize *ws) {
|
||||
int i, fds[3];
|
||||
uint32_t mode;
|
||||
struct NtConsoleScreenBufferInfoEx sbinfo;
|
||||
if (!isfdkind(fd, kFdFile)) return ebadf();
|
||||
if (!GetConsoleMode(g_fds.p[fd].handle, &mode)) return enotty();
|
||||
memset(&sbinfo, 0, sizeof(sbinfo));
|
||||
sbinfo.cbSize = sizeof(sbinfo);
|
||||
if (GetConsoleScreenBufferInfoEx(g_fds.p[fd].handle, &sbinfo)) {
|
||||
ws->ws_col = sbinfo.srWindow.Right - sbinfo.srWindow.Left;
|
||||
ws->ws_row = sbinfo.srWindow.Bottom - sbinfo.srWindow.Top;
|
||||
ws->ws_xpixel = 0;
|
||||
ws->ws_ypixel = 0;
|
||||
return 0;
|
||||
} else if (g_ntstartupinfo.dwFlags & kNtStartfUsecountchars) {
|
||||
ws->ws_col = g_ntstartupinfo.dwXCountChars;
|
||||
ws->ws_row = g_ntstartupinfo.dwYCountChars;
|
||||
ws->ws_xpixel = 0;
|
||||
ws->ws_ypixel = 0;
|
||||
return 0;
|
||||
} else {
|
||||
return winerr();
|
||||
fds[0] = fd, fds[1] = 1, fds[2] = 0;
|
||||
for (i = 0; i < ARRAYLEN(fds); ++i) {
|
||||
if (isfdkind(fds[i], kFdFile) || isfdkind(fds[i], kFdConsole)) {
|
||||
if (GetConsoleMode(g_fds.p[fds[i]].handle, &mode)) {
|
||||
memset(&sbinfo, 0, sizeof(sbinfo));
|
||||
sbinfo.cbSize = sizeof(sbinfo);
|
||||
if (GetConsoleScreenBufferInfoEx(g_fds.p[fds[i]].handle, &sbinfo)) {
|
||||
ws->ws_col = sbinfo.srWindow.Right - sbinfo.srWindow.Left + 1;
|
||||
ws->ws_row = sbinfo.srWindow.Bottom - sbinfo.srWindow.Top + 1;
|
||||
ws->ws_xpixel = 0;
|
||||
ws->ws_ypixel = 0;
|
||||
return 0;
|
||||
} else if (g_ntstartupinfo.dwFlags & kNtStartfUsecountchars) {
|
||||
ws->ws_col = g_ntstartupinfo.dwXCountChars;
|
||||
ws->ws_row = g_ntstartupinfo.dwYCountChars;
|
||||
ws->ws_xpixel = 0;
|
||||
ws->ws_ypixel = 0;
|
||||
return 0;
|
||||
} else {
|
||||
winerr();
|
||||
}
|
||||
} else {
|
||||
enotty();
|
||||
}
|
||||
} else {
|
||||
ebadf();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -17,27 +17,28 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/alg/bisectcarleft.h"
|
||||
#include "libc/assert.h"
|
||||
#include "libc/runtime/symbols.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/nexgen32e/nexgen32e.h"
|
||||
#include "libc/nt/enum/status.h"
|
||||
#include "libc/nt/errors.h"
|
||||
#include "libc/nt/nt/time.h"
|
||||
#include "libc/nt/synchronization.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
/**
|
||||
* Finds symbol associated with address.
|
||||
* @param symbol table pointer (null propagating)
|
||||
* @return symbol address or NULL if not found
|
||||
*/
|
||||
const struct Symbol *bisectsymbol(struct SymbolTable *t,
|
||||
intptr_t virtual_address,
|
||||
int64_t *opt_out_addend) {
|
||||
const struct Symbol *symbol = NULL;
|
||||
int64_t addend = (intptr_t)virtual_address;
|
||||
if (t && t->count) {
|
||||
unsigned key = (unsigned)((intptr_t)virtual_address - t->addr_base - 1);
|
||||
unsigned i = bisectcarleft((const int32_t(*)[2])t->symbols, t->count, key);
|
||||
assert(0 <= i && i < t->count);
|
||||
symbol = &t->symbols[i];
|
||||
addend = (int64_t)key - (int64_t)symbol->addr_rva;
|
||||
textwindows int nanosleep$nt(const struct timespec *req, struct timespec *rem) {
|
||||
int64_t millis, hectonanos, relasleep;
|
||||
if (rem) memcpy(rem, req, sizeof(*rem));
|
||||
hectonanos = req->tv_sec * 10000000ull + div100int64(req->tv_nsec);
|
||||
hectonanos = MAX(1, hectonanos);
|
||||
relasleep = -hectonanos;
|
||||
if (NtError(NtDelayExecution(true, &relasleep))) {
|
||||
millis = div10000int64(hectonanos);
|
||||
millis = MAX(1, millis);
|
||||
if (SleepEx(millis, true) == kNtWaitIoCompletion) {
|
||||
return eintr();
|
||||
}
|
||||
}
|
||||
if (opt_out_addend) *opt_out_addend = addend;
|
||||
return symbol;
|
||||
if (rem) memset(rem, 0, sizeof(*rem));
|
||||
return 0;
|
||||
}
|
|
@ -17,16 +17,15 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/elf/elf.h"
|
||||
#include "libc/runtime/symbols.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/nexgen32e/nexgen32e.h"
|
||||
#include "libc/sock/internal.h"
|
||||
|
||||
/**
|
||||
* Finds starting address of symbol.
|
||||
* @param symbol table pointer (null propagating)
|
||||
* @return name string or null if not found
|
||||
*/
|
||||
const char *getsymbolname(struct SymbolTable *t, const struct Symbol *symbol) {
|
||||
return (t && symbol)
|
||||
? getelfstring(t->elf, t->elfsize, t->name_base, symbol->name_rva)
|
||||
: NULL;
|
||||
int nanosleep$xnu(const struct timespec *req, struct timespec *rem) {
|
||||
long millis;
|
||||
millis = div1000int64(req->tv_nsec);
|
||||
millis = MAX(1, millis);
|
||||
return select$sysv(0, 0, 0, 0, &(struct timeval){req->tv_sec, millis});
|
||||
}
|
|
@ -17,48 +17,23 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/conv/conv.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/nexgen32e/nexgen32e.h"
|
||||
#include "libc/nt/enum/status.h"
|
||||
#include "libc/nt/errors.h"
|
||||
#include "libc/nt/nt/time.h"
|
||||
#include "libc/nt/synchronization.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
/**
|
||||
* Sleeps for a particular amount of time.
|
||||
*/
|
||||
int nanosleep(const struct timespec *req, struct timespec *rem) {
|
||||
long res, millis, hectonanos;
|
||||
if (!req) return efault();
|
||||
if (!IsWindows()) {
|
||||
if (!IsXnu()) {
|
||||
return nanosleep$sysv(req, rem);
|
||||
} else {
|
||||
return select$sysv(
|
||||
0, 0, 0, 0, /* lool */
|
||||
&(struct timeval){req->tv_sec, div1000int64(req->tv_nsec)});
|
||||
return nanosleep$xnu(req, rem);
|
||||
}
|
||||
} else {
|
||||
if (rem) memcpy(rem, req, sizeof(*rem));
|
||||
if (req->tv_sec && req->tv_nsec) {
|
||||
hectonanos = MAX(1, req->tv_sec * 10000000L + div100int64(req->tv_nsec));
|
||||
} else {
|
||||
hectonanos = 1;
|
||||
}
|
||||
if (NtError(NtDelayExecution(true, &hectonanos))) {
|
||||
millis = div10000int64(hectonanos);
|
||||
res = SleepEx(millis, true);
|
||||
if (res == kNtWaitIoCompletion) return eintr();
|
||||
}
|
||||
if (rem) memset(rem, 0, sizeof(*rem));
|
||||
return 0;
|
||||
return nanosleep$nt(req, rem);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,13 +31,7 @@ static struct Now {
|
|||
bool once;
|
||||
uint64_t k0;
|
||||
long double r0, cpn;
|
||||
} now_;
|
||||
|
||||
/**
|
||||
* Returns timestamp without needing system calls.
|
||||
* @note uses microsecond scale fallback on k8 or vm
|
||||
*/
|
||||
long double (*nowl)(void);
|
||||
} g_now;
|
||||
|
||||
static long double GetTimeSample(void) {
|
||||
uint64_t tick1, tick2;
|
||||
|
@ -48,7 +42,7 @@ static long double GetTimeSample(void) {
|
|||
nanosleep(&(struct timespec){0, 100000}, NULL);
|
||||
time2 = dtime(CLOCK_MONOTONIC);
|
||||
tick2 = rdtsc();
|
||||
return (time2 - time1) * 1e9 / (tick2 - tick1);
|
||||
return (time2 - time1) * 1e9 / MAX(1, tick2 - tick1);
|
||||
}
|
||||
|
||||
static long double MeasureNanosPerCycle(void) {
|
||||
|
@ -62,15 +56,15 @@ static long double MeasureNanosPerCycle(void) {
|
|||
}
|
||||
|
||||
static void InitTime(void) {
|
||||
now_.cpn = MeasureNanosPerCycle();
|
||||
now_.r0 = dtime(CLOCK_REALTIME);
|
||||
now_.k0 = rdtsc();
|
||||
now_.once = true;
|
||||
g_now.cpn = MeasureNanosPerCycle();
|
||||
g_now.r0 = dtime(CLOCK_REALTIME);
|
||||
g_now.k0 = rdtsc();
|
||||
g_now.once = true;
|
||||
}
|
||||
|
||||
long double converttickstonanos(uint64_t ticks) {
|
||||
if (!now_.once) InitTime();
|
||||
return ticks * now_.cpn; /* pico scale */
|
||||
if (!g_now.once) InitTime();
|
||||
return ticks * g_now.cpn; /* pico scale */
|
||||
}
|
||||
|
||||
long double converttickstoseconds(uint64_t ticks) {
|
||||
|
@ -83,15 +77,7 @@ long double nowl$sys(void) {
|
|||
|
||||
long double nowl$art(void) {
|
||||
uint64_t ticks;
|
||||
if (!now_.once) InitTime();
|
||||
ticks = unsignedsubtract(rdtsc(), now_.k0);
|
||||
return now_.r0 + converttickstoseconds(ticks);
|
||||
if (!g_now.once) InitTime();
|
||||
ticks = unsignedsubtract(rdtsc(), g_now.k0);
|
||||
return g_now.r0 + converttickstoseconds(ticks);
|
||||
}
|
||||
|
||||
INITIALIZER(301, _init_nowl, {
|
||||
if (X86_HAVE(INVTSC)) {
|
||||
nowl = nowl$art;
|
||||
} else {
|
||||
nowl = nowl$sys;
|
||||
}
|
||||
})
|
||||
|
|
|
@ -17,25 +17,23 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/nexgen32e/x86feature.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Checks for printable characters that aren't space / alnum.
|
||||
/ Returns timestamp without needing system calls.
|
||||
/
|
||||
/ @param edi is character to test (treated as uint8_t)
|
||||
/ @return nonzero if character matches, otherwise 0
|
||||
ispunct:.leafprologue
|
||||
.profilable
|
||||
xor %eax,%eax
|
||||
cmp $255,%edi
|
||||
ja 1f
|
||||
movslq %edi,%rdi
|
||||
ezlea kCtype,cx
|
||||
mov (%rcx,%rdi),%dl
|
||||
test $16,%dl
|
||||
je 1f
|
||||
xor %eax,%eax
|
||||
and $7,%dl
|
||||
sete %al
|
||||
1: .leafepilogue
|
||||
.endfn ispunct,globl
|
||||
/ @return seconds since unix epoch in %st0
|
||||
/ @note uses microsecond scale fallback on k8 or vm
|
||||
.initbss 202,_init_nowl
|
||||
nowl: .quad 0
|
||||
.endobj nowl,globl
|
||||
.previous
|
||||
|
||||
.init.start 202,_init_nowl
|
||||
ezlea nowl$sys,ax
|
||||
ezlea nowl$art,cx
|
||||
testb X86_HAVE(INVTSC)+kCpuids(%rip)
|
||||
cmovnz %rcx,%rax
|
||||
stosq
|
||||
.init.end 202,_init_nowl
|
||||
.source __FILE__
|
31
libc/calls/onntalarm.c
Normal file
31
libc/calls/onntalarm.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- 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 │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/struct/siginfo.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
|
||||
void onntalarm(void *lpArgToCompletionRoutine, uint32_t dwTimerLowValue,
|
||||
uint32_t dwTimerHighValue) {
|
||||
siginfo_t info;
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.si_signo = SIGALRM;
|
||||
__sigenter(info.si_signo, &info, NULL);
|
||||
}
|
|
@ -37,9 +37,9 @@ textwindows bool32 onntconsoleevent(uint32_t CtrlType) {
|
|||
case kNtCtrlCloseEvent:
|
||||
sig = pushpop(SIGHUP);
|
||||
break;
|
||||
case kNtCtrlLogoffEvent:
|
||||
case kNtCtrlShutdownEvent:
|
||||
sig = pushpop(SIGTERM);
|
||||
case kNtCtrlLogoffEvent: // only received by services so hack hack hack
|
||||
case kNtCtrlShutdownEvent: // only received by services so hack hack hack
|
||||
sig = pushpop(SIGALRM);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "libc/bits/weaken.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
@ -47,7 +48,7 @@ ssize_t pread(int fd, void *buf, size_t size, int64_t offset) {
|
|||
} else if (!IsWindows()) {
|
||||
rc = pread$sysv(fd, buf, size, offset);
|
||||
} else if (isfdkind(fd, kFdFile)) {
|
||||
rc = read$nt(&g_fds.p[fd], buf, size, offset);
|
||||
rc = read$nt(&g_fds.p[fd], (struct iovec[]){{buf, size}}, 1, offset);
|
||||
} else {
|
||||
rc = ebadf();
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ ssize_t preadv(int fd, struct iovec *iovec, int count, int64_t off) {
|
|||
*/
|
||||
if (!once) {
|
||||
once = true;
|
||||
if (IsLinux() && iovec->iov_len >= __NR_preadv_linux) {
|
||||
if (IsModeDbg() || (IsLinux() && iovec->iov_len >= __NR_preadv_linux)) {
|
||||
/*
|
||||
* Read size is too large to detect older kernels safely without
|
||||
* introducing nontrivial mechanics. We'll try again later.
|
||||
|
|
|
@ -29,7 +29,12 @@
|
|||
#define __NR_pwritev_linux 0x0128
|
||||
|
||||
/**
|
||||
* Writes data from multiple buffers to file descriptor at offset.
|
||||
* Writes data from multiple buffers to offset.
|
||||
*
|
||||
* Please note that it's not an error for a short write to happen. This
|
||||
* can happen in the kernel if EINTR happens after some of the write has
|
||||
* been committed. It can also happen if we need to polyfill this system
|
||||
* call using pwrite().
|
||||
*
|
||||
* @param count is recommended to be 16 or fewer; if it exceeds IOV_MAX
|
||||
* then the extra buffers are simply ignored
|
||||
|
@ -48,7 +53,7 @@ ssize_t pwritev(int fd, const struct iovec *iovec, int count, int64_t off) {
|
|||
*/
|
||||
if (!once) {
|
||||
once = true;
|
||||
if (IsLinux() && iovec->iov_len >= __NR_pwritev_linux) {
|
||||
if (IsModeDbg() || (IsLinux() && iovec->iov_len >= __NR_pwritev_linux)) {
|
||||
/*
|
||||
* Write size is too large to detect older kernels safely without
|
||||
* introducing nontrivial mechanics. We'll try again later.
|
||||
|
|
124
libc/calls/readansi.c
Normal file
124
libc/calls/readansi.c
Normal file
|
@ -0,0 +1,124 @@
|
|||
/*-*- 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 │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/str/thompike.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
/**
|
||||
* Reads single keystroke or control sequence from character device.
|
||||
*
|
||||
* When reading ANSI UTF-8 text streams, characters and control codes
|
||||
* are oftentimes encoded as multi-byte sequences. This function knows
|
||||
* how long each sequence is, so that each read consumes a single thing
|
||||
* from the underlying file descriptor, e.g.
|
||||
*
|
||||
* "a" ALFA
|
||||
* "\316\261" ALPHA
|
||||
* "\033[A" CURSOR UP
|
||||
* "\033[38;5;202m" ORANGERED
|
||||
* "\eOP" PF1
|
||||
*
|
||||
* This routine generalizes to ascii, utf-8, chorded modifier keys,
|
||||
* function keys, color codes, c0/c1 control codes, cursor movement,
|
||||
* mouse movement, etc.
|
||||
*
|
||||
* Userspace buffering isn't required, since ANSI escape sequences and
|
||||
* UTF-8 are decoded without peeking. Noncanonical overlong encodings
|
||||
* can cause the stream to go out of sync. This function recovers such
|
||||
* events by ignoring continuation bytes at the beginning of each read.
|
||||
*
|
||||
* String control sequences, e.g. "\e_hello\e\\" currently are not
|
||||
* tokenized as a single read. Lastly note, this function has limited
|
||||
* support for UNICODE representations of C0/C1 control codes, e.g.
|
||||
*
|
||||
* "\000" NUL
|
||||
* "\300\200" NUL
|
||||
* "\302\233A" CURSOR UP
|
||||
*
|
||||
* @param buf is guaranteed to receive a NUL terminator if size>0
|
||||
* @return number of bytes read (helps differentiate "\0" vs. "")
|
||||
* @see examples/ttyinfo.c
|
||||
* @see ANSI X3.64-1979
|
||||
* @see ISO/IEC 6429
|
||||
* @see FIPS-86
|
||||
* @see ECMA-48
|
||||
*/
|
||||
ssize_t readansi(int fd, char *buf, size_t size) {
|
||||
int i, j;
|
||||
uint8_t c;
|
||||
enum { kAscii, kUtf8, kEsc, kCsi, kSs } t;
|
||||
if (size) buf[0] = 0;
|
||||
for (j = i = 0, t = kAscii;;) {
|
||||
if (i + 2 >= size) return enomem();
|
||||
if (read(fd, &c, 1) != 1) return -1;
|
||||
buf[i++] = c;
|
||||
buf[i] = 0;
|
||||
switch (t) {
|
||||
case kAscii:
|
||||
if (c < 0200) {
|
||||
if (c == '\e') {
|
||||
t = kEsc;
|
||||
} else {
|
||||
return i;
|
||||
}
|
||||
} else if (c >= 0300) {
|
||||
t = kUtf8;
|
||||
j = ThomPikeLen(c) - 1;
|
||||
}
|
||||
break;
|
||||
case kUtf8:
|
||||
if (!--j) return i;
|
||||
break;
|
||||
case kEsc:
|
||||
switch (c) {
|
||||
case '[':
|
||||
t = kCsi;
|
||||
break;
|
||||
case 'N':
|
||||
case 'O':
|
||||
t = kSs;
|
||||
break;
|
||||
case 0x20 ... 0x2F:
|
||||
break;
|
||||
default:
|
||||
return i;
|
||||
}
|
||||
break;
|
||||
case kCsi:
|
||||
switch (c) {
|
||||
case ':':
|
||||
case ';':
|
||||
case '<':
|
||||
case '=':
|
||||
case '>':
|
||||
case '?':
|
||||
case '0' ... '9':
|
||||
break;
|
||||
default:
|
||||
return i;
|
||||
}
|
||||
break;
|
||||
case kSs:
|
||||
return i;
|
||||
default:
|
||||
unreachable;
|
||||
}
|
||||
}
|
||||
}
|
104
libc/calls/setitimer-nt.c
Normal file
104
libc/calls/setitimer-nt.c
Normal file
|
@ -0,0 +1,104 @@
|
|||
/*-*- 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 │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/struct/itimerval.h"
|
||||
#include "libc/conv/conv.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/nexgen32e/nexgen32e.h"
|
||||
#include "libc/nt/files.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/nt/synchronization.h"
|
||||
#include "libc/nt/thread.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/itimer.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
/**
|
||||
* @fileoverview Heartbreaking polyfill for SIGALRM on NT.
|
||||
*
|
||||
* Threads are used to trigger the SIGALRM handler, which should
|
||||
* hopefully be an unfancy function like this:
|
||||
*
|
||||
* void OnAlarm(int sig, struct siginfo *si, struct ucontext *uc) {
|
||||
* g_alarmed = true;
|
||||
* }
|
||||
*
|
||||
* This is needed because WIN32 provides no obvious solutions for
|
||||
* interrupting i/o operations on the standard input handle.
|
||||
*/
|
||||
|
||||
static struct ItimerNt {
|
||||
int64_t ith;
|
||||
uint32_t tid;
|
||||
struct itimerval itv;
|
||||
} g_itimernt;
|
||||
|
||||
static uint32_t ItimerWorker(void *arg) {
|
||||
do {
|
||||
if (!WaitForSingleObject(g_itimernt.ith, -1)) {
|
||||
onntalarm(NULL, 0, 0);
|
||||
}
|
||||
} while (g_itimernt.ith && g_itimernt.tid == GetCurrentThreadId());
|
||||
return 0;
|
||||
}
|
||||
|
||||
textwindows int setitimer$nt(int which, const struct itimerval *newvalue,
|
||||
struct itimerval *out_opt_oldvalue) {
|
||||
int32_t period;
|
||||
int64_t ith, duetime;
|
||||
if (which != ITIMER_REAL) return einval();
|
||||
if (newvalue) {
|
||||
if (newvalue->it_value.tv_sec && newvalue->it_value.tv_usec) {
|
||||
if (!(ith = CreateWaitableTimer(NULL, false, NULL))) {
|
||||
return winerr();
|
||||
}
|
||||
duetime = -(newvalue->it_value.tv_sec * HECTONANOSECONDS +
|
||||
newvalue->it_value.tv_usec * 10);
|
||||
period = newvalue->it_value.tv_sec * 1000 +
|
||||
div1000int64(newvalue->it_value.tv_usec);
|
||||
if (!period && newvalue->it_value.tv_usec) period = 1;
|
||||
if (!SetWaitableTimer(ith, &duetime, period, NULL, NULL, false)) {
|
||||
errno = GetLastError();
|
||||
CloseHandle(ith);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
ith = 0;
|
||||
}
|
||||
if (g_itimernt.ith) {
|
||||
CloseHandle(g_itimernt.ith);
|
||||
g_itimernt.ith = 0;
|
||||
}
|
||||
} else {
|
||||
ith = 0;
|
||||
}
|
||||
if (out_opt_oldvalue) {
|
||||
memcpy(out_opt_oldvalue, &g_itimernt.itv, sizeof(struct itimerval));
|
||||
}
|
||||
if (ith) {
|
||||
g_itimernt.ith = ith;
|
||||
memcpy(&g_itimernt.itv, newvalue, sizeof(struct itimerval));
|
||||
CloseHandle(
|
||||
CreateThread(NULL, STACKSIZE, ItimerWorker, NULL, 0, &g_itimernt.tid));
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -24,7 +24,18 @@
|
|||
#include "libc/time/time.h"
|
||||
|
||||
/**
|
||||
* Schedules delivery of one-shot or intermittent wakeup signal, e.g.
|
||||
* Schedules delivery of one-shot or intermittent interrupt signal, e.g.
|
||||
*
|
||||
* Raise SIGALRM every 1.5s:
|
||||
*
|
||||
* CHECK_NE(-1, sigaction(SIGALRM,
|
||||
* &(struct sigaction){.sa_sigaction = missingno},
|
||||
* NULL));
|
||||
* CHECK_NE(-1, setitimer(ITIMER_REAL,
|
||||
* &(const struct itimerval){{1, 500000}, {1, 500000}},
|
||||
* NULL));
|
||||
*
|
||||
* Set single-shot 50ms timer callback to interrupt laggy connect():
|
||||
*
|
||||
* CHECK_NE(-1, sigaction(SIGALRM,
|
||||
* &(struct sigaction){.sa_sigaction = missingno,
|
||||
|
@ -34,21 +45,29 @@
|
|||
* &(const struct itimerval){{0, 0}, {0, 50000}},
|
||||
* NULL));
|
||||
* if (connect(...) == -1 && errno == EINTR) { ... }
|
||||
* CHECK_NE(-1, setitimer(ITIMER_REAL,
|
||||
* &(const struct itimerval){{0, 0}, {0, 0}},
|
||||
* NULL));
|
||||
*
|
||||
* Disarm timer:
|
||||
*
|
||||
* CHECK_NE(-1, setitimer(ITIMER_REAL, &(const struct itimerval){0}, NULL));
|
||||
*
|
||||
* Be sure to check for EINTR on your i/o calls, for best low latency.
|
||||
*
|
||||
* @param which can be ITIMER_REAL, ITIMER_VIRTUAL, etc.
|
||||
* @param newvalue specifies the interval ({0,0} means one-shot) and
|
||||
* duration ({0,0} means disarm) in microseconds
|
||||
* duration ({0,0} means disarm) in microseconds ∈ [0,999999] and
|
||||
* if this parameter is NULL, we'll polyfill getitimer() behavior
|
||||
* @param out_opt_old may receive remainder of previous op (if any)
|
||||
* @return 0 on success or -1 w/ errno
|
||||
*/
|
||||
int setitimer(int which, const struct itimerval *newvalue,
|
||||
struct itimerval *out_opt_oldvalue) {
|
||||
if (!IsWindows()) {
|
||||
return setitimer$sysv(which, newvalue, out_opt_oldvalue);
|
||||
if (newvalue) {
|
||||
return setitimer$sysv(which, newvalue, out_opt_oldvalue);
|
||||
} else {
|
||||
return getitimer$sysv(which, out_opt_oldvalue);
|
||||
}
|
||||
} else {
|
||||
return enosys(); /* TODO(jart): Implement me! */
|
||||
return setitimer$nt(which, newvalue, out_opt_oldvalue);
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
#include "libc/calls/struct/timespec.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
struct stat {
|
||||
struct stat { /* linux abi */
|
||||
int64_t st_dev; /* 0: id of device with file */
|
||||
int64_t st_ino; /* 8: inode number in disk b-tree */
|
||||
int64_t st_nlink; /* 16: hard link count */
|
||||
|
|
|
@ -18,14 +18,10 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.real
|
||||
.text.windows
|
||||
.source __FILE__
|
||||
.code16 # ∩ .code32 ∩ .code64
|
||||
|
||||
__unprovable:
|
||||
push %bp
|
||||
mov %sp,%bp
|
||||
.softicebp
|
||||
pop %bp
|
||||
ret
|
||||
.endfn __unprovable,globl,hidden
|
||||
onntalarm$nt:
|
||||
ezlea onntalarm,ax
|
||||
jmp nt2sysv
|
||||
.endfn onntalarm$nt,globl,hidden
|
|
@ -1,10 +1,9 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_TYPEDEF_SIGACTION_F_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_TYPEDEF_SIGACTION_F_H_
|
||||
#include "libc/calls/struct/siginfo.h"
|
||||
#include "libc/calls/ucontext.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
struct siginfo;
|
||||
struct ucontext;
|
||||
|
||||
typedef void (*sigaction_f)(int, struct siginfo *, struct ucontext *);
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_UCONTEXT_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_UCONTEXT_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/sigaltstack.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
|
|
@ -27,6 +27,11 @@
|
|||
/**
|
||||
* Writes data from multiple buffers.
|
||||
*
|
||||
* Please note that it's not an error for a short write to happen. This
|
||||
* can happen in the kernel if EINTR happens after some of the write has
|
||||
* been committed. It can also happen if we need to polyfill this system
|
||||
* call using write().
|
||||
*
|
||||
* @return number of bytes actually handed off, or -1 w/ errno
|
||||
*/
|
||||
ssize_t writev(int fd, const struct iovec *iov, int iovlen) {
|
||||
|
|
|
@ -27,9 +27,9 @@ long long llabs(long long) libcesque pureconst;
|
|||
char *ltpcpy(char *, long) paramsnonnull() libcesque nocallback;
|
||||
int llog10(unsigned long) libcesque pureconst;
|
||||
int unsleb128(const void *, size_t, int64_t *);
|
||||
int atoi(const char *) paramsnonnull() libcesque nosideeffect;
|
||||
long atol(const char *) paramsnonnull() libcesque nosideeffect;
|
||||
long long atoll(const char *) paramsnonnull() libcesque nosideeffect;
|
||||
int atoi(const char *) paramsnonnull() libcesque;
|
||||
long atol(const char *) paramsnonnull() libcesque;
|
||||
long long atoll(const char *) paramsnonnull() libcesque;
|
||||
unsigned long strtoul(const char *, char **, int) paramsnonnull((1));
|
||||
long long strtoll(const char *, char **, int) paramsnonnull((1));
|
||||
unsigned long long strtoull(const char *, char **, int) paramsnonnull((1));
|
||||
|
@ -39,8 +39,7 @@ intmax_t strtoimax(const char *, char **, int) paramsnonnull((1));
|
|||
uintmax_t strtoumax(const char *, char **, int) paramsnonnull((1));
|
||||
intmax_t wcstoimax(const wchar_t *, wchar_t **, int);
|
||||
long wcstol(const wchar_t *, wchar_t **, int);
|
||||
long strtol(const char *, char **, int)
|
||||
paramsnonnull((1)) libcesque nosideeffect;
|
||||
long strtol(const char *, char **, int) paramsnonnull((1)) libcesque;
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
│ cosmopolitan § conversion » time ─╬─│┼
|
||||
|
|
|
@ -35,8 +35,9 @@ LIBC_CONV_A_CHECKS = \
|
|||
$(LIBC_CONV_A_HDRS:%=o/$(MODE)/%.ok)
|
||||
|
||||
LIBC_CONV_A_DIRECTDEPS = \
|
||||
LIBC_STUBS \
|
||||
LIBC_NEXGEN32E \
|
||||
LIBC_STUBS \
|
||||
LIBC_STR \
|
||||
LIBC_TINYMATH \
|
||||
LIBC_SYSV \
|
||||
THIRD_PARTY_COMPILER_RT
|
||||
|
|
|
@ -92,14 +92,21 @@ static int ppatoi(const char **str) {
|
|||
*
|
||||
* Precision Modifiers
|
||||
*
|
||||
* - `%.8s` supplied character length (ignore nul terminator)
|
||||
* - `%.*s` supplied character length argument (ignore nul terminator)
|
||||
* - `%.8s` supplied byte length (obeys nul terminator)
|
||||
* - `%.*s` supplied byte length argument (obeys nul terminator)
|
||||
* - `%`.*s` supplied byte length argument c escaped (ignores nul terminator)
|
||||
* - `%#.*s` supplied byte length argument visualized (ignores nul terminator)
|
||||
* - `%.*hs` supplied char16_t length argument (obeys nul terminator)
|
||||
* - `%.*ls` supplied wchar_t length argument (obeys nul terminator)
|
||||
*
|
||||
* Formatting Modifiers
|
||||
*
|
||||
* - `%,d` thousands separators
|
||||
* - `%'s` escaped c string literal
|
||||
* - `%'c` escaped c character literal
|
||||
* - `%`c` c escaped character
|
||||
* - `%`'c` c escaped character quoted
|
||||
* - `%`s` c escaped string
|
||||
* - `%`'s` c escaped string quoted
|
||||
* - `%`s` escaped double quoted c string literal
|
||||
* - `%`c` escaped double quoted c character literal
|
||||
* - `%+d` plus leftpad if positive (aligns w/ negatives)
|
||||
|
@ -114,7 +121,7 @@ hidden int palandprintf(void *fn, void *arg, const char *format, va_list va) {
|
|||
void *p;
|
||||
char qchar;
|
||||
long double ldbl;
|
||||
wchar_t charbuf[3];
|
||||
wchar_t charbuf[1];
|
||||
const char *alphabet;
|
||||
int (*out)(long, void *);
|
||||
unsigned char signbit, log2base;
|
||||
|
@ -281,14 +288,15 @@ hidden int palandprintf(void *fn, void *arg, const char *format, va_list va) {
|
|||
break;
|
||||
|
||||
case 'c':
|
||||
precision = 1;
|
||||
flags |= FLAGS_PRECISION;
|
||||
qchar = '\'';
|
||||
p = charbuf;
|
||||
charbuf[0] = va_arg(va, int);
|
||||
charbuf[1] = L'\0';
|
||||
charbuf[0] = va_arg(va, int); /* assume little endian */
|
||||
goto showstr;
|
||||
|
||||
case 'm':
|
||||
p = weaken(strerror)(lasterr);
|
||||
p = weaken(strerror) ? weaken(strerror)(lasterr) : "?";
|
||||
signbit = 0;
|
||||
goto showstr;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ static int StoaEmitWordEncodedString(int f(long, void *), void *a, uint64_t w) {
|
|||
}
|
||||
|
||||
static int StoaEmitUnicode(int f(long, void *), void *a, wint_t c) {
|
||||
if (0 <= c && c <= 127) {
|
||||
if (isascii(c)) {
|
||||
return f(c, a);
|
||||
} else {
|
||||
return StoaEmitWordEncodedString(f, a, tpenc(c));
|
||||
|
@ -52,7 +52,7 @@ static int StoaEmitUnicode(int f(long, void *), void *a, wint_t c) {
|
|||
}
|
||||
|
||||
static int StoaEmitQuoted(int f(long, void *), void *a, wint_t c) {
|
||||
if (0 <= c && c <= 127) {
|
||||
if (isascii(c)) {
|
||||
return StoaEmitWordEncodedString(f, a, cescapec(c));
|
||||
} else {
|
||||
return StoaEmitWordEncodedString(f, a, tpenc(c));
|
||||
|
@ -92,8 +92,8 @@ int stoa(int out(long, void *), void *arg, void *data, unsigned long flags,
|
|||
wint_t wc;
|
||||
unsigned n;
|
||||
emit_f emit;
|
||||
bool justdobytes;
|
||||
unsigned w, c, pad;
|
||||
bool justdobytes, ignorenul;
|
||||
|
||||
p = data;
|
||||
if (!p) {
|
||||
|
@ -105,13 +105,35 @@ int stoa(int out(long, void *), void *arg, void *data, unsigned long flags,
|
|||
if (StoaEmitQuote(out, arg, flags, qchar, signbit) == -1) return -1;
|
||||
}
|
||||
|
||||
if (!(flags & FLAGS_PRECISION)) {
|
||||
if (signbit == 63) {
|
||||
precision = tinywcsnlen((const wchar_t *)p, -1);
|
||||
} else if (signbit == 15) {
|
||||
precision = tinystrnlen16((const char16_t *)p, -1);
|
||||
ignorenul = false;
|
||||
justdobytes = false;
|
||||
if (signbit == 15 || signbit == 63) {
|
||||
if (flags & FLAGS_QUOTE) {
|
||||
emit = StoaEmitQuoted;
|
||||
ignorenul = flags & FLAGS_PRECISION;
|
||||
} else {
|
||||
precision = strlen(p);
|
||||
emit = StoaEmitUnicode;
|
||||
}
|
||||
} else if ((flags & FLAGS_HASH) && weaken(kCp437)) {
|
||||
justdobytes = true;
|
||||
emit = StoaEmitVisualized;
|
||||
ignorenul = flags & FLAGS_PRECISION;
|
||||
} else if (flags & FLAGS_QUOTE) {
|
||||
emit = StoaEmitQuoted;
|
||||
ignorenul = flags & FLAGS_PRECISION;
|
||||
} else {
|
||||
justdobytes = true;
|
||||
emit = StoaEmitByte;
|
||||
}
|
||||
|
||||
if (!(flags & FLAGS_PRECISION)) precision = -1;
|
||||
if (!(flags & FLAGS_PRECISION) || !ignorenul) {
|
||||
if (signbit == 63) {
|
||||
precision = tinywcsnlen((const wchar_t *)p, precision);
|
||||
} else if (signbit == 15) {
|
||||
precision = tinystrnlen16((const char16_t *)p, precision);
|
||||
} else {
|
||||
precision = strnlen(p, precision);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,32 +160,17 @@ int stoa(int out(long, void *), void *arg, void *data, unsigned long flags,
|
|||
if (spacepad(out, arg, pad) == -1) return -1;
|
||||
}
|
||||
|
||||
justdobytes = false;
|
||||
if (signbit == 15 || signbit == 63) {
|
||||
if (flags & FLAGS_QUOTE) {
|
||||
emit = StoaEmitQuoted;
|
||||
} else {
|
||||
emit = StoaEmitUnicode;
|
||||
}
|
||||
} else if ((flags & FLAGS_HASH) && weaken(kCp437)) {
|
||||
justdobytes = true;
|
||||
emit = StoaEmitVisualized;
|
||||
} else if (flags & FLAGS_QUOTE) {
|
||||
emit = StoaEmitQuoted;
|
||||
} else {
|
||||
justdobytes = true;
|
||||
emit = StoaEmitByte;
|
||||
}
|
||||
|
||||
if (justdobytes) {
|
||||
while (precision--) {
|
||||
wc = *p++ & 0xff;
|
||||
if (!wc && !ignorenul) break;
|
||||
if (emit(out, arg, wc) == -1) return -1;
|
||||
}
|
||||
} else {
|
||||
while (precision--) {
|
||||
if (signbit == 15) {
|
||||
wc = *(const char16_t *)p;
|
||||
if (!wc && !ignorenul) break;
|
||||
if (IsUcs2(wc)) {
|
||||
p += sizeof(char16_t);
|
||||
} else if (IsUtf16Cont(wc)) {
|
||||
|
@ -177,10 +184,12 @@ int stoa(int out(long, void *), void *arg, void *data, unsigned long flags,
|
|||
}
|
||||
} else if (signbit == 63) {
|
||||
wc = *(const wint_t *)p;
|
||||
if (!wc && !ignorenul) break;
|
||||
p += sizeof(wint_t);
|
||||
if (!wc) break;
|
||||
} else {
|
||||
wc = *p++ & 0xff;
|
||||
if (!wc && !ignorenul) break;
|
||||
if (!isascii(wc)) {
|
||||
if (ThomPikeCont(wc)) continue;
|
||||
n = ThomPikeLen(wc) - 1;
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
/**
|
||||
* Compares signed 8-bit integers w/ greater than predicate.
|
||||
*
|
||||
* Note that operands can be xor'd with 0x80 for unsigned compares.
|
||||
*
|
||||
* @param 𝑎 [w/o] receives result
|
||||
* @param 𝑏 [r/o] supplies first input vector
|
||||
* @param 𝑐 [r/o] supplies second input vector
|
||||
|
|
|
@ -19,6 +19,12 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/pmovmskb.h"
|
||||
|
||||
/**
|
||||
* Turns result of byte comparison into bitmask.
|
||||
*
|
||||
* @param 𝑝 is byte vector to crunch
|
||||
* @see pcmpeqb(), bsf(), etc.
|
||||
*/
|
||||
uint32_t(pmovmskb)(const uint8_t p[16]) {
|
||||
uint32_t i, m;
|
||||
for (m = i = 0; i < 16; ++i) {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/pshufd.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
/**
|
||||
* Shuffles int vector.
|
||||
|
@ -30,8 +31,5 @@ void(pshufd)(int32_t b[4], const int32_t a[4], uint8_t m) {
|
|||
t[1] = a[(m & 0b00001100) >> 2];
|
||||
t[2] = a[(m & 0b00110000) >> 4];
|
||||
t[3] = a[(m & 0b11000000) >> 6];
|
||||
b[0] = t[0];
|
||||
b[1] = t[1];
|
||||
b[2] = t[2];
|
||||
b[3] = t[3];
|
||||
memcpy(b, t, 16);
|
||||
}
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
* @param 𝑐 [r/o] supplies second input vector
|
||||
* @mayalias
|
||||
*/
|
||||
void(psubb)(int8_t a[16], const int8_t b[16], const int8_t c[16]) {
|
||||
void(psubb)(uint8_t a[16], const uint8_t b[16], const uint8_t c[16]) {
|
||||
unsigned i;
|
||||
int8_t r[16];
|
||||
uint8_t r[16];
|
||||
for (i = 0; i < 16; ++i) {
|
||||
r[i] = b[i] - c[i];
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
void psubb(int8_t[16], const int8_t[16], const int8_t[16]);
|
||||
void psubb(uint8_t[16], const uint8_t[16], const uint8_t[16]);
|
||||
|
||||
#define psubb(A, B, C) \
|
||||
INTRIN_SSEVEX_X_X_X_(psubb, SSE2, "psubb", INTRIN_NONCOMMUTATIVE, A, B, C)
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#define PVOID void*
|
||||
#define PVOID64 void*
|
||||
#define LPCVOID const void*
|
||||
#define CHAR char
|
||||
#define SHORT short
|
||||
#define CONST const
|
||||
|
|
12
libc/linux/close.h
Normal file
12
libc/linux/close.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_LINUX_CLOSE_H_
|
||||
#define COSMOPOLITAN_LIBC_LINUX_CLOSE_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
forceinline long LinuxClose(long fd) {
|
||||
long rc;
|
||||
asm volatile("syscall" : "=a"(rc) : "0"(3), "D"(fd) : "rcx", "r11", "memory");
|
||||
return rc;
|
||||
}
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_LINUX_CLOSE_H_ */
|
|
@ -3,7 +3,7 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
forceinline noreturn long LinuxExit(int rc) {
|
||||
forceinline noreturn long LinuxExit(long rc) {
|
||||
asm volatile("syscall"
|
||||
: /* no outputs */
|
||||
: "a"(0xE7), "D"(rc)
|
||||
|
|
16
libc/linux/fstat.h
Normal file
16
libc/linux/fstat.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_LINUX_FSTAT_H_
|
||||
#define COSMOPOLITAN_LIBC_LINUX_FSTAT_H_
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
forceinline long LinuxFstat(long fd, struct stat *st) {
|
||||
long rc;
|
||||
asm volatile("syscall"
|
||||
: "=a"(rc)
|
||||
: "0"(5), "D"(fd), "S"(st)
|
||||
: "rcx", "r11", "memory");
|
||||
return rc;
|
||||
}
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_LINUX_FSTAT_H_ */
|
20
libc/linux/mmap.h
Normal file
20
libc/linux/mmap.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_LINUX_MMAP_H_
|
||||
#define COSMOPOLITAN_LIBC_LINUX_MMAP_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
forceinline long LinuxMmap(void *addr, size_t size, long prot, long flags,
|
||||
long fd, long off) {
|
||||
long rc;
|
||||
register long r10 asm("r10") = flags;
|
||||
register long r8 asm("r8") = fd;
|
||||
register long r9 asm("r9") = off;
|
||||
asm volatile("syscall"
|
||||
: "=a"(rc)
|
||||
: "0"(9), "D"(addr), "S"(size), "d"(prot), "r"(r10), "r"(r8),
|
||||
"r"(r9)
|
||||
: "rcx", "r11", "memory");
|
||||
return rc;
|
||||
}
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_LINUX_MMAP_H_ */
|
15
libc/linux/munmap.h
Normal file
15
libc/linux/munmap.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_LINUX_MUNMAP_H_
|
||||
#define COSMOPOLITAN_LIBC_LINUX_MUNMAP_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
forceinline long LinuxMunmap(void *addr, size_t size) {
|
||||
long rc;
|
||||
asm volatile("syscall"
|
||||
: "=a"(rc)
|
||||
: "0"(0xb), "D"(addr), "S"(size)
|
||||
: "rcx", "r11", "memory");
|
||||
return rc;
|
||||
}
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_LINUX_MUNMAP_H_ */
|
15
libc/linux/open.h
Normal file
15
libc/linux/open.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_LINUX_OPEN_H_
|
||||
#define COSMOPOLITAN_LIBC_LINUX_OPEN_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
forceinline long LinuxOpen(const char *path, long flags, long mode) {
|
||||
long rc;
|
||||
asm volatile("syscall"
|
||||
: "=a"(rc)
|
||||
: "0"(2), "D"(path), "S"(flags), "d"(mode)
|
||||
: "rcx", "r11", "memory");
|
||||
return rc;
|
||||
}
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_LINUX_OPEN_H_ */
|
|
@ -2,7 +2,7 @@
|
|||
#define COSMOPOLITAN_LIBC_LINUX_READ_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
forceinline long LinuxRead(int fd, void *data, unsigned long size) {
|
||||
forceinline long LinuxRead(long fd, void *data, unsigned long size) {
|
||||
long rc;
|
||||
asm volatile("syscall"
|
||||
: "=a"(rc), "=m"(*(char(*)[size])data)
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_LINUX_WRITE_H_
|
||||
#define COSMOPOLITAN_LIBC_LINUX_WRITE_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
forceinline long LinuxWrite(int fd, const void *data, unsigned long size) {
|
||||
forceinline long LinuxWrite(long fd, const void *data, unsigned long size) {
|
||||
long rc;
|
||||
asm volatile("syscall"
|
||||
: "=a"(rc)
|
||||
|
@ -13,6 +12,5 @@ forceinline long LinuxWrite(int fd, const void *data, unsigned long size) {
|
|||
return rc;
|
||||
}
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_LINUX_WRITE_H_ */
|
||||
|
|
|
@ -17,25 +17,14 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/weaken.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/conv/conv.h"
|
||||
#include "libc/conv/itoa.h"
|
||||
#include "libc/log/asan.h"
|
||||
#include "libc/log/backtrace.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/mem/hook/hook.h"
|
||||
#include "libc/runtime/directmap.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/memtrack.h"
|
||||
#include "libc/runtime/missioncritical.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/symbols.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/fileno.h"
|
||||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
|
@ -154,9 +143,9 @@ static const char *__asan_describe_access_poison(int c) {
|
|||
}
|
||||
|
||||
static noreturn void __asan_die(const char *msg, size_t size) {
|
||||
__print(msg, size);
|
||||
PrintBacktraceUsingSymbols(stderr, __builtin_frame_address(0),
|
||||
getsymboltable());
|
||||
write(STDERR_FILENO, msg, size);
|
||||
PrintBacktraceUsingSymbols(STDERR_FILENO, __builtin_frame_address(0),
|
||||
GetSymbolTable());
|
||||
DebugBreak();
|
||||
_Exit(66);
|
||||
}
|
||||
|
@ -170,7 +159,7 @@ static noreturn void __asan_report_deallocate_fault(void *addr, int c) {
|
|||
p = mempcpy(p, ibuf, int64toarray_radix10(c, ibuf));
|
||||
p = stpcpy(p, " at 0x");
|
||||
p = mempcpy(p, ibuf, uint64toarray_fixed16((intptr_t)addr, ibuf, 48));
|
||||
p = stpcpy(p, "\n");
|
||||
p = stpcpy(p, "\r\n");
|
||||
__asan_die(buf, p - buf);
|
||||
}
|
||||
|
||||
|
@ -186,7 +175,7 @@ static noreturn void __asan_report_memory_fault(uint8_t *addr, int size,
|
|||
p = stpcpy(p, kind);
|
||||
p = stpcpy(p, " at 0x");
|
||||
p = mempcpy(p, ibuf, uint64toarray_fixed16((intptr_t)addr, ibuf, 48));
|
||||
p = stpcpy(p, "\n");
|
||||
p = stpcpy(p, "\r\n");
|
||||
__asan_die(buf, p - buf);
|
||||
}
|
||||
|
||||
|
@ -209,13 +198,6 @@ static void __asan_morgue_flush(void) {
|
|||
}
|
||||
}
|
||||
|
||||
static bool __asan_is_mapped(void *p) {
|
||||
int x, i;
|
||||
x = (intptr_t)p >> 16;
|
||||
i = FindMemoryInterval(&_mmi, x);
|
||||
return i < _mmi.i && x >= _mmi.p[i].x && x <= _mmi.p[i].y;
|
||||
}
|
||||
|
||||
static void *__asan_allocate(size_t align, size_t size, int underrun,
|
||||
int overrun) {
|
||||
char *p, *s;
|
||||
|
@ -394,44 +376,62 @@ void __asan_install_malloc_hooks(void) {
|
|||
HOOK(hook$malloc_usable_size, __asan_malloc_usable_size);
|
||||
}
|
||||
|
||||
void __asan_map_shadow(void *addr, size_t size) {
|
||||
int i, n, x;
|
||||
char *a, *b;
|
||||
static bool __asan_is_mapped(int x) {
|
||||
int i = FindMemoryInterval(&_mmi, x);
|
||||
return i < _mmi.i && x >= _mmi.p[i].x && x <= _mmi.p[i].y;
|
||||
}
|
||||
|
||||
void __asan_map_shadow(void *p, size_t n) {
|
||||
int i, x, a, b;
|
||||
struct DirectMap sm;
|
||||
a = (char *)ROUNDDOWN(SHADOW((intptr_t)addr), FRAMESIZE);
|
||||
b = (char *)ROUNDDOWN(SHADOW((intptr_t)addr + size - 1), FRAMESIZE);
|
||||
for (; a <= b; a += FRAMESIZE) {
|
||||
a = SHADOW((uintptr_t)p) >> 16;
|
||||
b = ROUNDUP(SHADOW(ROUNDUP((uintptr_t)p + n, 8)), 1 << 16) >> 16;
|
||||
for (; a < b; ++a) {
|
||||
if (!__asan_is_mapped(a)) {
|
||||
sm = DirectMap(a, FRAMESIZE, PROT_READ | PROT_WRITE,
|
||||
sm = DirectMap((void *)((uintptr_t)a << 16), 1 << 16,
|
||||
PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
|
||||
if (sm.addr == MAP_FAILED ||
|
||||
TrackMemoryInterval(&_mmi, (intptr_t)a >> 16, (intptr_t)a >> 16,
|
||||
sm.maphandle) == -1) {
|
||||
TrackMemoryInterval(&_mmi, a, a, sm.maphandle) == -1) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
textstartup void __asan_init(int argc, char *argv[], char **envp,
|
||||
intptr_t *auxv) {
|
||||
int i;
|
||||
static bool once;
|
||||
register intptr_t rsp asm("rsp");
|
||||
if (!once) {
|
||||
__asan_map_shadow(_base, _end - _base);
|
||||
__asan_map_shadow((void *)ROUNDDOWN(rsp, STACKSIZE), STACKSIZE);
|
||||
for (i = 0; i < argc; ++i) __asan_map_shadow(argv[i], strlen(argv[i]));
|
||||
for (; *envp; ++envp) __asan_map_shadow(*envp, strlen(*envp));
|
||||
__asan_map_shadow(auxv, sizeof(intptr_t) * 2);
|
||||
__asan_install_malloc_hooks();
|
||||
once = true;
|
||||
static char *__asan_get_stack_base(void) {
|
||||
register uintptr_t rsp asm("rsp");
|
||||
return (char *)ROUNDDOWN(ROUNDDOWN(rsp, STACKSIZE), FRAMESIZE);
|
||||
}
|
||||
|
||||
static textstartup size_t __asan_get_auxv_size(intptr_t *auxv) {
|
||||
unsigned i;
|
||||
for (i = 0;; i += 2) {
|
||||
if (!auxv[i]) break;
|
||||
}
|
||||
return (i + 2) * sizeof(intptr_t);
|
||||
}
|
||||
|
||||
static textstartup void __asan_shadow_string_list(char **list) {
|
||||
for (; *list; ++list) {
|
||||
__asan_map_shadow(*list, strlen(*list) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
textstartup void __asan_init(int argc, char **argv, char **envp,
|
||||
intptr_t *auxv) {
|
||||
static bool once;
|
||||
if (once) return;
|
||||
__asan_map_shadow(_base, _end - _base);
|
||||
__asan_map_shadow(__asan_get_stack_base(), STACKSIZE);
|
||||
__asan_shadow_string_list(argv);
|
||||
__asan_shadow_string_list(envp);
|
||||
__asan_map_shadow(auxv, __asan_get_auxv_size(auxv));
|
||||
__asan_install_malloc_hooks();
|
||||
}
|
||||
|
||||
static textstartup void __asan_ctor(void) {
|
||||
/* __cxa_atexit(__asan_morgue_flush, NULL, NULL); */
|
||||
getsymboltable();
|
||||
__cxa_atexit(__asan_morgue_flush, NULL, NULL);
|
||||
}
|
||||
|
||||
const void *const g_asan_ctor[] initarray = {__asan_ctor};
|
||||
|
|
|
@ -29,10 +29,13 @@
|
|||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/symbols.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/fileno.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/w.h"
|
||||
|
||||
#define RESTORE_TTY "\e[?1000;1002;1015;1006l\e[?25h"
|
||||
|
||||
/**
|
||||
* Launches GDB debugger GUI for current process.
|
||||
*
|
||||
|
@ -50,17 +53,18 @@
|
|||
* @note this is called via eponymous spinlock macro wrapper
|
||||
*/
|
||||
relegated int(attachdebugger)(intptr_t continuetoaddr) {
|
||||
int ttyin, ttyout;
|
||||
int ttyfd;
|
||||
struct StackFrame *bp;
|
||||
char pidstr[11], breakcmd[40];
|
||||
const char *se, *elf, *gdb, *rewind, *layout;
|
||||
if (IsGenuineCosmo() || !(gdb = GetGdbPath()) ||
|
||||
(ttyin = ttyout = open(_PATH_TTY, O_RDWR, 0)) == -1) {
|
||||
(ttyfd = open(_PATH_TTY, O_RDWR, 0)) == -1) {
|
||||
return -1;
|
||||
}
|
||||
write(ttyfd, RESTORE_TTY, strlen(RESTORE_TTY));
|
||||
snprintf(pidstr, sizeof(pidstr), "%u", getpid());
|
||||
layout = "layout asm";
|
||||
if ((elf = finddebugbinary())) {
|
||||
if ((elf = FindDebugBinary())) {
|
||||
se = "-se";
|
||||
if (fileexists(__FILE__)) layout = "layout src";
|
||||
} else {
|
||||
|
@ -78,7 +82,7 @@ relegated int(attachdebugger)(intptr_t continuetoaddr) {
|
|||
rewind = NULL;
|
||||
breakcmd[0] = '\0';
|
||||
}
|
||||
return spawnve(0, (int[3]){ttyin, ttyout, STDERR_FILENO}, gdb,
|
||||
return spawnve(0, (int[3]){ttyfd, ttyfd, STDERR_FILENO}, gdb,
|
||||
(char *const[]){
|
||||
"gdb", "--tui",
|
||||
"-p", pidstr,
|
||||
|
|
|
@ -2,12 +2,11 @@
|
|||
#define COSMOPOLITAN_LIBC_LOG_BACKTRACE_H_
|
||||
#include "libc/nexgen32e/stackframe.h"
|
||||
#include "libc/runtime/symbols.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
void showbacktrace(FILE *, const struct StackFrame *);
|
||||
int PrintBacktraceUsingSymbols(FILE *, const struct StackFrame *,
|
||||
void ShowBacktrace(int, const struct StackFrame *);
|
||||
int PrintBacktraceUsingSymbols(int, const struct StackFrame *,
|
||||
struct SymbolTable *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
|
@ -31,14 +31,13 @@
|
|||
#include "libc/nexgen32e/gc.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/symbols.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/fileno.h"
|
||||
|
||||
#define kBacktraceMaxFrames 128
|
||||
#define kBacktraceBufSize ((kBacktraceMaxFrames - 1) * (16 + 1))
|
||||
|
||||
static int PrintBacktraceUsingAddr2line(FILE *f, const struct StackFrame *bp) {
|
||||
static int PrintBacktraceUsingAddr2line(int fd, const struct StackFrame *bp) {
|
||||
ssize_t got;
|
||||
intptr_t addr;
|
||||
size_t i, j, gi;
|
||||
|
@ -47,7 +46,7 @@ static int PrintBacktraceUsingAddr2line(FILE *f, const struct StackFrame *bp) {
|
|||
const struct StackFrame *frame;
|
||||
const char *debugbin, *p1, *p2, *p3, *addr2line;
|
||||
char buf[kBacktraceBufSize], *argv[kBacktraceMaxFrames];
|
||||
if (!(debugbin = finddebugbinary()) || !(addr2line = GetAddr2linePath())) {
|
||||
if (!(debugbin = FindDebugBinary()) || !(addr2line = GetAddr2linePath())) {
|
||||
return -1;
|
||||
}
|
||||
i = 0;
|
||||
|
@ -88,11 +87,11 @@ static int PrintBacktraceUsingAddr2line(FILE *f, const struct StackFrame *bp) {
|
|||
strlen(" (discriminator ") - 1)) &&
|
||||
(p3 = memchr(p2, '\n', got - (p2 - p1)))) {
|
||||
if (p3 > p2 && p3[-1] == '\r') --p3;
|
||||
fwrite(p1, 1, p2 - p1, f);
|
||||
write(fd, p1, p2 - p1);
|
||||
got -= p3 - p1;
|
||||
p1 += p3 - p1;
|
||||
} else {
|
||||
fwrite(p1, 1, got, f);
|
||||
write(fd, p1, got);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -103,20 +102,21 @@ static int PrintBacktraceUsingAddr2line(FILE *f, const struct StackFrame *bp) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int PrintBacktrace(FILE *f, const struct StackFrame *bp) {
|
||||
static int PrintBacktrace(int fd, const struct StackFrame *bp) {
|
||||
if (!IsTiny()) {
|
||||
if (PrintBacktraceUsingAddr2line(f, bp) != -1) {
|
||||
if (PrintBacktraceUsingAddr2line(fd, bp) != -1) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return PrintBacktraceUsingSymbols(f, bp, getsymboltable());
|
||||
return PrintBacktraceUsingSymbols(fd, bp, GetSymbolTable());
|
||||
}
|
||||
|
||||
void showbacktrace(FILE *f, const struct StackFrame *bp) {
|
||||
void ShowBacktrace(int fd, const struct StackFrame *bp) {
|
||||
static bool noreentry;
|
||||
if (!bp) bp = __builtin_frame_address(0);
|
||||
if (!noreentry) {
|
||||
noreentry = true;
|
||||
PrintBacktrace(f, bp);
|
||||
PrintBacktrace(fd, bp);
|
||||
noreentry = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "libc/alg/bisectcarleft.h"
|
||||
#include "libc/assert.h"
|
||||
#include "libc/bits/weaken.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/conv/itoa.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/log/backtrace.h"
|
||||
|
@ -28,26 +29,26 @@
|
|||
#include "libc/nexgen32e/stackframe.h"
|
||||
#include "libc/runtime/missioncritical.h"
|
||||
#include "libc/runtime/symbols.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
/**
|
||||
* Prints stack frames with symbols.
|
||||
*
|
||||
* PrintBacktraceUsingSymbols(stdout, NULL, getsymboltable());
|
||||
* PrintBacktraceUsingSymbols(STDOUT_FILENO, NULL, GetSymbolTable());
|
||||
*
|
||||
* @param f is output stream
|
||||
* @param bp is rbp which can be NULL to detect automatically
|
||||
* @param st is open symbol table for current executable
|
||||
* @return -1 w/ errno if error happened
|
||||
*/
|
||||
int PrintBacktraceUsingSymbols(FILE *f, const struct StackFrame *bp,
|
||||
int PrintBacktraceUsingSymbols(int fd, const struct StackFrame *bp,
|
||||
struct SymbolTable *st) {
|
||||
char *p;
|
||||
size_t gi;
|
||||
intptr_t addr;
|
||||
int64_t addend;
|
||||
struct Garbages *garbage;
|
||||
char *p, buf[256], ibuf[21];
|
||||
char buf[256], ibuf[21];
|
||||
const struct Symbol *symbol;
|
||||
const struct StackFrame *frame;
|
||||
if (!st) return -1;
|
||||
|
@ -78,8 +79,11 @@ int PrintBacktraceUsingSymbols(FILE *f, const struct StackFrame *bp,
|
|||
} else {
|
||||
p = stpcpy(p, "UNKNOWN");
|
||||
}
|
||||
*p++ = '\r';
|
||||
*p++ = '\n';
|
||||
__print(buf, p - buf);
|
||||
if (write(fd, buf, p - buf) == -1) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#define CHECK(X, ...) __CHK(eq, ==, true, "true", !!(X), #X, "" __VA_ARGS__)
|
||||
#define CHECK(X, ...) __CHK(ne, !=, false, "false", !!(X), #X, "" __VA_ARGS__)
|
||||
#define CHECK_EQ(Y, X, ...) __CHK(eq, ==, Y, #Y, X, #X, "" __VA_ARGS__)
|
||||
#define CHECK_NE(Y, X, ...) __CHK(ne, !=, Y, #Y, X, #X, "" __VA_ARGS__)
|
||||
#define CHECK_LE(Y, X, ...) __CHK(le, <=, Y, #Y, X, #X, "" __VA_ARGS__)
|
||||
|
@ -19,7 +19,7 @@ COSMOPOLITAN_C_START_
|
|||
#define CHECK_GT(Y, X, ...) __CHK(gt, >, Y, #Y, X, #X, "" __VA_ARGS__)
|
||||
#define CHECK_NOTNULL(X, ...) __CHK(ne, !=, NULL, "NULL", X, #X, "" __VA_ARGS__)
|
||||
|
||||
#define DCHECK(X, ...) __DCHK(eq, ==, true, "true", !!(X), #X, "" __VA_ARGS__)
|
||||
#define DCHECK(X, ...) __DCHK(ne, !=, false, "false", !!(X), #X, "" __VA_ARGS__)
|
||||
#define DCHECK_EQ(Y, X, ...) __DCHK(eq, ==, Y, #Y, X, #X, "" __VA_ARGS__)
|
||||
#define DCHECK_NE(Y, X, ...) __DCHK(ne, !=, Y, #Y, X, #X, "" __VA_ARGS__)
|
||||
#define DCHECK_LE(Y, X, ...) __DCHK(le, <=, Y, #Y, X, #X, "" __VA_ARGS__)
|
||||
|
|
|
@ -29,7 +29,7 @@ STATIC_YOINK("stoa");
|
|||
void __check_fail_aligned(unsigned bytes, uint64_t ptr) {
|
||||
fflush(stderr);
|
||||
if (!IsTiny()) memsummary(fileno(stderr));
|
||||
(dprintf)(fileno(stderr), "%s%d%s%#p\n", "error: pointer not ", bytes,
|
||||
(dprintf)(fileno(stderr), "%s%d%s%#p\r\n", "error: pointer not ", bytes,
|
||||
"-byte aligned: ", ptr);
|
||||
die();
|
||||
}
|
||||
|
|
|
@ -52,10 +52,10 @@ relegated void __check_fail(const char *suffix, const char *opstr,
|
|||
strtoupper(sufbuf);
|
||||
|
||||
(fprintf)(stderr,
|
||||
"check failed\n"
|
||||
"\tCHECK_%s(%s, %s);\n"
|
||||
"\t\t → %#lx (%s)\n"
|
||||
"\t\t%s %#lx (%s)\n",
|
||||
"check failed\r\n"
|
||||
"\tCHECK_%s(%s, %s);\r\n"
|
||||
"\t\t → %#lx (%s)\r\n"
|
||||
"\t\t%s %#lx (%s)\r\n",
|
||||
sufbuf, wantstr, gotstr, want, wantstr, opstr, got, gotstr);
|
||||
|
||||
if (!isempty(fmt)) {
|
||||
|
@ -63,18 +63,18 @@ relegated void __check_fail(const char *suffix, const char *opstr,
|
|||
va_start(va, fmt);
|
||||
(vfprintf)(stderr, fmt, va);
|
||||
va_end(va);
|
||||
fputc('\n', stderr);
|
||||
fputs("\r\n", stderr);
|
||||
}
|
||||
|
||||
(fprintf)(stderr, "\t%s\n\t%s%s%s%s\n", strerror(lasterr), SUBTLE,
|
||||
(fprintf)(stderr, "\t%s\r\n\t%s%s%s%s\r\n", strerror(lasterr), SUBTLE,
|
||||
getauxval(AT_EXECFN), g_argc > 1 ? " \\" : "", RESET);
|
||||
|
||||
for (i = 1; i < g_argc; ++i) {
|
||||
(fprintf)(stderr, "\t\t%s%s\n", g_argv[i], i < g_argc - 1 ? " \\" : "");
|
||||
(fprintf)(stderr, "\t\t%s%s\r\n", g_argv[i], i < g_argc - 1 ? " \\" : "");
|
||||
}
|
||||
|
||||
if (!IsTiny() && lasterr == ENOMEM) {
|
||||
(fprintf)(stderr, "\n");
|
||||
(fprintf)(stderr, "\r\n");
|
||||
fflush(stderr);
|
||||
PrintMemoryIntervals(fileno(stderr), &_mmi);
|
||||
}
|
||||
|
|
|
@ -47,5 +47,5 @@ relegated void ___check_fail_ndebug(uint64_t want, uint64_t got,
|
|||
__print(bx, uint64toarray_radix16(got, bx));
|
||||
__print_string(" (");
|
||||
__print(bx, int64toarray_radix10(lasterr, bx));
|
||||
__print_string(")\n");
|
||||
__print_string(")\r\n");
|
||||
}
|
||||
|
|
|
@ -18,10 +18,12 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/log/backtrace.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/sysv/consts/exit.h"
|
||||
#include "libc/sysv/consts/fileno.h"
|
||||
|
||||
/**
|
||||
* Aborts process after printing details on its current state.
|
||||
|
@ -33,7 +35,7 @@ relegated noreturn void die(void) {
|
|||
if (!IsTiny()) {
|
||||
g_runstate |= RUNSTATE_BROKEN;
|
||||
if (IsDebuggerPresent(false)) DebugBreak();
|
||||
backtrace(stderr);
|
||||
ShowBacktrace(STDERR_FILENO, NULL);
|
||||
}
|
||||
exit(EXIT_FAILURE);
|
||||
unreachable;
|
||||
|
|
|
@ -38,7 +38,7 @@ int(gdbexec)(const char *cmd) {
|
|||
char pidstr[11], breakcmd[40];
|
||||
if (!(gdb = GetGdbPath())) return -1;
|
||||
snprintf(pidstr, sizeof(pidstr), "%u", getpid());
|
||||
if ((elf = finddebugbinary())) {
|
||||
if ((elf = FindDebugBinary())) {
|
||||
se = "-se";
|
||||
} else {
|
||||
se = "-q";
|
||||
|
|
|
@ -24,15 +24,15 @@
|
|||
* Returns debug binary symbol table, as global singleton.
|
||||
* @return symbol table, or NULL w/ errno on first call
|
||||
*/
|
||||
struct SymbolTable *getsymboltable(void) {
|
||||
struct SymbolTable *GetSymbolTable(void) {
|
||||
static bool once;
|
||||
static struct SymbolTable *singleton;
|
||||
const char *debugbin;
|
||||
if (!once) {
|
||||
once = true;
|
||||
if ((debugbin = finddebugbinary()) &&
|
||||
(singleton = opensymboltable(debugbin))) {
|
||||
__cxa_atexit(closesymboltable, &singleton, NULL);
|
||||
if ((debugbin = FindDebugBinary()) &&
|
||||
(singleton = OpenSymbolTable(debugbin))) {
|
||||
__cxa_atexit(CloseSymbolTable, &singleton, NULL);
|
||||
}
|
||||
}
|
||||
return singleton;
|
||||
|
|
|
@ -33,7 +33,6 @@ typedef struct FILE FILE;
|
|||
|
||||
extern FILE *g_logfile;
|
||||
|
||||
void backtrace(FILE *) relegated; /* shows fn backtrace and args */
|
||||
void perror(const char *) relegated; /* print the last system error */
|
||||
void die(void) relegated noreturn; /* print backtrace and abort() */
|
||||
void meminfo(int); /* shows malloc statistics &c. */
|
||||
|
|
|
@ -25,7 +25,7 @@ STATIC_YOINK("ntoa");
|
|||
|
||||
void malloc_stats(void) {
|
||||
struct MallocStats res = dlmalloc_stats(g_dlmalloc);
|
||||
(fprintf)(stderr, "max system bytes = %'10zu\n", res.maxfp);
|
||||
(fprintf)(stderr, "system bytes = %'10zu\n", res.fp);
|
||||
(fprintf)(stderr, "in use bytes = %'10zu\n", res.used);
|
||||
(fprintf)(stderr, "max system bytes = %'10zu\r\n", res.maxfp);
|
||||
(fprintf)(stderr, "system bytes = %'10zu\r\n", res.fp);
|
||||
(fprintf)(stderr, "in use bytes = %'10zu\r\n", res.used);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ STATIC_YOINK("ntoa");
|
|||
STATIC_YOINK("stoa");
|
||||
|
||||
static void onmemchunk(void *start, void *end, size_t used_bytes, void *arg) {
|
||||
(dprintf)(*(int *)arg, "%p - %p : %08zx / %08lx\n", start, end, used_bytes,
|
||||
(dprintf)(*(int *)arg, "%p - %p : %08zx / %08lx\r\n", start, end, used_bytes,
|
||||
(intptr_t)end - (intptr_t)start);
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ static void onmemchunk(void *start, void *end, size_t used_bytes, void *arg) {
|
|||
*/
|
||||
void meminfo(int fd) {
|
||||
memsummary(fd);
|
||||
(dprintf)(fd, "%*s %*s %*s %*s\n", POINTER_XDIGITS, "start",
|
||||
(dprintf)(fd, "%*s %*s %*s %*s\r\n", POINTER_XDIGITS, "start",
|
||||
POINTER_XDIGITS, "end", 8, "used", 8, "size");
|
||||
malloc_inspect_all(onmemchunk, &fd);
|
||||
}
|
||||
|
|
|
@ -32,9 +32,9 @@
|
|||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/memtrack.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/auxv.h"
|
||||
#include "libc/sysv/consts/fileno.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
|
||||
|
@ -49,17 +49,17 @@ STATIC_YOINK("stoa");
|
|||
|
||||
struct siginfo;
|
||||
|
||||
aligned(1) const char kGregOrder[17] = {
|
||||
const char kGregOrder[17] aligned(1) = {
|
||||
13, 11, 8, 14, 12, 9, 10, 15, 16, 0, 1, 2, 3, 4, 5, 6, 7,
|
||||
};
|
||||
|
||||
aligned(1) const char kGregNames[17][4] = {
|
||||
const char kGregNames[17][4] aligned(1) = {
|
||||
"R8", "R9", "R10", "R11", "R12", "R13", "R14", "R15", "RDI",
|
||||
"RSI", "RBP", "RBX", "RDX", "RAX", "RCX", "RSP", "RIP",
|
||||
};
|
||||
|
||||
aligned(1) const char kGodHatesFlags[12] = "CVPRAKZSTIDO";
|
||||
aligned(1) const char kCrashSigNames[8][5] = {"QUIT", "FPE", "ILL", "SEGV",
|
||||
const char kGodHatesFlags[12] aligned(1) = "CVPRAKZSTIDO";
|
||||
const char kCrashSigNames[8][5] aligned(1) = {"QUIT", "FPE", "ILL", "SEGV",
|
||||
"TRAP", "ABRT", "BUS"};
|
||||
|
||||
int kCrashSigs[8];
|
||||
|
@ -75,60 +75,60 @@ relegated static const char *TinyStrSignal(int sig) {
|
|||
return "???";
|
||||
}
|
||||
|
||||
relegated static void ShowFunctionCalls(FILE *f, ucontext_t *ctx) {
|
||||
relegated static void ShowFunctionCalls(int fd, ucontext_t *ctx) {
|
||||
struct StackFrame *bp;
|
||||
struct StackFrame goodframe;
|
||||
fputc('\n', f);
|
||||
write(fd, "\r\n", 2);
|
||||
if (ctx && ctx->uc_mcontext.rip && ctx->uc_mcontext.rbp) {
|
||||
goodframe.next = (struct StackFrame *)ctx->uc_mcontext.rbp;
|
||||
goodframe.addr = ctx->uc_mcontext.rip;
|
||||
bp = &goodframe;
|
||||
showbacktrace(f, bp);
|
||||
ShowBacktrace(fd, bp);
|
||||
}
|
||||
}
|
||||
|
||||
relegated static void DescribeCpuFlags(FILE *f, unsigned efl) {
|
||||
size_t i;
|
||||
relegated static void DescribeCpuFlags(int fd, unsigned flags) {
|
||||
unsigned i;
|
||||
char buf[64], *p;
|
||||
p = buf;
|
||||
for (i = 0; i < ARRAYLEN(kGodHatesFlags); ++i) {
|
||||
if (efl & 1) {
|
||||
fputc(' ', f);
|
||||
fputc(kGodHatesFlags[i], f);
|
||||
fputc('F', f);
|
||||
if (flags & 1) {
|
||||
*p++ = ' ';
|
||||
*p++ = kGodHatesFlags[i];
|
||||
*p++ = 'F';
|
||||
}
|
||||
efl >>= 1;
|
||||
flags >>= 1;
|
||||
}
|
||||
(fprintf)(f, " %s%d\n", "IOPL", efl & 3);
|
||||
p = stpcpy(p, " IOPL");
|
||||
*p++ = '0' + (flags & 3);
|
||||
write(fd, buf, p - buf);
|
||||
}
|
||||
|
||||
relegated static void ShowGeneralRegisters(FILE *f, ucontext_t *ctx) {
|
||||
relegated static void ShowGeneralRegisters(int fd, ucontext_t *ctx) {
|
||||
size_t i, j, k;
|
||||
long double st;
|
||||
fputc('\n', f);
|
||||
write(fd, "\r\n", 2);
|
||||
for (i = 0, j = 0, k = 0; i < ARRAYLEN(kGregNames); ++i) {
|
||||
if (j > 0) {
|
||||
fputc(' ', f);
|
||||
}
|
||||
(fprintf)(f, "%-3s %016lx", kGregNames[(unsigned)kGregOrder[i]],
|
||||
if (j > 0) write(fd, " ", 1);
|
||||
(dprintf)(fd, "%-3s %016lx", kGregNames[(unsigned)kGregOrder[i]],
|
||||
ctx->uc_mcontext.gregs[(unsigned)kGregOrder[i]]);
|
||||
if (++j == 3) {
|
||||
j = 0;
|
||||
memcpy(&st, (char *)&ctx->fpustate.st[k], sizeof(st));
|
||||
(fprintf)(f, " %s(%zu) %Lf", "ST", k, st);
|
||||
(dprintf)(fd, " %s(%zu) %Lf", "ST", k, st);
|
||||
++k;
|
||||
fputc('\r', f);
|
||||
fputc('\n', f);
|
||||
write(fd, "\r\n", 2);
|
||||
}
|
||||
}
|
||||
fflush(stderr);
|
||||
DescribeCpuFlags(f, ctx->uc_mcontext.gregs[REG_EFL]);
|
||||
DescribeCpuFlags(fd, ctx->uc_mcontext.gregs[REG_EFL]);
|
||||
}
|
||||
|
||||
relegated static void ShowSseRegisters(FILE *f, ucontext_t *ctx) {
|
||||
relegated static void ShowSseRegisters(int fd, ucontext_t *ctx) {
|
||||
size_t i;
|
||||
fputc('\n', f);
|
||||
write(fd, "\r\n", 2);
|
||||
for (i = 0; i < 8; ++i) {
|
||||
(fprintf)(f, VEIL("r", "%s%-2zu %016lx%016lx %s%-2d %016lx%016lx\n"), "XMM",
|
||||
i + 0, ctx->fpustate.xmm[i + 0].u64[0],
|
||||
(dprintf)(fd, VEIL("r", "%s%-2zu %016lx%016lx %s%-2d %016lx%016lx\r\n"),
|
||||
"XMM", i + 0, ctx->fpustate.xmm[i + 0].u64[0],
|
||||
ctx->fpustate.xmm[i + 0].u64[1], "XMM", i + 8,
|
||||
ctx->fpustate.xmm[i + 8].u64[0], ctx->fpustate.xmm[i + 8].u64[1]);
|
||||
}
|
||||
|
@ -149,23 +149,23 @@ relegated static void ShowMemoryMappings(int outfd) {
|
|||
}
|
||||
}
|
||||
|
||||
relegated static void ShowCrashReport(int err, FILE *f, int sig,
|
||||
relegated static void ShowCrashReport(int err, int fd, int sig,
|
||||
ucontext_t *ctx) {
|
||||
struct utsname names;
|
||||
(fprintf)(f, VEIL("r", "\n%serror%s: Uncaught SIG%s\n %s\n %s\n"), RED2,
|
||||
RESET, TinyStrSignal(sig), getauxval(AT_EXECFN), strerror(err));
|
||||
(dprintf)(fd, VEIL("r", "\r\n%serror%s: Uncaught SIG%s\r\n %s\r\n %s\r\n"),
|
||||
RED2, RESET, TinyStrSignal(sig), getauxval(AT_EXECFN),
|
||||
strerror(err));
|
||||
if (uname(&names) != -1) {
|
||||
(fprintf)(f, VEIL("r", " %s %s %s %s\n"), names.sysname, names.nodename,
|
||||
(dprintf)(fd, VEIL("r", " %s %s %s %s\r\n"), names.sysname, names.nodename,
|
||||
names.release, names.version);
|
||||
}
|
||||
ShowFunctionCalls(f, ctx);
|
||||
ShowFunctionCalls(fd, ctx);
|
||||
if (ctx) {
|
||||
ShowGeneralRegisters(f, ctx);
|
||||
ShowSseRegisters(f, ctx);
|
||||
ShowGeneralRegisters(fd, ctx);
|
||||
ShowSseRegisters(fd, ctx);
|
||||
}
|
||||
fputc('\n', f);
|
||||
fflush(f);
|
||||
ShowMemoryMappings(fileno(f));
|
||||
write(fd, "\r\n", 2);
|
||||
ShowMemoryMappings(fd);
|
||||
}
|
||||
|
||||
relegated static void RestoreDefaultCrashSignalHandlers(void) {
|
||||
|
@ -215,7 +215,7 @@ relegated void oncrash(int sig, struct siginfo *si, ucontext_t *ctx) {
|
|||
: 0);
|
||||
}
|
||||
if (gdbpid > 0 && (sig == SIGTRAP || sig == SIGQUIT)) return;
|
||||
ShowCrashReport(err, stderr, sig, ctx);
|
||||
quick_exit(128 + sig);
|
||||
ShowCrashReport(err, STDERR_FILENO, sig, ctx);
|
||||
exit(128 + sig);
|
||||
unreachable;
|
||||
}
|
||||
|
|
|
@ -17,12 +17,14 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/log/internal.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
||||
void perror(const char *message) {
|
||||
fprintf(stderr, "%s%s%s: %s: %m: %s\n", RED2, "error", RESET,
|
||||
program_invocation_name, message);
|
||||
fprintf(stderr, "%s%s%s: %s: %s: %s\r\n", RED2, "error", RESET,
|
||||
program_invocation_name, strerror(errno), message);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ void __ubsan_abort(const struct UbsanSourceLocation *loc,
|
|||
g_runstate |= RUNSTATE_BROKEN;
|
||||
if (IsDebuggerPresent(false)) DebugBreak();
|
||||
startfatal(loc->file, loc->line);
|
||||
fprintf(stderr, "%s\n", description);
|
||||
fprintf(stderr, "%s\r\n", description);
|
||||
die();
|
||||
unreachable;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ void __ubsan_handle_type_mismatch(struct UbsanTypeMismatchInfo *type_mismatch,
|
|||
type_mismatch->alignment);
|
||||
} else {
|
||||
description = __ubsan_buf;
|
||||
snprintf(__ubsan_buf, sizeof(__ubsan_buf), "%s\n\t%s %s %p %s %s",
|
||||
snprintf(__ubsan_buf, sizeof(__ubsan_buf), "%s\r\n\t%s %s %p %s %s",
|
||||
"insufficient size", kind, "address", pointer,
|
||||
"with insufficient space for object of type",
|
||||
type_mismatch->type->name);
|
||||
|
|
|
@ -72,7 +72,7 @@ void vflogf_onfail(FILE *f) {
|
|||
fseek(f, SEEK_SET, 0);
|
||||
f->beg = f->end = 0;
|
||||
clearerr(f);
|
||||
(fprintf)(f, "performed emergency log truncation: %s\n", strerror(err));
|
||||
(fprintf)(f, "performed emergency log truncation: %s\r\n", strerror(err));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,10 +111,10 @@ void(vflogf)(unsigned level, const char *file, int line, FILE *f,
|
|||
}
|
||||
(vfprintf)(f, fmt, va);
|
||||
va_end(va);
|
||||
fputc('\n', f);
|
||||
fputs("\r\n", f);
|
||||
if (level == kLogFatal) {
|
||||
startfatal(file, line);
|
||||
(fprintf)(stderr, "fatal error see logfile\n");
|
||||
(fprintf)(stderr, "fatal error see logfile\r\n");
|
||||
die();
|
||||
unreachable;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#define ROUNDUP(X, K) (((X) + ((K)-1)) & ~((K)-1))
|
||||
#define ROUNDUP(X, K) (((X) + (K)-1) & -(K))
|
||||
#define ROUNDDOWN(X, K) ((X) & -(K))
|
||||
#define ABS(X) ((X) >= 0 ? (X) : -(X))
|
||||
#define MIN(X, Y) ((Y) > (X) ? (X) : (Y))
|
||||
|
|
|
@ -29,4 +29,3 @@
|
|||
bcopy: jmp memmove
|
||||
.endfn bcopy,globl
|
||||
.source __FILE__
|
||||
.source __FILE__
|
||||
|
|
|
@ -25,8 +25,10 @@
|
|||
/ This turns stuff like (char)0xFF into \0377. The returned
|
||||
/ string is word-encoded, e.g. '\\'|'0'<<010|'3'<<020|etc.
|
||||
/
|
||||
/ @param dil contains byte to escape
|
||||
/ @see libc/nexgen32e/cescapec.c
|
||||
cescapec:
|
||||
movzbl %dil,%edi
|
||||
lea -7(%rdi),%ecx
|
||||
cmp $85,%cl
|
||||
ja 1f
|
||||
|
@ -63,12 +65,11 @@ cescapec:
|
|||
ret
|
||||
.LQM:
|
||||
#endif
|
||||
1: movzbl %dil,%eax
|
||||
cmp $127,%eax
|
||||
1: mov %edi,%eax
|
||||
lea -0x20(%rax),%ecx
|
||||
cmp $0x5E,%ecx
|
||||
ja 2f
|
||||
ezlea kCtype,cx
|
||||
testb $16,(%rcx,%rax)
|
||||
jne 3f
|
||||
ret
|
||||
2: and $-64,%eax
|
||||
mov %edi,%ecx
|
||||
and $56,%ecx
|
||||
|
@ -78,7 +79,7 @@ cescapec:
|
|||
or %ecx,%edi
|
||||
lea (%rdi,%rax,4),%eax
|
||||
add $'0<<030|'0<<020|'0<<010|'\\,%eax
|
||||
3: ret
|
||||
ret
|
||||
.endfn cescapec,globl
|
||||
|
||||
.initro 300,_init_cescapec
|
||||
|
|
|
@ -1,101 +0,0 @@
|
|||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Returns nonzero if %dil ∈ [ \t\v\r\n].
|
||||
/
|
||||
/ @param edi is character to test (treated as uint8_t)
|
||||
/ @return nonzero if character matches, otherwise 0
|
||||
isspace:push $1
|
||||
jmp ctypep
|
||||
.endfn isspace,globl
|
||||
|
||||
/ Returns nonzero if %dil ∈ [A-Za-z].
|
||||
/
|
||||
/ @param edi is character to test (treated as uint8_t)
|
||||
/ @return nonzero if character matches, otherwise 0
|
||||
isalpha:push $2
|
||||
jmp ctypep
|
||||
.endfn isalpha,globl
|
||||
|
||||
/ Returns nonzero if %dil ∈ [0-9].
|
||||
/
|
||||
/ @param edi is character to test (treated as uint8_t)
|
||||
/ @return nonzero if character matches, otherwise 0
|
||||
isdigit:push $4
|
||||
jmp ctypep
|
||||
.endfn isdigit,globl
|
||||
|
||||
/ Returns nonzero if %dil ∈ [0-9A-Za-z].
|
||||
/
|
||||
/ @param edi is character to test (treated as uint8_t)
|
||||
/ @return nonzero if character matches, otherwise 0
|
||||
isalnum:push $6
|
||||
jmp ctypep
|
||||
.endfn isalnum,globl
|
||||
|
||||
/ Returns nonzero if %dil ∈ [0-9A-fa-f].
|
||||
/
|
||||
/ @param edi is character to test (treated as uint8_t)
|
||||
/ @return nonzero if character matches, otherwise 0
|
||||
isxdigit:push $8
|
||||
jmp ctypep
|
||||
.endfn isxdigit,globl
|
||||
|
||||
/ Returns nonzero if %dil ∈ [ -~] a.k.a. [\x20-\x7e].
|
||||
/
|
||||
/ @param edi is character to test (treated as uint8_t)
|
||||
/ @return nonzero if character matches, otherwise 0
|
||||
isprint:push $16
|
||||
jmp ctypep
|
||||
.endfn isprint,globl
|
||||
|
||||
/ Returns nonzero if %dil ∈ [a-z]
|
||||
/
|
||||
/ @param edi is character to test (treated as uint8_t)
|
||||
/ @return nonzero if character matches, otherwise 0
|
||||
islower:push $32
|
||||
jmp ctypep
|
||||
.endfn islower,globl
|
||||
|
||||
/ Returns nonzero if %dil ∈ [A-Z]
|
||||
/
|
||||
/ @param edi is character to test (treated as uint8_t)
|
||||
/ @return nonzero if character matches, otherwise 0
|
||||
isupper:push $64
|
||||
jmp ctypep
|
||||
.endfn isupper,globl
|
||||
|
||||
/ Returns nonzero if %dil ∈ [ \t]
|
||||
/
|
||||
/ @param edi is character to test (treated as uint8_t)
|
||||
/ @return nonzero if character matches, otherwise 0
|
||||
isblank:push $-128
|
||||
/ fallthrough
|
||||
.endfn isblank,globl
|
||||
|
||||
ctypep: pop %rsi
|
||||
movzbl %dil,%edi
|
||||
ezlea kCtype,cx
|
||||
movzbl (%rcx,%rdi),%eax
|
||||
and %esi,%eax
|
||||
ret
|
||||
.endfn ctypep
|
||||
.source __FILE__
|
|
@ -1,33 +0,0 @@
|
|||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
hextoint:
|
||||
.leafprologue
|
||||
.profilable
|
||||
mov %edi,%eax
|
||||
sar $6,%eax
|
||||
and $1,%eax
|
||||
lea (%rax,%rax,8),%eax
|
||||
add %edi,%eax
|
||||
and $15,%eax
|
||||
.leafepilogue
|
||||
.endfn hextoint,globl
|
||||
.source __FILE__
|
|
@ -1,35 +0,0 @@
|
|||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iscntrl:.leafprologue
|
||||
.profilable
|
||||
xor %eax,%eax
|
||||
cmp $255,%edi
|
||||
ja 1f
|
||||
movslq %edi,%rdi
|
||||
ezlea kCtype,cx
|
||||
mov (%rcx,%rdi),%al
|
||||
shr $4,%al
|
||||
xor $1,%eax
|
||||
and $1,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iscntrl,globl
|
||||
.source __FILE__
|
|
@ -1,38 +0,0 @@
|
|||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
isgraph:.leafprologue
|
||||
.profilable
|
||||
xor %eax,%eax
|
||||
cmp $255,%edi
|
||||
ja 1f
|
||||
movslq %edi,%rax
|
||||
ezlea kCtype,cx
|
||||
mov (%rcx,%rax),%al
|
||||
shr $4,%al
|
||||
mov %eax,%edx
|
||||
xor %eax,%eax
|
||||
cmp $32,%edi
|
||||
setne %al
|
||||
and %edx,%eax
|
||||
1: .leafepilogue
|
||||
.endfn isgraph,globl
|
||||
.source __FILE__
|
|
@ -1,33 +0,0 @@
|
|||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswalnum:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movslq %edi,%rax
|
||||
cmpl $127,%eax
|
||||
ja 1f
|
||||
ezlea kCtype,cx
|
||||
movb (%rcx,%rax),%al
|
||||
andl $6,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswalnum,globl
|
||||
.source __FILE__
|
|
@ -1,34 +0,0 @@
|
|||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswalpha:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movslq %edi,%rax
|
||||
cmpl $127,%eax
|
||||
ja 1f
|
||||
ezlea kCtype,cx
|
||||
movb (%rcx,%rax),%al
|
||||
andl $2,%eax
|
||||
movzbl %al,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswalpha,globl
|
||||
.source __FILE__
|
|
@ -1,34 +0,0 @@
|
|||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswblank:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movslq %edi,%rax
|
||||
cmpl $127,%eax
|
||||
ja 1f
|
||||
ezlea kCtype,cx
|
||||
movb (%rcx,%rax),%al
|
||||
andl $-128,%eax
|
||||
movzbl %al,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswblank,globl
|
||||
.source __FILE__
|
|
@ -1,35 +0,0 @@
|
|||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswcntrl:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movslq %edi,%rax
|
||||
cmp $127,%eax
|
||||
ja 1f
|
||||
ezlea kCtype,cx
|
||||
mov (%rcx,%rax),%al
|
||||
shr $4,%al
|
||||
xor $1,%eax
|
||||
and $1,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswcntrl,globl
|
||||
.source __FILE__
|
|
@ -1,34 +0,0 @@
|
|||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswdigit:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movl %edi,%eax
|
||||
cmpl $127,%edi
|
||||
ja 1f
|
||||
subl $48,%eax
|
||||
cmpl $9,%eax
|
||||
setbe %al
|
||||
movzbl %al,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswdigit,globl
|
||||
.source __FILE__
|
|
@ -1,38 +0,0 @@
|
|||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswgraph:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movl %edi,%eax
|
||||
cmpl $127,%edi
|
||||
ja 1f
|
||||
movslq %edi,%rdx
|
||||
ezlea kCtype,cx
|
||||
movb (%rcx,%rdx),%dl
|
||||
shrb $4,%dl
|
||||
cmpl $32,%edi
|
||||
setne %al
|
||||
movzbl %al,%eax
|
||||
andl %edx,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswgraph,globl
|
||||
.source __FILE__
|
|
@ -1,34 +0,0 @@
|
|||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswlower:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movslq %edi,%rax
|
||||
cmpl $127,%eax
|
||||
ja 1f
|
||||
ezlea kCtype,cx
|
||||
movb (%rcx,%rax),%al
|
||||
andl $32,%eax
|
||||
movzbl %al,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswlower,globl
|
||||
.source __FILE__
|
|
@ -1,35 +0,0 @@
|
|||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswprint:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movl $1,%eax
|
||||
cmpl $127,%edi
|
||||
ja 1f
|
||||
movslq %edi,%rdi
|
||||
ezlea kCtype,cx
|
||||
movb (%rcx,%rdi),%al
|
||||
shrb $4,%al
|
||||
andl $1,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswprint,globl
|
||||
.source __FILE__
|
|
@ -1,39 +0,0 @@
|
|||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswpunct:
|
||||
.leafprologue
|
||||
.profilable
|
||||
mov $1,%eax
|
||||
cmp $127,%edi
|
||||
ja 1f
|
||||
movslq %edi,%rdi
|
||||
ezlea kCtype,cx
|
||||
mov (%rcx,%rdi),%dl
|
||||
xor %eax,%eax
|
||||
test $16,%dl
|
||||
je 1f
|
||||
xor %eax,%eax
|
||||
and $7,%dl
|
||||
sete %al
|
||||
1: .leafepilogue
|
||||
.endfn iswpunct,globl
|
||||
.source __FILE__
|
|
@ -1,33 +0,0 @@
|
|||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswspace:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movslq %edi,%rax
|
||||
cmpl $127,%eax
|
||||
ja 1f
|
||||
ezlea kCtype,cx
|
||||
movb (%rcx,%rax),%al
|
||||
andl $1,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswspace,globl
|
||||
.source __FILE__
|
|
@ -1,34 +0,0 @@
|
|||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswupper:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movslq %edi,%rax
|
||||
cmpl $127,%eax
|
||||
ja 1f
|
||||
ezlea kCtype,cx
|
||||
movb (%rcx,%rax),%al
|
||||
andl $64,%eax
|
||||
movzbl %al,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswupper,globl
|
||||
.source __FILE__
|
|
@ -1,34 +0,0 @@
|
|||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
iswxdigit:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movslq %edi,%rax
|
||||
cmpl $127,%eax
|
||||
ja 1f
|
||||
ezlea kCtype,cx
|
||||
movb (%rcx,%rax),%al
|
||||
andl $8,%eax
|
||||
movzbl %al,%eax
|
||||
1: .leafepilogue
|
||||
.endfn iswxdigit,globl
|
||||
.source __FILE__
|
|
@ -1,63 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
#include "libc/notice.inc"
|
||||
|
||||
.initbss 300,_init_kCtype
|
||||
kCtype: .rept 256
|
||||
.byte 0
|
||||
.endr
|
||||
.endobj kCtype,globl,hidden
|
||||
.previous
|
||||
|
||||
.initro 300,_init_kCtype
|
||||
.LkCtype.rodata:
|
||||
/ ┌─isblank
|
||||
/ │┌─isupper
|
||||
/ ││┌─islower
|
||||
/ │││┌─isprint
|
||||
/ ││││┌─isxdigit
|
||||
/ │││││┌─isdigit
|
||||
/ ││││││┌─isalpha
|
||||
/ │││││││┌─isspace
|
||||
/ ││││││││
|
||||
.byte 9, 0b00000000 # 00─08 ∅─◘
|
||||
.byte 1, 0b10000001 # 09─09 ○
|
||||
.byte 4, 0b00000001 # 0a─0d ◙─♪
|
||||
.byte 18, 0b00000000 # 0e─1f ♫─▼
|
||||
.byte 1, 0b10010001 # 20─20
|
||||
.byte 15, 0b00010000 # 21─2f !─/
|
||||
.byte 10, 0b00011100 # 30─39 0─9
|
||||
.byte 7, 0b00010000 # 3a─40 :─@
|
||||
.byte 6, 0b01011010 # 41─46 A─F
|
||||
.byte 20, 0b01010010 # 47─5a G─Z
|
||||
.byte 6, 0b00010000 # 5b─60 [─`
|
||||
.byte 6, 0b00111010 # 61─66 a─f
|
||||
.byte 20, 0b00110010 # 67─7a g─z
|
||||
.byte 4, 0b00010000 # 7b─7e {─~
|
||||
.byte 129, 0b00000000 # 7f─ff ⌂─λ
|
||||
.endobj .LkCtype.rodata # 32b ─ 13%
|
||||
.byte 0,0 # terminatr
|
||||
.previous
|
||||
|
||||
.init.start 300,_init_kCtype
|
||||
call rldecode
|
||||
.init.end 300,_init_kCtype
|
||||
.source __FILE__
|
|
@ -1,35 +0,0 @@
|
|||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
toupper:.leafprologue
|
||||
.profilable
|
||||
xor %eax,%eax
|
||||
cmp $255,%edi
|
||||
ja 1f
|
||||
movslq %edi,%rax
|
||||
ezlea kCtype,cx
|
||||
mov (%rcx,%rax),%al
|
||||
and $32,%eax
|
||||
movzbl %al,%eax
|
||||
andn %edi,%eax,%eax # TODO(jart): FIX
|
||||
1: .leafepilogue
|
||||
.endfn toupper,globl
|
||||
.source __FILE__
|
|
@ -1,36 +0,0 @@
|
|||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
towupper:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movl %edi,%eax
|
||||
cmpl $127,%edi
|
||||
ja 1f
|
||||
movslq %edi,%rdx
|
||||
ezlea kCtype,cx
|
||||
movb (%rcx,%rdx),%dl
|
||||
andl $32,%edx
|
||||
movzbl %dl,%edx
|
||||
andn %edi,%edx,%eax
|
||||
1: .leafepilogue
|
||||
.endfn towupper,globl
|
||||
.source __FILE__
|
|
@ -1,2 +1,15 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp KernelBase,__imp_CancelIo,CancelIo,101
|
||||
|
||||
.text.windows
|
||||
CancelIo:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov %rdi,%rcx
|
||||
sub $32,%rsp
|
||||
call *__imp_CancelIo(%rip)
|
||||
leave
|
||||
ret
|
||||
.endfn CancelIo,globl
|
||||
.previous
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp KernelBase,__imp_CancelIoEx,CancelIoEx,102
|
||||
|
||||
.text.windows
|
||||
CancelIoEx:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_CancelIoEx(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
.endfn CancelIoEx,globl
|
||||
.previous
|
||||
|
|
|
@ -1,2 +1,15 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp KernelBase,__imp_CancelSynchronousIo,CancelSynchronousIo,103
|
||||
|
||||
.text.windows
|
||||
CancelSynchronousIo:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov %rdi,%rcx
|
||||
sub $32,%rsp
|
||||
call *__imp_CancelSynchronousIo(%rip)
|
||||
leave
|
||||
ret
|
||||
.endfn CancelSynchronousIo,globl
|
||||
.previous
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp KernelBase,__imp_CreateIoCompletionPort,CreateIoCompletionPort,195
|
||||
|
||||
.text.windows
|
||||
CreateIoCompletionPort:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_CreateIoCompletionPort(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
.endfn CreateIoCompletionPort,globl
|
||||
.previous
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp KernelBase,__imp_CreateThread,CreateThread,224
|
||||
|
||||
.text.windows
|
||||
CreateThread:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_CreateThread(%rip),%rax
|
||||
jmp __sysv2nt6
|
||||
.endfn CreateThread,globl
|
||||
.previous
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp KernelBase,__imp_CreateWaitableTimerW,CreateWaitableTimerW,234
|
||||
|
||||
.text.windows
|
||||
CreateWaitableTimer:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_CreateWaitableTimerW(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
.endfn CreateWaitableTimer,globl
|
||||
.previous
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp KernelBase,__imp_GetQueuedCompletionStatus,GetQueuedCompletionStatus,695
|
||||
|
||||
.text.windows
|
||||
GetQueuedCompletionStatus:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_GetQueuedCompletionStatus(%rip),%rax
|
||||
jmp __sysv2nt6
|
||||
.endfn GetQueuedCompletionStatus,globl
|
||||
.previous
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp KernelBase,__imp_GetQueuedCompletionStatusEx,GetQueuedCompletionStatusEx,696
|
||||
|
||||
.text.windows
|
||||
GetQueuedCompletionStatusEx:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_GetQueuedCompletionStatusEx(%rip),%rax
|
||||
jmp __sysv2nt6
|
||||
.endfn GetQueuedCompletionStatusEx,globl
|
||||
.previous
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp KernelBase,__imp_PostQueuedCompletionStatus,PostQueuedCompletionStatus,1221
|
||||
|
||||
.text.windows
|
||||
PostQueuedCompletionStatus:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_PostQueuedCompletionStatus(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
.endfn PostQueuedCompletionStatus,globl
|
||||
.previous
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp KernelBase,__imp_ReadFileEx,ReadFileEx,1312
|
||||
|
||||
.text.windows
|
||||
ReadFileEx:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_ReadFileEx(%rip),%rax
|
||||
jmp __sysv2nt6
|
||||
.endfn ReadFileEx,globl
|
||||
.previous
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp KernelBase,__imp_SetWaitableTimer,SetWaitableTimer,1583
|
||||
|
||||
.text.windows
|
||||
SetWaitableTimer:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_SetWaitableTimer(%rip),%rax
|
||||
jmp __sysv2nt6
|
||||
.endfn SetWaitableTimer,globl
|
||||
.previous
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp KernelBase,__imp_WriteFileEx,WriteFileEx,1824
|
||||
|
||||
.text.windows
|
||||
WriteFileEx:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_WriteFileEx(%rip),%rax
|
||||
jmp __sysv2nt6
|
||||
.endfn WriteFileEx,globl
|
||||
.previous
|
||||
|
|
|
@ -121,10 +121,10 @@ bool32 CreateDirectory(const char16_t *lpPathName,
|
|||
struct NtSecurityAttributes *lpSecurityAttributes);
|
||||
bool32 RemoveDirectory(const char16_t *lpPathName);
|
||||
|
||||
int32_t DuplicateHandle(int64_t hSourceProcessHandle, int64_t hSourceHandle,
|
||||
int64_t hTargetProcessHandle, int64_t *lpTargetHandle,
|
||||
uint32_t dwDesiredAccess, bool32 bInheritHandle,
|
||||
uint32_t dwOptions);
|
||||
bool32 DuplicateHandle(int64_t hSourceProcessHandle, int64_t hSourceHandle,
|
||||
int64_t hTargetProcessHandle, int64_t *lpTargetHandle,
|
||||
uint32_t dwDesiredAccess, bool32 bInheritHandle,
|
||||
uint32_t dwOptions);
|
||||
|
||||
bool32 GetHandleInformation(int64_t hObject, uint32_t *out_lpdwFlags);
|
||||
bool32 SetHandleInformation(int64_t hObject, uint32_t dwMask, uint32_t dwFlags);
|
||||
|
@ -244,6 +244,7 @@ bool32 ReadFileScatter(
|
|||
uint32_t nNumberOfBytesToReadThatsMultipleOfFileVolumeSectorSize,
|
||||
uint32_t *lpReserved, struct NtOverlapped *inout_lpOverlapped)
|
||||
paramsnonnull();
|
||||
|
||||
bool32 WriteFileGather(int64_t hFileOpenedWithOverlappedAndNoBuffering,
|
||||
const union NtFileSegmentElement aSegmentArray[],
|
||||
uint32_t nNumberOfBytesToWrite, uint32_t *lpReserved,
|
||||
|
|
79
libc/nt/iocp.h
Normal file
79
libc/nt/iocp.h
Normal file
|
@ -0,0 +1,79 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_NT_IOCP_H_
|
||||
#define COSMOPOLITAN_LIBC_NT_IOCP_H_
|
||||
#if 0
|
||||
/* ░░░░
|
||||
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
|
||||
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
|
||||
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
|
||||
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
|
||||
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
|
||||
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
|
||||
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
|
||||
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
|
||||
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
|
||||
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
|
||||
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
|
||||
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
|
||||
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
|
||||
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
|
||||
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
|
||||
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
|
||||
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
|
||||
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
|
||||
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
|
||||
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
|
||||
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
|
||||
│ cosmopolitan § new technology » i/o completion ports ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
#endif
|
||||
#include "libc/nt/struct/overlapped.h"
|
||||
#include "libc/nt/struct/overlappedentry.h"
|
||||
|
||||
#define kNtFileSkipCompletionPortOnSuccess 1
|
||||
#define kNtFileSkipSetEventOnHandle 2
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
typedef void (*NtOverlappedCompletionRoutine)(
|
||||
uint32_t dwErrorCode, uint32_t dwNumberOfBytesTransfered,
|
||||
struct NtOverlapped *inout_lpOverlapped);
|
||||
|
||||
int64_t CreateIoCompletionPort(int64_t FileHandleOrNeg1,
|
||||
int64_t opt_ExistingCompletionPortOrZero,
|
||||
void *StatePointer,
|
||||
uint32_t NumberOfConcurrentThreads);
|
||||
|
||||
bool32 GetQueuedCompletionStatus(int64_t CompletionPort,
|
||||
uint32_t *lpNumberOfBytesTransferred,
|
||||
void *StatePointerPointer,
|
||||
struct NtOverlapped **lpOverlapped,
|
||||
uint32_t dwMilliseconds);
|
||||
|
||||
bool32 GetQueuedCompletionStatusEx(
|
||||
int64_t CompletionPort,
|
||||
struct NtOverlappedEntry *out_lpCompletionPortEntries, uint32_t ulCount,
|
||||
uint32_t *out_ulNumEntriesRemoved, uint32_t dwMilliseconds,
|
||||
bool32 fAlertable);
|
||||
|
||||
bool32 PostQueuedCompletionStatus(int64_t CompletionPort,
|
||||
uint32_t dwNumberOfBytesTransferred,
|
||||
uint32_t *dwCompletionKey,
|
||||
struct NtOverlapped *opt_lpOverlapped);
|
||||
|
||||
bool32 SetFileCompletionNotificationModes(int64_t FileHandle,
|
||||
unsigned char Flags);
|
||||
|
||||
bool32 ReadFileEx(int64_t hFile, void *lpBuffer, uint32_t nNumberOfBytesToRead,
|
||||
uint32_t *lpNumberOfBytesRead,
|
||||
struct NtOverlapped *opt_lpOverlapped,
|
||||
NtOverlappedCompletionRoutine lpCompletionRoutine);
|
||||
|
||||
bool32 WriteFileEx(int64_t hFile, const void *lpBuffer,
|
||||
uint32_t nNumberOfBytesToWrite,
|
||||
struct NtOverlapped *lpOverlapped,
|
||||
NtOverlappedCompletionRoutine lpCompletionRoutine);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_NT_IOCP_H_ */
|
|
@ -28,17 +28,17 @@
|
|||
#endif
|
||||
|
||||
/* CreateNamedPipe:dwOpenMode */
|
||||
#define kNtPipeAccessInbound 0x00000001
|
||||
#define kNtPipeAccessInbound 0x00000001
|
||||
#define kNtPipeAccessOutbound 0x00000002
|
||||
#define kNtPipeAccessDuplex 0x00000003
|
||||
#define kNtPipeAccessDuplex 0x00000003
|
||||
|
||||
/* CreateNamedPipe::dwPipeMode */
|
||||
#define kNtPipeWait 0x00000000
|
||||
#define kNtPipeNowait 0x00000001
|
||||
#define kNtPipeReadmodeByte 0x00000000
|
||||
#define kNtPipeReadmodeMessage 0x00000002
|
||||
#define kNtPipeTypeByte 0x00000000
|
||||
#define kNtPipeTypeMessage 0x00000004
|
||||
#define kNtPipeWait 0x00000000
|
||||
#define kNtPipeNowait 0x00000001
|
||||
#define kNtPipeReadmodeByte 0x00000000
|
||||
#define kNtPipeReadmodeMessage 0x00000002
|
||||
#define kNtPipeTypeByte 0x00000000
|
||||
#define kNtPipeTypeMessage 0x00000004
|
||||
#define kNtPipeAcceptRemoteClients 0x00000000
|
||||
#define kNtPipeRejectRemoteClients 0x00000008
|
||||
|
||||
|
@ -55,28 +55,34 @@ COSMOPOLITAN_C_START_
|
|||
struct NtOverlapped;
|
||||
struct NtSecurityAttributes;
|
||||
|
||||
int CreatePipe(int64_t *out_hReadPipe, int64_t *out_hWritePipe,
|
||||
const struct NtSecurityAttributes *opt_lpPipeAttributes,
|
||||
uint32_t nSize) paramsnonnull((1, 2));
|
||||
void *CreateNamedPipe(
|
||||
bool32 CreatePipe(int64_t *out_hReadPipe, int64_t *out_hWritePipe,
|
||||
const struct NtSecurityAttributes *opt_lpPipeAttributes,
|
||||
uint32_t nSize) paramsnonnull((1, 2));
|
||||
|
||||
int64_t CreateNamedPipe(
|
||||
const char16_t *lpName, uint32_t dwOpenMode, uint32_t dwPipeMode,
|
||||
uint32_t nMaxInstances, uint32_t nOutBufferSize, uint32_t nInBufferSize,
|
||||
uint32_t nDefaultTimeOut,
|
||||
const struct NtSecurityAttributes *opt_lpSecurityAttributes)
|
||||
paramsnonnull((1));
|
||||
bool32 ConnectNamedPipe(int64_t *hNamedPipe, struct NtOverlapped *lpOverlapped);
|
||||
|
||||
bool32 CallNamedPipe(const char16_t *lpNamedPipeName, void *lpInBuffer,
|
||||
uint32_t nInBufferSize, void *lpOutBuffer,
|
||||
uint32_t nOutBufferSize, uint32_t *lpBytesRead,
|
||||
uint32_t nTimeOut);
|
||||
|
||||
bool32 ConnectNamedPipe(int64_t *hNamedPipe, struct NtOverlapped *lpOverlapped);
|
||||
bool32 WaitNamedPipe(const char16_t *lpNamedPipeName, uint32_t nTimeOut);
|
||||
bool32 DisconnectNamedPipe(int64_t *hNamedPipe);
|
||||
|
||||
bool32 SetNamedPipeHandleState(int64_t *hNamedPipe, uint32_t *lpMode,
|
||||
uint32_t *lpMaxCollectionCount,
|
||||
uint32_t *lpCollectDataTimeout);
|
||||
|
||||
bool32 PeekNamedPipe(int64_t *hNamedPipe, void *lpBuffer, uint32_t nBufferSize,
|
||||
uint32_t *lpBytesRead, uint32_t *lpTotalBytesAvail,
|
||||
uint32_t *lpBytesLeftThisMessage);
|
||||
|
||||
bool32 TransactNamedPipe(int64_t *hNamedPipe, void *lpInBuffer,
|
||||
uint32_t nInBufferSize, void *lpOutBuffer,
|
||||
uint32_t nOutBufferSize, uint32_t *lpBytesRead,
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp kernel32,__imp_SetFileCompletionNotificationModes,SetFileCompletionNotificationModes,1318
|
||||
|
||||
.text.windows
|
||||
SetFileCompletionNotificationModes:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_SetFileCompletionNotificationModes(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
.endfn SetFileCompletionNotificationModes,globl
|
||||
.previous
|
||||
|
|
|
@ -341,11 +341,11 @@ imp 'CallWindowProc' CallWindowProcW user32 1537
|
|||
imp 'CallbackMayRunLong' CallbackMayRunLong KernelBase 100
|
||||
imp 'CancelDC' CancelDC gdi32 1038
|
||||
imp 'CancelDeviceWakeupRequest' CancelDeviceWakeupRequest kernel32 113
|
||||
imp 'CancelIo' CancelIo KernelBase 101
|
||||
imp 'CancelIoEx' CancelIoEx KernelBase 102
|
||||
imp 'CancelIo' CancelIo KernelBase 101 1
|
||||
imp 'CancelIoEx' CancelIoEx KernelBase 102 2
|
||||
imp 'CancelOverlappedAccess' CancelOverlappedAccess advapi32 1091
|
||||
imp 'CancelShutdown' CancelShutdown user32 1538
|
||||
imp 'CancelSynchronousIo' CancelSynchronousIo KernelBase 103
|
||||
imp 'CancelSynchronousIo' CancelSynchronousIo KernelBase 103 1
|
||||
imp 'CancelTimerQueueTimer' CancelTimerQueueTimer kernel32 118
|
||||
imp 'CancelWaitableTimer' CancelWaitableTimer KernelBase 105
|
||||
imp 'CascadeChildWindows' CascadeChildWindows user32 1539
|
||||
|
@ -625,7 +625,7 @@ imp 'CreateIcon' CreateIcon user32 1615
|
|||
imp 'CreateIconFromResource' CreateIconFromResource user32 1616
|
||||
imp 'CreateIconFromResourceEx' CreateIconFromResourceEx user32 1617
|
||||
imp 'CreateIconIndirect' CreateIconIndirect user32 1618
|
||||
imp 'CreateIoCompletionPort' CreateIoCompletionPort KernelBase 195
|
||||
imp 'CreateIoCompletionPort' CreateIoCompletionPort KernelBase 195 4
|
||||
imp 'CreateJobObjectA' CreateJobObjectA kernel32 209
|
||||
imp 'CreateJobObject' CreateJobObjectW kernel32 210
|
||||
imp 'CreateJobSet' CreateJobSet kernel32 211
|
||||
|
@ -702,7 +702,7 @@ imp 'CreateSymbolicLinkTransactedA' CreateSymbolicLinkTransactedA kernel32
|
|||
imp 'CreateSymbolicLinkTransacted' CreateSymbolicLinkTransactedW kernel32 238
|
||||
imp 'CreateSystemThreads' CreateSystemThreads user32 1623
|
||||
imp 'CreateTapePartition' CreateTapePartition kernel32 240
|
||||
imp 'CreateThread' CreateThread KernelBase 224
|
||||
imp 'CreateThread' CreateThread KernelBase 224 6
|
||||
imp 'CreateThreadpool' CreateThreadpool KernelBase 225
|
||||
imp 'CreateThreadpoolCleanupGroup' CreateThreadpoolCleanupGroup KernelBase 226
|
||||
imp 'CreateThreadpoolIo' CreateThreadpoolIo KernelBase 227
|
||||
|
@ -717,7 +717,7 @@ imp 'CreateUmsThreadContext' CreateUmsThreadContext kernel32 252
|
|||
imp 'CreateWaitableTimerA' CreateWaitableTimerA kernel32 253
|
||||
imp 'CreateWaitableTimerExA' CreateWaitableTimerExA kernel32 254
|
||||
imp 'CreateWaitableTimerEx' CreateWaitableTimerExW KernelBase 233
|
||||
imp 'CreateWaitableTimer' CreateWaitableTimerW KernelBase 234
|
||||
imp 'CreateWaitableTimer' CreateWaitableTimerW KernelBase 234 3
|
||||
imp 'CreateWellKnownSid' CreateWellKnownSid KernelBase 235
|
||||
imp 'CreateWindowEx' CreateWindowExW user32 1625 12
|
||||
imp 'CreateWindowExA' CreateWindowExA user32 1624 12
|
||||
|
@ -2516,8 +2516,8 @@ imp 'GetPtrCalDataArray' GetPtrCalDataArray KernelBase 692
|
|||
imp 'GetPublisherCacheFolder' GetPublisherCacheFolder KernelBase 693
|
||||
imp 'GetPublisherRootFolder' GetPublisherRootFolder KernelBase 694
|
||||
imp 'GetQueueStatus' GetQueueStatus user32 1936
|
||||
imp 'GetQueuedCompletionStatus' GetQueuedCompletionStatus KernelBase 695
|
||||
imp 'GetQueuedCompletionStatusEx' GetQueuedCompletionStatusEx KernelBase 696
|
||||
imp 'GetQueuedCompletionStatus' GetQueuedCompletionStatus KernelBase 695 5
|
||||
imp 'GetQueuedCompletionStatusEx' GetQueuedCompletionStatusEx KernelBase 696 6
|
||||
imp 'GetROP2' GetROP2 gdi32 1695
|
||||
imp 'GetRandomRgn' GetRandomRgn gdi32 1696
|
||||
imp 'GetRasterizerCaps' GetRasterizerCaps gdi32 1697
|
||||
|
@ -4320,7 +4320,7 @@ imp 'PolylineTo' PolylineTo gdi32 1791
|
|||
imp 'PoolPerAppKeyStateInternal' PoolPerAppKeyStateInternal KernelBase 1220
|
||||
imp 'PostMessageA' PostMessageA user32 2204
|
||||
imp 'PostMessage' PostMessageW user32 2205
|
||||
imp 'PostQueuedCompletionStatus' PostQueuedCompletionStatus KernelBase 1221
|
||||
imp 'PostQueuedCompletionStatus' PostQueuedCompletionStatus KernelBase 1221 4
|
||||
imp 'PostQuitMessage' PostQuitMessage user32 2206 1
|
||||
imp 'PostThreadMessageA' PostThreadMessageA user32 2207
|
||||
imp 'PostThreadMessage' PostThreadMessageW user32 2208
|
||||
|
@ -4517,7 +4517,7 @@ imp 'ReadEncryptedFileRaw' ReadEncryptedFileRaw advapi32 1601
|
|||
imp 'ReadEventLogA' ReadEventLogA advapi32 1602
|
||||
imp 'ReadEventLog' ReadEventLogW advapi32 1603
|
||||
imp 'ReadFile' ReadFile KernelBase 1311 5
|
||||
imp 'ReadFileEx' ReadFileEx KernelBase 1312
|
||||
imp 'ReadFileEx' ReadFileEx KernelBase 1312 5
|
||||
imp 'ReadFileScatter' ReadFileScatter KernelBase 1313 5
|
||||
imp 'ReadProcessMemory' ReadProcessMemory KernelBase 1314
|
||||
imp 'ReadStateAtomValue' ReadStateAtomValue KernelBase 1315
|
||||
|
@ -6225,7 +6225,7 @@ imp 'SetFileAttributesA' SetFileAttributesA KernelBase 1507 2
|
|||
imp 'SetFileAttributesTransactedA' SetFileAttributesTransactedA kernel32 1314
|
||||
imp 'SetFileAttributesTransacted' SetFileAttributesTransactedW kernel32 1315
|
||||
imp 'SetFileBandwidthReservation' SetFileBandwidthReservation kernel32 1317
|
||||
imp 'SetFileCompletionNotificationModes' SetFileCompletionNotificationModes kernel32 1318
|
||||
imp 'SetFileCompletionNotificationModes' SetFileCompletionNotificationModes kernel32 1318 2
|
||||
imp 'SetFileInformationByHandle' SetFileInformationByHandle KernelBase 1509
|
||||
imp 'SetFileIoOverlappedRange' SetFileIoOverlappedRange KernelBase 1510
|
||||
imp 'SetFilePointer' SetFilePointer KernelBase 1511 4
|
||||
|
@ -6425,7 +6425,7 @@ imp 'SetVolumeLabel' SetVolumeLabelW kernel32 1401
|
|||
imp 'SetVolumeMountPointA' SetVolumeMountPointA kernel32 1402
|
||||
imp 'SetVolumeMountPoint' SetVolumeMountPointW kernel32 1403
|
||||
imp 'SetVolumeMountPointWStub' SetVolumeMountPointWStub kernel32 1404
|
||||
imp 'SetWaitableTimer' SetWaitableTimer KernelBase 1583
|
||||
imp 'SetWaitableTimer' SetWaitableTimer KernelBase 1583 6
|
||||
imp 'SetWaitableTimerEx' SetWaitableTimerEx KernelBase 1584
|
||||
imp 'SetWinEventHook' SetWinEventHook user32 2388
|
||||
imp 'SetWinMetaFileBits' SetWinMetaFileBits gdi32 1917
|
||||
|
@ -7188,7 +7188,7 @@ imp 'WriteConsoleOutputCharacter' WriteConsoleOutputCharacterW KernelBase
|
|||
imp 'WriteConsoleOutputCharacterA' WriteConsoleOutputCharacterA KernelBase 1819 5
|
||||
imp 'WriteEncryptedFileRaw' WriteEncryptedFileRaw advapi32 1857
|
||||
imp 'WriteFile' WriteFile KernelBase 1823 5
|
||||
imp 'WriteFileEx' WriteFileEx KernelBase 1824
|
||||
imp 'WriteFileEx' WriteFileEx KernelBase 1824 5
|
||||
imp 'WriteFileGather' WriteFileGather KernelBase 1825 5
|
||||
imp 'WritePrivateProfileSectionA' WritePrivateProfileSectionA kernel32 1565
|
||||
imp 'WritePrivateProfileSection' WritePrivateProfileSectionW kernel32 1566
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue