[lttng-dev] [Babeltrace RFC PATCH 09/28] Add MinGW implementation of strerror_r

Ikaheimonen, JP jp_ikaheimonen at mentor.com
Thu May 2 07:50:35 EDT 2013


---
 compat/compat_strlib.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/compat/compat_strlib.c b/compat/compat_strlib.c
index 9aabb07..7413e74 100644
--- a/compat/compat_strlib.c
+++ b/compat/compat_strlib.c
@@ -1,5 +1,17 @@
 #include <babeltrace/compat/string.h>
 
+#ifdef __MINGW32__
+int strerror_r(int errnum, char *buf, size_t buflen)
+{
+	/* non-recursive implementation of strerror_r */
+	char * retbuf;
+	retbuf = strerror(errnum);
+	strncpy(buf, retbuf, buflen);
+	buf[buflen - 1] = '\0';
+	return 0;
+}
+#endif
+
 int compat_strerror_r(int errnum, char *buf, size_t buflen)
 {
 #if !defined(__linux__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
-- 
1.8.1.msysgit.1




More information about the lttng-dev mailing list