From 5d9e481dff798103567399f310b54c5928849466 Mon Sep 17 00:00:00 2001 From: Vreixo Formoso Date: Sun, 27 Jan 2008 14:41:52 +0100 Subject: [PATCH] Check for non standard timegm, and replace it if not available. --- configure.ac | 5 +++++ libisofs/util.c | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/configure.ac b/configure.ac index 8465b6f..b7ebea0 100644 --- a/configure.ac +++ b/configure.ac @@ -98,6 +98,11 @@ AC_CHECK_MEMBER([struct tm.tm_gmtoff], , [#include ]) +AC_CHECK_DECL([timegm], + [AC_DEFINE(HAVE_TIMEGM, 1, [Define this if timegm function is available])], + , + [#include ]) + THREAD_LIBS=-lpthread AC_SUBST(THREAD_LIBS) diff --git a/libisofs/util.c b/libisofs/util.c index 0f28f50..4209b83 100644 --- a/libisofs/util.c +++ b/libisofs/util.c @@ -1058,6 +1058,26 @@ void iso_datetime_17(unsigned char *buf, time_t t, int always_gmt) } +#ifndef HAVE_TIMEGM +static +time_t timegm(struct tm *tm) +{ + time_t ret; + char *tz; + + tz = getenv("TZ"); + setenv("TZ", "", 1); + tzset(); + ret = mktime(tm); + if (tz) + setenv("TZ", tz, 1); + else + unsetenv("TZ"); + tzset(); + return ret; +} +#endif + time_t iso_datetime_read_7(const uint8_t *buf) { struct tm tm;