From: Michael Jeanson Date: Thu, 15 Sep 2016 19:47:01 +0000 (+0000) Subject: Port: Add timegm compat for mingw X-Git-Tag: v2.0.0-pre1~91 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=3d2f08e7a34d78b0fff4da7a374a81c7d4141ac6 Port: Add timegm compat for mingw Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- diff --git a/include/babeltrace/compat/utc-internal.h b/include/babeltrace/compat/utc-internal.h index fd41f620..d78a1885 100644 --- a/include/babeltrace/compat/utc-internal.h +++ b/include/babeltrace/compat/utc-internal.h @@ -34,6 +34,14 @@ time_t bt_timegm(struct tm *tm) return timegm(tm); } +#elif defined(__MINGW32__) + +static inline +time_t bt_timegm(struct tm *tm) +{ + return _mkgmtime(tm); +} + #else #include diff --git a/plugins/utils/trimmer/iterator.c b/plugins/utils/trimmer/iterator.c index b726c695..8241014d 100644 --- a/plugins/utils/trimmer/iterator.c +++ b/plugins/utils/trimmer/iterator.c @@ -27,6 +27,7 @@ */ #include +#include #include #include #include @@ -158,9 +159,9 @@ int update_lazy_bound(struct trimmer_bound *bound, const char *name, tm.tm_sec = bound->lazy_values.ss; tm.tm_min = bound->lazy_values.mm; tm.tm_hour = bound->lazy_values.hh; - timeval = timegm(&tm); + timeval = bt_timegm(&tm); if (timeval < 0) { - printf_error("Failure in timegm(), incorrectly formatted %s timestamp", + printf_error("Failure in bt_timegm(), incorrectly formatted %s timestamp", name); goto error; } diff --git a/plugins/utils/trimmer/trimmer.c b/plugins/utils/trimmer/trimmer.c index b938bd51..58684d05 100644 --- a/plugins/utils/trimmer/trimmer.c +++ b/plugins/utils/trimmer/trimmer.c @@ -26,6 +26,7 @@ * SOFTWARE. */ +#include #include #include #include @@ -106,7 +107,7 @@ int timestamp_from_arg(const char *arg, struct trimmer *trimmer, time_t result; if (gmt) { - result = timegm(&tm); + result = bt_timegm(&tm); if (result < 0) { return -1; } @@ -152,7 +153,7 @@ int timestamp_from_arg(const char *arg, struct trimmer *trimmer, time_t result; if (gmt) { - result = timegm(&tm); + result = bt_timegm(&tm); if (result < 0) { return -1; } @@ -200,7 +201,7 @@ int timestamp_from_arg(const char *arg, struct trimmer *trimmer, }; if (gmt) { - value = timegm(&tm); + value = bt_timegm(&tm); if (value < 0) { return -1; } @@ -244,7 +245,7 @@ int timestamp_from_arg(const char *arg, struct trimmer *trimmer, time_t result; if (gmt) { - result = timegm(&tm); + result = bt_timegm(&tm); if (result < 0) { return -1; }