From 5e2be61a2c49ba9b10f6710853a85a545e1ea448 Mon Sep 17 00:00:00 2001 From: woolcoxm <13604288+woolcoxm@users.noreply.github.com> Date: Fri, 17 Jul 2026 08:27:51 -0400 Subject: [PATCH] fix(test): make test_stops build on Windows (mkdtemp compat shim) test_stops.c uses POSIX mkdtemp() to make a scratch dir in the CWD, but MinGW-w64 does not declare mkdtemp, so the test failed to compile on the Windows job - and only there: tests/test_stops.c:73:9: error: implicit declaration of function 'mkdtemp'; did you mean 'mktemp'? [-Wimplicit-function-declaration] make: *** [Makefile:318: tests/test_stops.exe] Error 1 That halted `make test` at the C-test stage on Windows (test_uring is correctly Linux-only, so test_stops was the only blocker). Added a compat_mkdtemp shim to compat.h, following the file's existing convention (every platform difference lives there; the .c stays clean): _mktemp fills the trailing X's in place (same contract as mkdtemp), then _mkdir creates the directory. Also added for _mkdir. On Linux compat.h is a complete no-op, so POSIX mkdtemp is untouched there. Verified: test_stops builds clean on MinGW and all 5 sub-cases pass: tokenizer special-flag parsing, config/generation_config eos union, no-generation_config fallback, both-configs-mutilated tokenizer sweep, and the T=NULL validation path. --- c/compat.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/c/compat.h b/c/compat.h index 82de8b6c..c477170c 100644 --- a/c/compat.h +++ b/c/compat.h @@ -80,6 +80,7 @@ static inline int compat_open_direct(const char *path){ #endif #include #include +#include /* _mkdir (for the mkdtemp shim below) */ #include #include #include @@ -304,6 +305,19 @@ static inline int compat_setenv(const char *name, const char *value, int overwri } #define setenv(name,value,overwrite) compat_setenv(name,value,overwrite) +/* --- mkdtemp -> _mktemp + _mkdir (POSIX mkdtemp assente su Windows) --- + * Test binaries (test_stops.c) create a scratch dir in the CWD via a + * "name_XXXXXX" template; POSIX mkdtemp fills the X's and mkdirs 0700. The + * Windows CRT has _mktemp (in-place, same XXXXXX contract) so we compose it. + * Returns the template pointer on success, NULL on failure — matching POSIX. */ +static inline char *compat_mkdtemp(char *tmpl){ + if(!tmpl) return NULL; + if(!_mktemp(tmpl)) return NULL; /* fills the trailing X's in place */ + if(_mkdir(tmpl) != 0) return NULL; /* EEXIST is impossible post-_mktemp */ + return tmpl; +} +#define mkdtemp(tmpl) compat_mkdtemp(tmpl) + #endif /* _WIN32 */ /* --- compat_aligned_free su piattaforme diverse da Windows ---