Skip to content

Commit

Permalink
Fix Windows MODE=tiny breakage
Browse files Browse the repository at this point in the history
  • Loading branch information
jart committed Jan 5, 2025
1 parent f0b0f92 commit 7b67b20
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions libc/intrin/fds.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,11 @@
#include "libc/thread/thread.h"
#include "libc/thread/tls.h"

#define OPEN_MAX 16

#ifdef __x86_64__
__static_yoink("_init_fds");
#endif

struct Fds g_fds;
static struct Fd g_fds_static[OPEN_MAX];

static bool TokAtoi(const char **str, long *res) {
int c, d;
Expand Down Expand Up @@ -92,15 +89,9 @@ textstartup void __init_fds(int argc, char **argv, char **envp) {
fds = &g_fds;
fds->n = 4;
atomic_store_explicit(&fds->f, 3, memory_order_relaxed);
if (_weaken(_extend)) {
fds->p = fds->e = (void *)kMemtrackFdsStart;
fds->e =
_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;
}
fds->p = fds->e = (void *)kMemtrackFdsStart;
fds->e = _extend(fds->p, fds->n * sizeof(*fds->p), fds->e, MAP_PRIVATE,
kMemtrackFdsStart + kMemtrackFdsSize);

// inherit standard i/o file descriptors
if (IsMetal()) {
Expand Down Expand Up @@ -154,8 +145,7 @@ textstartup void __init_fds(int argc, char **argv, char **envp) {
break;
if (!TokAtoi(&fdspec, &protocol))
break;
if (_weaken(__ensurefds_unlocked))
_weaken(__ensurefds_unlocked)(fd);
__ensurefds_unlocked(fd);
struct Fd *f = fds->p + fd;
if (f->handle && f->handle != -1 && f->handle != handle) {
CloseHandle(f->handle);
Expand Down

0 comments on commit 7b67b20

Please sign in to comment.