From: Mathieu Desnoyers Date: Sat, 18 May 2013 15:18:31 +0000 (+0200) Subject: rcuja: Add debug output X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=7d67da99e337f495c1b4c48636d93fa522bd9dfd;p=urcu.git rcuja: Add debug output Signed-off-by: Mathieu Desnoyers --- diff --git a/rcuja/rcuja-internal.h b/rcuja/rcuja-internal.h index 6b8da15..96e9dab 100644 --- a/rcuja/rcuja-internal.h +++ b/rcuja/rcuja-internal.h @@ -23,9 +23,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#define _GNU_SOURCE #include #include #include +#include #include /* @@ -161,14 +163,38 @@ int rcuja_delete_ht(struct cds_lfht *ht); //#define DEBUG +#ifdef __linux__ +#include +#endif + +#if defined(_syscall0) +_syscall0(pid_t, gettid) +#elif defined(__NR_gettid) +static inline pid_t gettid(void) +{ + return syscall(__NR_gettid); +} +#else +#warning "use pid as tid" +static inline pid_t gettid(void) +{ + return getpid(); +} +#endif + #ifdef DEBUG -#define dbg_printf(fmt, args...) printf("[debug rcuja] " fmt, ## args) +#define dbg_printf(fmt, args...) \ + fprintf(stderr, "[debug rcuja %lu %s()@%s:%u] " fmt, \ + (unsigned long) gettid(), __func__, \ + __FILE__, __LINE__, ## args) #else #define dbg_printf(fmt, args...) \ do { \ /* do nothing but check printf format */ \ if (0) \ - printf("[debug rcuja] " fmt, ## args); \ + fprintf(stderr, "[debug rcuja %lu %s()@%s:%u] " fmt, \ + (unsigned long) gettid(), __func__, \ + __FILE__, __LINE__, ## args); \ } while (0) #endif