X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Ferror.h;h=6660cee6adec9f765d8802bacfe80db44e67f954;hb=48a4000561343808724f7cb5fa8c131877489ccd;hp=ea00ea5f96f7b81eb5bfb045e9ae893e5303644d;hpb=f5fb86c1254b785eee8caf87cb996d33eda0ede9;p=lttng-tools.git diff --git a/src/common/error.h b/src/common/error.h index ea00ea5f9..6660cee6a 100644 --- a/src/common/error.h +++ b/src/common/error.h @@ -8,7 +8,7 @@ #ifndef _ERROR_H #define _ERROR_H -#include +#include #include #include #include @@ -25,6 +25,10 @@ #include #include +#if defined(__cplusplus) +extern "C" { +#endif + /* Avoid conflict with Solaris */ #if defined(ERR) && defined(__sun__) #undef ERR @@ -221,7 +225,7 @@ static inline void __lttng_print_check_abort(enum lttng_error_level type) DBG3(fmt, ## args); \ break; \ default: \ - assert(0); \ + abort(); \ } \ } while(0); @@ -232,23 +236,24 @@ static inline void __lttng_print_check_abort(enum lttng_error_level type) /* * 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); +#define PERROR(call, args...) \ + do { \ + char _perror_buf[200]; \ + strerror_r(errno, _perror_buf, sizeof(_perror_buf)); \ + _PERROR(call ": %s", ##args, _perror_buf); \ + } while (0); #else /* * Version using GNU strerror_r, for linux with appropriate defines. */ -#define PERROR(call, args...) \ - do { \ - char *buf; \ - char tmp[200]; \ - buf = strerror_r(errno, tmp, sizeof(tmp)); \ - _PERROR(call ": %s", ## args, buf); \ - } while(0); +#define PERROR(call, args...) \ + do { \ + char *_perror_buf; \ + char _perror_tmp[200]; \ + _perror_buf = strerror_r( \ + errno, _perror_tmp, sizeof(_perror_tmp)); \ + _PERROR(call ": %s", ##args, _perror_buf); \ + } while (0); #endif const char *error_get_str(int32_t code); @@ -261,7 +266,10 @@ const char *error_get_str(int32_t code); const char *log_add_time(void); /* Name must be a statically-allocated string. */ -LTTNG_HIDDEN void logger_set_thread_name(const char *name, bool set_pthread_name); +#if defined(__cplusplus) +} +#endif + #endif /* _ERROR_H */