Fix Windows MODE=tiny breakage

This commit is contained in:
Justine Tunney 2025-01-05 12:04:39 -08:00
parent f0b0f926bf
commit 7b67b20dae
No known key found for this signature in database
GPG key ID: BE714B4575D6E328

View file

@ -46,14 +46,11 @@
#include "libc/thread/thread.h" #include "libc/thread/thread.h"
#include "libc/thread/tls.h" #include "libc/thread/tls.h"
#define OPEN_MAX 16
#ifdef __x86_64__ #ifdef __x86_64__
__static_yoink("_init_fds"); __static_yoink("_init_fds");
#endif #endif
struct Fds g_fds; struct Fds g_fds;
static struct Fd g_fds_static[OPEN_MAX];
static bool TokAtoi(const char **str, long *res) { static bool TokAtoi(const char **str, long *res) {
int c, d; int c, d;
@ -92,15 +89,9 @@ textstartup void __init_fds(int argc, char **argv, char **envp) {
fds = &g_fds; fds = &g_fds;
fds->n = 4; fds->n = 4;
atomic_store_explicit(&fds->f, 3, memory_order_relaxed); atomic_store_explicit(&fds->f, 3, memory_order_relaxed);
if (_weaken(_extend)) { fds->p = fds->e = (void *)kMemtrackFdsStart;
fds->p = fds->e = (void *)kMemtrackFdsStart; fds->e = _extend(fds->p, fds->n * sizeof(*fds->p), fds->e, MAP_PRIVATE,
fds->e = kMemtrackFdsStart + kMemtrackFdsSize);
_weaken(_extend)(fds->p, fds->n * sizeof(*fds->p), fds->e, MAP_PRIVATE,
kMemtrackFdsStart + kMemtrackFdsSize);
} else {
fds->p = g_fds_static;
fds->e = g_fds_static + OPEN_MAX;
}
// inherit standard i/o file descriptors // inherit standard i/o file descriptors
if (IsMetal()) { if (IsMetal()) {
@ -154,8 +145,7 @@ textstartup void __init_fds(int argc, char **argv, char **envp) {
break; break;
if (!TokAtoi(&fdspec, &protocol)) if (!TokAtoi(&fdspec, &protocol))
break; break;
if (_weaken(__ensurefds_unlocked)) __ensurefds_unlocked(fd);
_weaken(__ensurefds_unlocked)(fd);
struct Fd *f = fds->p + fd; struct Fd *f = fds->p + fd;
if (f->handle && f->handle != -1 && f->handle != handle) { if (f->handle && f->handle != -1 && f->handle != handle) {
CloseHandle(f->handle); CloseHandle(f->handle);