Improve system call support on NT

- Improve i/o perf on New Technology
- Code cleanup on read() for New Technology
- Fix bad bug with dup() of socket on New Technology
- Clean up some more strace errors on New Technology
This commit is contained in:
Justine Tunney 2022-04-07 20:30:04 -07:00
parent 29bf8b1a30
commit 4f98ad1054
79 changed files with 707 additions and 197 deletions

View file

@ -55,8 +55,10 @@ void testlib_runallbenchmarks(void) {
int e;
e = errno;
_peekall();
mlockall(MCL_CURRENT);
nice(-1);
if (!IsWindows()) {
mlockall(MCL_CURRENT);
nice(-1);
}
errno = e;
__log_level = kLogWarn;
testlib_runtestcases(__bench_start, __bench_end, testlib_benchwarmup);

View file

@ -44,9 +44,9 @@ static noasan relegated uint64_t CountMappedBytes(void) {
static relegated void DieBecauseOfQuota(int rc, const char *message) {
int e = errno;
char hostname[32];
__stpcpy(hostname, "unknown");
stpcpy(hostname, "unknown");
gethostname(hostname, sizeof(hostname));
kprintf("%s on %s pid %d\n", message, hostname, (long)__getpid());
kprintf("%s on %s pid %d\n", message, hostname, (long)getpid());
PrintBacktraceUsingSymbols(2, 0, GetSymbolTable());
exit(rc);
}

View file

@ -37,8 +37,8 @@ testonly void testlib_showerror(const char *file, int line, const char *func,
const char *code, char *v1, char *v2) {
char *p;
char hostname[128];
__getpid(); /* make strace easier to read */
__getpid();
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"
@ -62,8 +62,8 @@ testonly void testlib_showerror_(int line, const char *wantcode,
va_list va;
char hostname[128];
e = errno;
__getpid();
__getpid();
if (!IsWindows()) __getpid();
if (!IsWindows()) __getpid();
__stpcpy(hostname, "unknown");
gethostname(hostname, sizeof(hostname));
kprintf("%serror%s:%s%s:%d%s: %s(%s) on %s\n"

View file

@ -23,6 +23,7 @@
#include "libc/calls/struct/sigaction.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/kprintf.h"
#include "libc/log/libfatal.internal.h"
#include "libc/log/log.h"
#include "libc/mem/mem.h"
@ -89,7 +90,7 @@ noasan int main(int argc, char *argv[]) {
GetOpts(argc, argv);
ShowCrashReports();
g_testlib_shoulddebugbreak = IsDebuggerPresent(false);
sys_getpid(); /* make strace easier to read */
if (!IsWindows()) sys_getpid(); /* make strace easier to read */
testlib_clearxmmregisters();
testlib_runalltests();
if (!g_testlib_failed && runbenchmarks_ && weaken(testlib_runallbenchmarks)) {

View file

@ -19,16 +19,19 @@
#include "libc/bits/weaken.h"
#include "libc/calls/calls.h"
#include "libc/calls/internal.h"
#include "libc/calls/strace.internal.h"
#include "libc/calls/struct/sigaction.h"
#include "libc/errno.h"
#include "libc/fmt/fmt.h"
#include "libc/fmt/itoa.h"
#include "libc/intrin/kprintf.h"
#include "libc/log/check.h"
#include "libc/log/libfatal.internal.h"
#include "libc/macros.internal.h"
#include "libc/nt/process.h"
#include "libc/runtime/runtime.h"
#include "libc/runtime/symbols.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/sig.h"
#include "libc/testlib/testlib.h"
#include "libc/x/x.h"
@ -52,10 +55,10 @@ wontreturn void testlib_abort(void) {
static void SetupTmpDir(void) {
char *p = g_testlib_tmpdir;
p = __stpcpy(p, "o/tmp/");
p = __stpcpy(p, program_invocation_short_name), *p++ = '.';
p = __intcpy(p, __getpid()), *p++ = '.';
p = __intcpy(p, x++);
p = stpcpy(p, "o/tmp/");
p = stpcpy(p, program_invocation_short_name), *p++ = '.';
p = FormatInt64(p, getpid()), *p++ = '.';
p = FormatInt64(p, x++);
p[0] = '\0';
CHECK_NE(-1, makedirs(g_testlib_tmpdir, 0755), "%s", g_testlib_tmpdir);
CHECK_EQ(1, isdirectory(g_testlib_tmpdir), "%s", g_testlib_tmpdir);
@ -66,7 +69,8 @@ static void SetupTmpDir(void) {
static void TearDownTmpDir(void) {
CHECK_NE(-1, chdir(g_testlib_olddir));
CHECK_NE(-1, rmrf(g_testlib_tmpdir));
CHECK_NE(-1, rmrf(g_testlib_tmpdir), "ugh %s", g_testlib_tmpdir);
CHECK_EQ(0, isdirectory(g_testlib_tmpdir), "%s", g_testlib_tmpdir);
}
/**
@ -98,11 +102,11 @@ testonly void testlib_runtestcases(testfn_t *start, testfn_t *end,
if (weaken(SetUp)) weaken(SetUp)();
errno = 0;
SetLastError(0);
sys_getpid();
if (!IsWindows()) sys_getpid();
if (warmup) warmup();
testlib_clearxmmregisters();
(*fn)();
sys_getpid();
if (!IsWindows()) sys_getpid();
if (weaken(TearDown)) weaken(TearDown)();
if (weaken(testlib_enable_tmp_setup_teardown)) TearDownTmpDir();
}