]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Define _POSIX_THREAD_SAFE_FUNCTIONS (MinGW-w64)
authorWolfgang Stöggl <c72578@yahoo.de>
Sun, 19 May 2019 18:28:59 +0000 (20:28 +0200)
committerTobias Oetiker <tobi@oetiker.ch>
Sun, 19 May 2019 19:47:42 +0000 (21:47 +0200)
- 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

configure.ac
src/rrd_config_bottom.h
src/rrd_rpncalc.c

index b615ce11d6bea66417091faa0d1db1d2036842d8..0db5d88a3a6ac5b9a6dd0199faeff4e67f864387 100644 (file)
@@ -448,7 +448,7 @@ AC_LINK_IFELSE(
     [ AC_LINK_IFELSE(
           [AC_LANG_PROGRAM(
                 [[#ifdef __MINGW32__
-#include <pthread.h>
+#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L
 #endif
 #include <time.h>]],
                 [[ctime_r(NULL,NULL)]])],
index 184eb58a41a6d56f0bb1b6be1d20815981468f66..82d04e09abd11f1f2f0bf686cf5e4cdb7b4816e5 100644 (file)
 # include <unistd.h>
 #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 <sys/time.h>
 # include <time.h>
index 0211491d77f29920b4e31238d5a68c1c1687af71..e3e5fd257453c4c5361156dbaf109807b6e0084a 100644 (file)
@@ -7,17 +7,8 @@
 #include <limits.h>
 #include <locale.h>
 #include <stdlib.h>
-#ifdef __MINGW32__
-#include <pthread.h>
-/* 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 <time.h> or remove include of <time.h>
- * 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 <time.h>
 #include "rrd_tool.h"
+#include <time.h>
 
 #ifdef HAVE_LANGINFO_H
 #include <langinfo.h>