X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=tests%2Ftest_perthreadlock_timing.c;h=9321f034f1221882c0dfc307033c3fc514d90473;hp=d0cc11c3841df70e08a1718417cc9e9c134d1116;hb=94df63189704b8f6483c737988df3728f5e13c2d;hpb=550265b2c2de28e0fe566f71fb1cab64fa620efa diff --git a/tests/test_perthreadlock_timing.c b/tests/test_perthreadlock_timing.c index d0cc11c..9321f03 100644 --- a/tests/test_perthreadlock_timing.c +++ b/tests/test_perthreadlock_timing.c @@ -34,24 +34,7 @@ #include -#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 +#include "thread-id.h" #include @@ -90,9 +73,8 @@ void *thr_reader(void *arg) cycles_t time1, time2; long tidx = (long)arg; - printf("thread_begin %s, thread id : %lx, tid %lu\n", - "reader", (unsigned long) pthread_self(), - (unsigned long) gettid()); + printf("thread_begin %s, tid %lu\n", + "reader", urcu_get_thread_id()); sleep(2); time1 = caa_get_cycles(); @@ -108,9 +90,8 @@ void *thr_reader(void *arg) reader_time[tidx] = time2 - time1; sleep(2); - printf("thread_end %s, thread id : %lx, tid %lu\n", - "reader", (unsigned long) pthread_self(), - (unsigned long) gettid()); + printf("thread_end %s, tid %lu\n", + "reader", urcu_get_thread_id()); return ((void*)1); } @@ -121,9 +102,8 @@ void *thr_writer(void *arg) long tidx; cycles_t time1, time2; - printf("thread_begin %s, thread id : %lx, tid %lu\n", - "writer", (unsigned long) pthread_self(), - (unsigned long) gettid()); + printf("thread_begin %s, tid %lu\n", + "writer", urcu_get_thread_id()); sleep(2); for (i = 0; i < OUTER_WRITE_LOOP; i++) { @@ -142,9 +122,8 @@ void *thr_writer(void *arg) } } - printf("thread_end %s, thread id : %lx, tid %lu\n", - "writer", (unsigned long) pthread_self(), - (unsigned long) gettid()); + printf("thread_end %s, tid %lu\n", + "writer", urcu_get_thread_id()); return ((void*)2); } @@ -169,9 +148,8 @@ int main(int argc, char **argv) tid_reader = malloc(sizeof(*tid_reader) * num_read); tid_writer = malloc(sizeof(*tid_writer) * num_write); - printf("thread %-6s, thread id : %lx, tid %lu\n", - "main", (unsigned long) pthread_self(), - (unsigned long) gettid()); + printf("thread %-6s, tid %lu\n", + "main", urcu_get_thread_id()); per_thread_lock = malloc(sizeof(struct per_thread_lock) * NR_READ);