summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xConfigureChecks.cmake1
-rwxr-xr-xconfig.h.cmake19
2 files changed, 19 insertions, 1 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 997cc54b..ba6ef1e7 100755
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -30,6 +30,7 @@ else()
check_function_exists(getpid HAVE_GETPID) #Unix <unistd.h>
check_function_exists(getpwent HAVE_GETPWENT) #Unix <sys/types.h>,<pwd.h>
check_function_exists(gmtime_r HAVE_GMTIME_R) #Unix <time.h>
+ check_function_exists(localtime_r HAVE_LOCALTIME_R) #Unix <time.h>
check_function_exists(mkdir HAVE_MKDIR) #Unix <sys/stat.h>,<sys/types.h>
check_function_exists(open HAVE_OPEN) #Unix <sys/stat.h>,<sys/types.h>,<fcntl.h>
check_function_exists(nanosleep HAVE_NANOSLEEP) #Unix <time.h>
diff --git a/config.h.cmake b/config.h.cmake
index 0d567369..80d32455 100755
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -18,6 +18,9 @@
/* Define to 1 if you have the `gmtime_r' function. */
#cmakedefine HAVE_GMTIME_R 1
+/* Define to 1 if you have the `localtime_r' function. */
+#cmakedefine HAVE_LOCALTIME_R 1
+
/* Define to 1 if you have the <inttypes.h> header file. */
#cmakedefine HAVE_INTTYPES_H 1
@@ -472,7 +475,7 @@ typedef ssize_t IO_SSIZE_T;
#endif
#endif
-/* gmtime_r - thread safe gmtime() really only need on Unix */
+/* gmtime_r - thread safe gmtime() really only needed on Unix */
#if !defined(HAVE_GMTIME_R)
#if !defined(_WIN32)
#error "No thread-safe gmtime function available"
@@ -486,6 +489,20 @@ typedef ssize_t IO_SSIZE_T;
#endif
#include <time.h>
+/* localtime_r - thread safe localtime() really only needed on Unix */
+#if !defined(HAVE_LOCALTIME_R)
+#if !defined(_WIN32)
+#error "No thread-safe localtime function available"
+#endif
+/*on Windows there might be a macro called localtime_r in pthread.h. don't use it.*/
+#if defined(localtime_r)
+#undef localtime_r
+#endif
+/* FYI: The localtime() in Microsoft's C library is MT-safe */
+#define localtime_r(tp,tmp) (localtime(tp)?(*(tmp)=*localtime(tp),(tmp)):0)
+#endif
+#include <time.h>
+
/* define MAXPATHLEN */
#if defined(_WIN32)
#include <windows.h> //for MAX_PATH