From dc7232fa53a35a1764b849391717dbff8afc6489 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 30 Jun 2015 00:01:26 +0900 Subject: [PATCH] Fix travis compile error --- configure.ac | 2 ++ src/timegm.c | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 9acab2c5..6a0b477c 100644 --- a/configure.ac +++ b/configure.ac @@ -556,6 +556,8 @@ fi # adjustment. AC_CHECK_SIZEOF([int *]) +AC_CHECK_SIZEOF([time_t]) + # Checks for library functions. if test "x$cross_compiling" != "xyes"; then AC_FUNC_MALLOC diff --git a/src/timegm.c b/src/timegm.c index a935ba70..b80e0789 100644 --- a/src/timegm.c +++ b/src/timegm.c @@ -44,10 +44,12 @@ time_t timegm(struct tm *tm) { num_leap_year = count_leap_year(tm->tm_year + 1900) - count_leap_year(1970); days = (tm->tm_year - 70) * 365 + num_leap_year + tm->tm_yday; t = ((int64_t)days * 24 + tm->tm_hour) * 3600 + tm->tm_min * 60 + tm->tm_sec; - if (sizeof(time_t) == 4) { - if (t < INT32_MIN || t > INT32_MAX) { - return -1; - } + +#if SIZEOF_TIME_T == 4 + if (t < INT32_MIN || t > INT32_MAX) { + return -1; } +#endif /* SIZEOF_TIME_T == 4 */ + return (time_t)t; }