mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 08:18:30 +00:00
Make improvements
- Document redbean's argon2 module - Fix regressions in cthreads library - Make testlib work better with threads - Give the cthreads library lots of love - Remove some of the stdio assembly code - Implement getloadavg() across platforms - Code size optimizations for errnos, etc. - Only check for signals in main thread on Windows - Make errnos for dup2 / dup3 consistent with posix This change also fixes a bug in the argon2 module, where the NUL terminator was being included in the hash encoded ascii string. This shouldn't require any database migrations to folks who found this module and productionized it, since the argon2 library treats it as a c string.
This commit is contained in:
parent
cb67223051
commit
de5de19004
234 changed files with 1728 additions and 1993 deletions
|
@ -20,6 +20,7 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/spinlock.h"
|
||||
#include "libc/log/color.internal.h"
|
||||
#include "libc/log/internal.h"
|
||||
#include "libc/log/libfatal.internal.h"
|
||||
|
@ -31,27 +32,30 @@ const char *testlib_showerror_func;
|
|||
const char *testlib_showerror_isfatal;
|
||||
const char *testlib_showerror_macro;
|
||||
const char *testlib_showerror_symbol;
|
||||
_Alignas(64) static int testlib_showerror_lock;
|
||||
|
||||
testonly void testlib_showerror(const char *file, int line, const char *func,
|
||||
const char *method, const char *symbol,
|
||||
const char *code, char *v1, char *v2) {
|
||||
char *p;
|
||||
char hostname[128];
|
||||
_spinlock(&testlib_showerror_lock);
|
||||
if (!IsWindows()) __getpid(); /* make strace easier to read */
|
||||
if (!IsWindows()) __getpid();
|
||||
__stpcpy(hostname, "unknown");
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
kprintf("%serror%s%s:%s:%d%s: %s() in %s(%s) on %s\n"
|
||||
kprintf("%serror%s%s:%s:%d%s: %s() in %s(%s) on %s pid %d tid %d\n"
|
||||
"\t%s\n"
|
||||
"\t\tneed %s %s\n"
|
||||
"\t\t got %s\n"
|
||||
"\t%s%s\n"
|
||||
"\t%s%s\n",
|
||||
RED2, UNBOLD, BLUE1, file, (long)line, RESET, method, func,
|
||||
g_fixturename, hostname, code, v1, symbol, v2, SUBTLE,
|
||||
strerror(errno), GetProgramExecutableName(), RESET);
|
||||
g_fixturename, hostname, getpid(), gettid(), code, v1, symbol, v2,
|
||||
SUBTLE, strerror(errno), GetProgramExecutableName(), RESET);
|
||||
free_s(&v1);
|
||||
free_s(&v2);
|
||||
_spunlock(&testlib_showerror_lock);
|
||||
}
|
||||
|
||||
/* TODO(jart): Pay off tech debt re duplication */
|
||||
|
@ -61,16 +65,17 @@ testonly void testlib_showerror_(int line, const char *wantcode,
|
|||
int e;
|
||||
va_list va;
|
||||
char hostname[128];
|
||||
_spinlock(&testlib_showerror_lock);
|
||||
e = errno;
|
||||
if (!IsWindows()) __getpid();
|
||||
if (!IsWindows()) __getpid();
|
||||
if (gethostname(hostname, sizeof(hostname))) {
|
||||
__stpcpy(hostname, "unknown");
|
||||
}
|
||||
kprintf("%serror%s:%s%s:%d%s: %s(%s) on %s\n"
|
||||
kprintf("%serror%s:%s%s:%d%s: %s(%s) on %s pid %d tid %d\n"
|
||||
"\t%s(%s, %s)\n",
|
||||
RED2, UNBOLD, BLUE1, testlib_showerror_file, line, RESET,
|
||||
testlib_showerror_func, g_fixturename, hostname,
|
||||
testlib_showerror_func, g_fixturename, hostname, getpid(), gettid(),
|
||||
testlib_showerror_macro, wantcode, gotcode);
|
||||
if (wantcode) {
|
||||
kprintf("\t\tneed %s %s\n"
|
||||
|
@ -94,4 +99,5 @@ testonly void testlib_showerror_(int line, const char *wantcode,
|
|||
free_s(&FREED_got);
|
||||
++g_testlib_failed;
|
||||
if (testlib_showerror_isfatal) testlib_abort();
|
||||
_spunlock(&testlib_showerror_lock);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue