Support XSI strerror_r in error.h
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 21 Feb 2012 18:54:20 +0000 (13:54 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Wed, 22 Feb 2012 22:25:30 +0000 (17:25 -0500)
Acked-by: David Goulet <dgoulet@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/common/error.h

index 81c20223d124282b59bb8ea23801cd714156f441..14b5e7c67ea1eda8f519f2cfe42a48cd32a3a7ca 100644 (file)
@@ -77,12 +77,27 @@ extern int opt_verbose;
 #define _PERROR(fmt, args...) \
        __lttng_print(PRINT_ERR, "perror " fmt "\n", ## args)
 
+#if !defined(__linux__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
+/*
+ * Version using XSI strerror_r.
+ */
+#define PERROR(call, args...) \
+       do { \
+               char buf[200]; \
+               strerror_r(errno, buf, sizeof(buf)); \
+               _PERROR(call ": %s", ## args, buf); \
+       } while(0);
+#else
+/*
+ * Version using GNU strerror_r, for linux with appropriate defines.
+ */
 #define PERROR(call, args...) \
-    do { \
+       do { \
                char *buf; \
                char tmp[200]; \
                buf = strerror_r(errno, tmp, sizeof(tmp)); \
                _PERROR(call ": %s", ## args, buf); \
        } while(0);
+#endif
 
 #endif /* _ERROR_H */
This page took 0.026121 seconds and 4 git commands to generate.