diff mbox

[babeltrace,3/3] Port: Add glib g_mkdtemp to mkdtemp wrapper

Message ID 1473956083-25901-3-git-send-email-mjeanson@efficios.com
State Superseded, archived
Headers show

Commit Message

Michael Jeanson Sept. 15, 2016, 4:14 p.m. UTC
Signed-off-by: Michael Jeanson <mjeanson at efficios.com>
---
 include/babeltrace/compat/stdlib.h | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/include/babeltrace/compat/stdlib.h b/include/babeltrace/compat/stdlib.h
index 57f942d..be0518f 100644
--- a/include/babeltrace/compat/stdlib.h
+++ b/include/babeltrace/compat/stdlib.h
@@ -25,16 +25,34 @@ 
  * SOFTWARE.
  */
 
+/*
+ * This compat wrapper can be removed and replaced by g_mkdtemp() when we bump
+ * the requirement on glib to version 2.30.
+ */
+
 #include <stdlib.h>
 #include <sys/stat.h>
+#include <glib.h>
 
 #ifdef HAVE_MKDTEMP
+
 static inline
 char *bt_mkdtemp(char *template)
 {
 	return mkdtemp(template);
 }
+
+#elif GLIB_CHECK_VERSION(2,30,0)
+
+#include <glib/gstdio.h>
+static inline
+char *bt_mkdtemp(char *template)
+{
+	return g_mkdtemp(template);
+}
+
 #else
+
 static inline
 char *bt_mkdtemp(char *template)
 {
@@ -54,7 +72,7 @@  char *bt_mkdtemp(char *template)
 end:
 	return ret;
 }
-#endif
 
+#endif
 
 #endif /* _BABELTRACE_COMPAT_STDLIB_H */