diff mbox series

[RFC,07/21] t/clar: simplify how the clar derives `struct stat`

Message ID f006545eef1624218491cfaf7e678c4cf83d42fd.1727881164.git.ps@pks.im (mailing list archive)
State Superseded
Headers show
Series Modernize the build system | expand

Commit Message

Patrick Steinhardt Oct. 2, 2024, 3:15 p.m. UTC
Windows has different definitions of `struct stat`. The difference
between those structs is that they either use 32 or 64 bit timestamps
and/or filesizes.

In the clar we try to set that up automatically, but the logic to do so
is somewhat convoluted and really fragile. Refactor the code such that
we always define the `stat()` function and its structure together, which
is both easier to understand and less fragile.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 t/unit-tests/clar/clar.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/t/unit-tests/clar/clar.c b/t/unit-tests/clar/clar.c
index f463ee823a..12fa66d088 100644
--- a/t/unit-tests/clar/clar.c
+++ b/t/unit-tests/clar/clar.c
@@ -30,6 +30,9 @@ 
 
 #	ifndef stat
 #		define stat(path, st) _stat(path, st)
+		typedef struct _stat STAT_T;
+#	else
+		typedef struct stat STAT_T;
 #	endif
 #	ifndef mkdir
 #		define mkdir(path, mode) _mkdir(path)
@@ -62,12 +65,6 @@ 
 #	else
 #		define p_snprintf snprintf
 #	endif
-
-#	if defined(_MSC_VER) || (defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR))
-	typedef struct stat STAT_T;
-#	else
-	typedef struct _stat STAT_T;
-#	endif
 #else
 #	include <sys/wait.h> /* waitpid(2) */
 #	include <unistd.h>