From: David Goulet Date: Tue, 21 Feb 2012 22:53:02 +0000 (-0500) Subject: Merge branch 'master' of git://git.lttng.org/lttng-tools X-Git-Tag: v2.0.0-rc2~35 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=373d38732a83167f19c3be89cf9ff238743cdeb0;hp=a440509044c2828bf6dbfb05e8d9d6d0277ce1a4 Merge branch 'master' of git://git.lttng.org/lttng-tools --- diff --git a/src/common/error.h b/src/common/error.h index 81c20223d..14b5e7c67 100644 --- a/src/common/error.h +++ b/src/common/error.h @@ -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 */