compat UPDATE support for timegm
diff --git a/CMakeModules/UseCompat.cmake b/CMakeModules/UseCompat.cmake
index c1befd7..4cc1873 100644
--- a/CMakeModules/UseCompat.cmake
+++ b/CMakeModules/UseCompat.cmake
@@ -27,6 +27,7 @@
set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200809L)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D__BSD_VISIBLE=1)
+ list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_DEFAULT_SOURCE)
set(CMAKE_REQUIRED_LIBRARIES pthread)
check_symbol_exists(vdprintf "stdio.h;stdarg.h" HAVE_VDPRINTF)
@@ -54,6 +55,7 @@
check_symbol_exists(realpath "stdlib.h" HAVE_REALPATH)
check_symbol_exists(localtime_r "time.h" HAVE_LOCALTIME_R)
check_symbol_exists(gmtime_r "time.h" HAVE_GMTIME_R)
+ check_symbol_exists(timegm "time.h" HAVE_TIMEGM)
check_symbol_exists(strptime "time.h" HAVE_STRPTIME)
check_symbol_exists(mmap "sys/mman.h" HAVE_MMAP)
check_symbol_exists(dirname "libgen.h" HAVE_DIRNAME)
diff --git a/compat/compat.h.in b/compat/compat.h.in
index c697d6c..6df7a7b 100644
--- a/compat/compat.h.in
+++ b/compat/compat.h.in
@@ -70,6 +70,7 @@
#cmakedefine HAVE_REALPATH
#cmakedefine HAVE_LOCALTIME_R
#cmakedefine HAVE_GMTIME_R
+#cmakedefine HAVE_TIMEGM
#cmakedefine HAVE_STRPTIME
#cmakedefine HAVE_MMAP
#cmakedefine HAVE_DIRNAME
@@ -188,6 +189,14 @@
struct tm *localtime_r(const time_t *timep, struct tm *result);
#endif
+#ifndef HAVE_TIMEGM
+# if defined (_WIN32)
+# define timegm _mkgmtime
+# else
+# error No timegm() implementation for this platform is available.
+# endif
+#endif
+
#ifndef HAVE_STRPTIME
char *strptime(const char *s, const char *format, struct tm *tm);
#endif