From 42dba9d5f4b87dfc6e43e68202285e98e4f10f91 Mon Sep 17 00:00:00 2001 From: Tormod Volden Date: Sat, 13 Mar 2021 22:15:34 +0100 Subject: [PATCH 1/3] Use gmtime for gmtime_r on Windows (including MinGW) Slightly modified from https://redmine.webtoolkit.eu/boards/2/topics/7316 For non-Windows platforms it is declared in Also for MinGW it is declared if _POSIX_THREAD_SAFE_FUNCTIONS is used, but this is not the case here. --- src/libkstapp/labelrenderer.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/libkstapp/labelrenderer.cpp b/src/libkstapp/labelrenderer.cpp index 5cc66ef0..e6503a7d 100644 --- a/src/libkstapp/labelrenderer.cpp +++ b/src/libkstapp/labelrenderer.cpp @@ -30,6 +30,20 @@ #include #include +#if defined (_WIN32) && !defined(_POSIX_THREAD_SAFE_FUNCTIONS) +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 + const double subscript_scale = 0.60; const double subscript_drop = 0.16; const double superscript_scale = 0.60; -- 2.25.1