[lttng-dev] [Babeltrace RFC PATCH 11/28] Add MinGW implementation of gmtime_r

Ikaheimonen, JP jp_ikaheimonen at mentor.com
Thu May 2 07:52:51 EDT 2013


Add a (non-recursive) implementation of gmtime_r as it is
missing in the MinGW standard library.
Implementation is written in file include/babeltrace/compat/time.h
which must be included in the source files that call gmtime_r.
---
 formats/ctf/ctf.c                |  1 +
 include/babeltrace/compat/time.h | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+)
 create mode 100644 include/babeltrace/compat/time.h

diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c
index 0cfad44..255a492 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..ccfc860
--- /dev/null
+++ b/include/babeltrace/compat/time.h
@@ -0,0 +1,19 @@
+#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