[lttng-dev] [Babeltrace PATCH 08/23] Add MinGW implementation of gmtime_r

Ikaheimonen, JP jp_ikaheimonen at mentor.com
Wed May 22 04:06:21 EDT 2013


Add a (non-recursive) implementation of gmtime_r, as it missing
in the MinGW library.
Implementation is written in file include/babeltrace/compat/time.h
which must be included in the source files that call gmtime_r.

Note that the Windows function gmtime_s is not available under
MinGW32.
---
 formats/ctf/ctf.c                |  1 +
 include/babeltrace/compat/time.h | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)
 create mode 100644 include/babeltrace/compat/time.h

diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c
index bb43664..2f743c7 100644
--- a/formats/ctf/ctf.c
+++ b/formats/ctf/ctf.c
@@ -52,6 +52,7 @@
 #include "metadata/ctf-ast.h"
 #include "events-private.h"
 #include <babeltrace/compat/memstream.h>
+#include <babeltrace/compat/time.h>
 
 #define LOG2_CHAR_BIT	3
 
diff --git a/include/babeltrace/compat/time.h b/include/babeltrace/compat/time.h
new file mode 100644
index 0000000..3238d58
--- /dev/null
+++ b/include/babeltrace/compat/time.h
@@ -0,0 +1,20 @@
+#ifndef _BABELTRACE_INCLUDE_COMPAT_TIME_H
+#define _BABELTRACE_INCLUDE_COMPAT_TIME_H
+
+#include <time.h>
+#include <stdlib.h>
+
+#ifdef __MINGW32__
+
+static inline
+struct tm *gmtime_r(const time_t *timep, struct tm *result)
+{
+	struct tm * r;
+
+	r = gmtime(timep);
+	memcpy(result, r, sizeof (struct tm));
+	return result;
+}
+
+#endif
+#endif
-- 
1.8.1.msysgit.1




More information about the lttng-dev mailing list