compat UPDATE embedded platform improvements
diff --git a/compat/compat.c b/compat/compat.c
index 24f235c..380c756 100644
--- a/compat/compat.c
+++ b/compat/compat.c
@@ -325,6 +325,40 @@
#endif
#endif
+#ifndef HAVE_TIMEGM
+time_t
+timegm(struct tm *tm)
+{
+ pthread_mutex_t tz_lock = PTHREAD_MUTEX_INITIALIZER;
+ time_t ret;
+ char *tz;
+
+ pthread_mutex_lock(&tz_lock);
+
+ tz = getenv("TZ");
+ if (tz) {
+ tz = strdup(tz);
+ }
+ setenv("TZ", "", 1);
+ tzset();
+
+ ret = mktime(tm);
+
+ if (tz) {
+ setenv("TZ", tz, 1);
+ free(tz);
+ } else {
+ unsetenv("TZ");
+ }
+ tzset();
+
+ pthread_mutex_unlock(&tz_lock);
+
+ return ret;
+}
+
+#endif
+
#ifndef HAVE_SETENV
#ifdef _WIN32
int