From 66594d44a56b72dcb4ebc3adde853d5fff5d03e3 Mon Sep 17 00:00:00 2001 From: sidney Date: Wed, 1 Jan 2025 08:58:51 +0100 Subject: [PATCH] Forget to include sys/time.h which is needed for MingGW32 builds. --- src/sim65/peripherals.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/sim65/peripherals.c b/src/sim65/peripherals.c index 4fa512ed8..4f105d87a 100644 --- a/src/sim65/peripherals.c +++ b/src/sim65/peripherals.c @@ -30,7 +30,7 @@ #include #include -#if defined(__MINGW64__) +#if defined(__MINGW64__) || defined(__MINGW32__) /* For gettimeofday() */ #include #endif @@ -63,7 +63,22 @@ static bool GetWallclockTime (struct timespec * ts) #if defined(__MINGW64__) /* When using the MinGW64 compiler, neither timespec_get() nor clock_gettime() - * are available; using either of them makes the Linux workflow build fail. + * are available; using either of them makes the Linux PR build workflow build fail. + * The gettimeofday() function does work, so use that; its microsecond resolution + * is fine for most applications. + */ + struct timeval tv; + time_valid = (gettimeofday(&tv, NULL) == 0); + if (time_valid) { + ts->tv_sec = tv.tv_sec; + ts->tv_nsec = tv.tv_usec * 1000; + } +#elif defined(__MINGW32__) + /* Note: we test for MinGW32 after the test for MinGW64, as the __MINGW32__ symbol is also + * defined in MinGW64. This allows us to distinguish MinGW32 and MinGW64 build. + * + * When using the MinGW32 compiler, neither timespec_get() nor clock_gettime() + * are available; using either of them makes the Linux snapshot workflow build fail. * The gettimeofday() function does work, so use that; its microsecond resolution * is fine for most applications. */