From: Wolfgang Stöggl Date: Sun, 19 May 2019 18:28:59 +0000 (+0200) Subject: Define _POSIX_THREAD_SAFE_FUNCTIONS (MinGW-w64) X-Git-Tag: v1.7.2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f7056505eb656c099fe0237c425b95e25215143;p=thirdparty%2Frrdtool-1.x.git Define _POSIX_THREAD_SAFE_FUNCTIONS (MinGW-w64) - time.h of MinGW-w64 requires _POSIX_THREAD_SAFE_FUNCTIONS to be defined in order to provide ctime_r, gmtime_r or localtime_r. - In newer versions of winpthreads (e.g. git-7.0.0.5447.a2d94c81), _POSIX_THREAD_SAFE_FUNCTIONS is not defined any more in pthread_unistd.h. Hence define it here directly. - This is a follow-up to commit: https://github.com/oetiker/rrdtool-1.x/commit/603de9a --- diff --git a/configure.ac b/configure.ac index b615ce11..0db5d88a 100644 --- a/configure.ac +++ b/configure.ac @@ -448,7 +448,7 @@ AC_LINK_IFELSE( [ AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[#ifdef __MINGW32__ -#include +#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L #endif #include ]], [[ctime_r(NULL,NULL)]])], diff --git a/src/rrd_config_bottom.h b/src/rrd_config_bottom.h index 184eb58a..82d04e09 100644 --- a/src/rrd_config_bottom.h +++ b/src/rrd_config_bottom.h @@ -68,6 +68,13 @@ # include #endif +/* for MinGW-w64 */ +#if (defined(__MINGW32__) && !defined(_POSIX_THREAD_SAFE_FUNCTIONS)) +/* time.h of MinGW-w64 requires _POSIX_THREAD_SAFE_FUNCTIONS to be defined + * in order to provide ctime_r, gmtime_r or localtime_r. */ +#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L +#endif + #ifdef TIME_WITH_SYS_TIME # include # include diff --git a/src/rrd_rpncalc.c b/src/rrd_rpncalc.c index 0211491d..e3e5fd25 100644 --- a/src/rrd_rpncalc.c +++ b/src/rrd_rpncalc.c @@ -7,17 +7,8 @@ #include #include #include -#ifdef __MINGW32__ -#include -/* time.h of MinGW-w64 requires _POSIX_THREAD_SAFE_FUNCTIONS to be defined in order to provide - * localtime_r. _POSIX_THREAD_SAFE_FUNCTIONS is defined in pthread_unistd.h (included from pthread.h). - * Alternatives here would be to either include "rrd_tool.h" before or remove include of - * from rrd_rpncalc.c, because time.h is included via rrd_tool.h ... - * However, let's do it this way, by including pthread.h here, only if __MINGW32__ is defined, - * in order to avoid any changes concerning other systems. */ -#endif -#include #include "rrd_tool.h" +#include #ifdef HAVE_LANGINFO_H #include