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

@ -18,6 +18,7 @@
*/
#include "libc/bits/bits.h"
#include "libc/dce.h"
#include "libc/intrin/kprintf.h"
#include "libc/log/backtrace.internal.h"
#include "libc/log/internal.h"
#include "libc/log/libfatal.internal.h"
@ -33,7 +34,8 @@
relegated wontreturn void __die(void) {
/* asan runtime depends on this function */
static bool once;
if (cmpxchg(&once, false, true)) {
kprintf("__die() called%n");
if (lockcmpxchg(&once, false, true)) {
__restore_tty(1);
if (IsDebuggerPresent(false)) {
DebugBreak();
@ -42,7 +44,7 @@ relegated wontreturn void __die(void) {
__restorewintty();
_Exit(77);
}
__write_str("PANIC: __DIE() DIED\r\n");
kprintf("panic: __die() died%n");
__restorewintty();
_Exit(78);
}

View file

@ -17,6 +17,7 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/bits/bits.h"
#include "libc/calls/strace.internal.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/kprintf.h"
#include "libc/runtime/internal.h"
@ -71,11 +72,12 @@ static noasan bool HasLeaks(void) {
*/
noasan void CheckForMemoryLeaks(void) {
struct mallinfo mi;
if (!cmpxchg(&once, false, true)) {
if (!lockcmpxchg(&once, false, true)) {
kprintf("CheckForMemoryLeaks() may only be called once\n");
exit(1);
}
__cxa_finalize(0);
STRACE("checking for memory leaks");
if (!IsAsan()) {
/* TODO(jart): How can we make this work without ASAN? */
return;

View file

@ -50,8 +50,11 @@ const void *const g_oldtermios_ctor[] initarray = {
};
void __restore_tty(int fd) {
int e;
e = errno;
if (g_oldtermios.c_lflag && !__nocolor && isatty(fd)) {
write(fd, ANSI_RESTORE, strlen(ANSI_RESTORE));
tcsetattr(fd, TCSAFLUSH, &g_oldtermios);
}
errno = e;
}