X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Ferror.h;fp=src%2Fcommon%2Ferror.h;h=e5255e4a42adaf9479c412679f812cd8064fa47b;hp=93c947c0d92ce79cf88b6aa7952762b2e35ff85f;hb=e71aad1fa4b06a5f91ddceace42366f3d79bd77e;hpb=4c462e790c62ed5f6c5d61b3a182762fe02f7e9a diff --git a/src/common/error.h b/src/common/error.h index 93c947c0d..e5255e4a4 100644 --- a/src/common/error.h +++ b/src/common/error.h @@ -83,6 +83,20 @@ extern int opt_verbose; __lttng_print(PRINT_ERR, "PERROR: " fmt \ " [in %s() at " __FILE__ ":" XSTR(__LINE__) "]\n", ## args, __func__) +#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 { \ char *buf; \ @@ -90,5 +104,6 @@ extern int opt_verbose; buf = strerror_r(errno, tmp, sizeof(tmp)); \ _PERROR(call ": %s", ## args, buf); \ } while(0); +#endif #endif /* _ERROR_H */