Port: Add timegm compat for mingw
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 15 Sep 2016 19:47:01 +0000 (19:47 +0000)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 9 Jun 2017 20:58:15 +0000 (16:58 -0400)
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/babeltrace/compat/utc-internal.h
plugins/utils/trimmer/iterator.c
plugins/utils/trimmer/trimmer.c

index fd41f620091131dc53b4b9a50cd604b10ddc8104..d78a1885203764f9830dca11b98eccbfb5d0a173 100644 (file)
@@ -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 <string.h>
index b726c695381d334614352c21d06b2c0ab240cf40..8241014d4fe678b9660ed40f053fcfd0207237e6 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 #include <babeltrace/compat/time-internal.h>
+#include <babeltrace/compat/utc-internal.h>
 #include <babeltrace/graph/notification-iterator.h>
 #include <babeltrace/graph/private-notification-iterator.h>
 #include <babeltrace/graph/notification.h>
@@ -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;
                }
index b938bd51f5932d9582092921a9818a78b6db7c84..58684d05617750fd30a5b445c81756ae90eec7b7 100644 (file)
@@ -26,6 +26,7 @@
  * SOFTWARE.
  */
 
+#include <babeltrace/compat/utc-internal.h>
 #include <babeltrace/plugin/plugin-dev.h>
 #include <babeltrace/graph/component.h>
 #include <babeltrace/graph/private-component.h>
@@ -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;
                                }
This page took 0.027508 seconds and 4 git commands to generate.