[lttng-dev] [Babeltrace PATCH 16/23] Add MinGW implementation of readdir_r

Ikaheimonen, JP jp_ikaheimonen at mentor.com
Wed May 22 04:07:16 EDT 2013


---
 formats/ctf/ctf.c                  |  2 +-
 include/babeltrace/compat/dirent.h | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 include/babeltrace/compat/dirent.h

diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c
index 0db23c3..ad3c3b1 100644
--- a/formats/ctf/ctf.c
+++ b/formats/ctf/ctf.c
@@ -42,7 +42,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <babeltrace/compat/fcntl.h>
-#include <dirent.h>
+#include <babeltrace/compat/dirent.h>
 #include <glib.h>
 #include <babeltrace/compat/unistd.h>
 #include <stdlib.h>
diff --git a/include/babeltrace/compat/dirent.h b/include/babeltrace/compat/dirent.h
new file mode 100644
index 0000000..281f40b
--- /dev/null
+++ b/include/babeltrace/compat/dirent.h
@@ -0,0 +1,20 @@
+#ifndef _BABELTRACE_INCLUDE_COMPAT_DIRENT_H
+#define _BABELTRACE_INCLUDE_COMPAT_DIRENT_H
+
+#include <dirent.h>
+
+#ifdef __MINGW32__
+static inline
+int readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result)
+{
+	errno = 0;
+	entry = readdir (dirp);
+	*result = entry;
+	if (entry == NULL && errno != 0) {
+		return -1;
+	}
+	return 0;
+}
+#endif
+
+#endif
-- 
1.8.1.msysgit.1




More information about the lttng-dev mailing list