From 820e4d43103b0b5cda944d496701adc15c16c822 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Thu, 2 Sep 2021 17:08:10 -0500 Subject: [PATCH] Fix compilation of misc.c with gmtime_r replacement function for mingw https://github.com/Hamlib/Hamlib/issues/784 --- src/misc.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/misc.c b/src/misc.c index bc679198f..76121037f 100644 --- a/src/misc.c +++ b/src/misc.c @@ -2346,6 +2346,27 @@ uint32_t CRC32_function(uint8_t *buf, uint32_t len) return crc ^ 0xFFFFFFFF; } +#if defined(_WIN32) +// gmtime_r can be defined by mingw +#ifndef gmtime_r +static struct tm *gmtime_r(const time_t *t, struct tm *r) +{ + // gmtime is threadsafe in windows because it uses TLS + struct tm *theTm = gmtime(t); + + if (theTm) + { + *r = *theTm; + return r; + } + else + { + return 0; + } +} +#endif // gmtime_r +#endif // _WIN32 + //! @cond Doxygen_Suppress char *date_strget(char *buf, int buflen) {