X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=rcuja%2Frcuja-internal.h;h=96e9dabf6225d58ebb91e445c574c8a21ecc3551;hb=7d67da99e337f495c1b4c48636d93fa522bd9dfd;hp=82ab158a7a95bd4f116987098c4e371040484190;hpb=3d8fe30760fd4fb67ce24b5aa011ab75f680a904;p=userspace-rcu.git diff --git a/rcuja/rcuja-internal.h b/rcuja/rcuja-internal.h index 82ab158..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 /* @@ -159,16 +161,40 @@ struct cds_lfht *rcuja_create_ht(const struct rcu_flavor_struct *flavor); __attribute__((visibility("protected"))) int rcuja_delete_ht(struct cds_lfht *ht); -#define DEBUG +//#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