[lttng-dev] [Babeltrace PATCH 09/23] Add MinGW implementaion of localtime_r

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


Add a (non-recursive) implementation of localtime_r for MinGW32.
MinGW does not include the Windows Visual C function localtime_s,
so the implementation uses localtime() instead.
---
 include/babeltrace/compat/time.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/babeltrace/compat/time.h b/include/babeltrace/compat/time.h
index 3238d58..5f23bfa 100644
--- a/include/babeltrace/compat/time.h
+++ b/include/babeltrace/compat/time.h
@@ -16,5 +16,14 @@ struct tm *gmtime_r(const time_t *timep, struct tm *result)
 	return result;
 }
 
+static inline
+struct tm *localtime_r(const time_t *timep, struct tm *result)
+{
+	struct tm * r;
+
+	r = localtime(timep);
+	memcpy(result, r, sizeof (struct tm));
+	return result;
+}
 #endif
 #endif
-- 
1.8.1.msysgit.1




More information about the lttng-dev mailing list