feat(dist): Win32 POSIX shim for el_runtime.c cross-compilation

This commit is contained in:
2026-06-29 12:38:27 -05:00
parent 70b60f78de
commit 76bd3afdf8
Generated Vendored
+35
View File
@@ -0,0 +1,35 @@
/*
* win32_shim.h Extra POSIXWin32 stubs for cross-compiling el_runtime.c with mingw-w64.
* Injected via -include; supplements el_platform_win.h for symbols it doesn't yet cover.
*/
#ifdef _WIN32
#include <windows.h>
/* ── rusage / getrusage ────────────────────────────────────────────────────── */
/* el_runtime.c uses getrusage(RUSAGE_SELF) only for a soft memory guard.
* On Windows, stub it out: always return 0 ru_maxrss so the guard never fires. */
#ifndef RUSAGE_SELF
#define RUSAGE_SELF 0
struct rusage {
long ru_maxrss; /* the only field el_runtime actually reads */
};
static inline int getrusage(int who, struct rusage *r) {
(void)who;
if (r) r->ru_maxrss = 0;
return 0;
}
#endif /* RUSAGE_SELF */
/* ── fsync ─────────────────────────────────────────────────────────────────── */
/* Windows has FlushFileBuffers but no fsync; map it. */
#ifndef fsync
#include <io.h>
static inline int el_win_fsync(int fd) {
HANDLE h = (HANDLE)_get_osfhandle(fd);
if (h == INVALID_HANDLE_VALUE) return -1;
return FlushFileBuffers(h) ? 0 : -1;
}
#define fsync(fd) el_win_fsync(fd)
#endif /* fsync */
#endif /* _WIN32 */