From b0aa034accbc557eac1817c50d5e0b2b76dee978 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 28 Feb 2022 11:18:20 -0600 Subject: [PATCH] Add gmtime_r to security_test.c https://github.com/Hamlib/Hamlib/issues/813 --- security/security_test.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/security/security_test.c b/security/security_test.c index 0e6d4f9be..48d53219f 100644 --- a/security/security_test.c +++ b/security/security_test.c @@ -28,6 +28,27 @@ #include "password.h" #include "../src/misc.h" +#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 + // using tv_usec with a sleep gives a fairly good random number static int my_rand(int max) {