X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=tests%2Ftest_rwlock_timing.c;h=628bed459af61e38afada3626e2b05e8dd659ab6;hb=f5d36fed8c4c03890527ab5051f1167b02e68324;hp=5bc93d33d969e8a1cf1c74901d048f06652a68eb;hpb=833dbdb633ba44bfb71b4b965a83096d8e4e827b;p=urcu.git diff --git a/tests/test_rwlock_timing.c b/tests/test_rwlock_timing.c index 5bc93d3..628bed4 100644 --- a/tests/test_rwlock_timing.c +++ b/tests/test_rwlock_timing.c @@ -3,7 +3,7 @@ * * Userspace RCU library - test program * - * Copyright February 2009 - Mathieu Desnoyers + * Copyright February 2009 - Mathieu Desnoyers * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +20,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#define _GNU_SOURCE #include #include #include @@ -29,12 +30,14 @@ #include #include #include -#include #include -#include "../arch.h" +#include -/* Make this big enough to include the POWER5+ L3 cacheline size of 256B */ -#define CACHE_LINE_SIZE 4096 +#include + +#ifdef __linux__ +#include +#endif #if defined(_syscall0) _syscall0(pid_t, gettid) @@ -51,7 +54,7 @@ static inline pid_t gettid(void) } #endif -#include "../urcu.h" +#include struct test_array { int a; @@ -75,8 +78,8 @@ static int num_write; #define NR_READ num_read #define NR_WRITE num_write -static cycles_t __attribute__((aligned(CACHE_LINE_SIZE))) *reader_time; -static cycles_t __attribute__((aligned(CACHE_LINE_SIZE))) *writer_time; +static cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *reader_time; +static cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *writer_time; void *thr_reader(void *arg) { @@ -87,7 +90,7 @@ void *thr_reader(void *arg) "reader", pthread_self(), (unsigned long)gettid()); sleep(2); - time1 = get_cycles(); + time1 = caa_get_cycles(); for (i = 0; i < OUTER_READ_LOOP; i++) { for (j = 0; j < INNER_READ_LOOP; j++) { pthread_rwlock_rdlock(&lock); @@ -95,7 +98,7 @@ void *thr_reader(void *arg) pthread_rwlock_unlock(&lock); } } - time2 = get_cycles(); + time2 = caa_get_cycles(); reader_time[(unsigned long)arg] = time2 - time1; @@ -117,11 +120,11 @@ void *thr_writer(void *arg) for (i = 0; i < OUTER_WRITE_LOOP; i++) { for (j = 0; j < INNER_WRITE_LOOP; j++) { - time1 = get_cycles(); + time1 = caa_get_cycles(); pthread_rwlock_wrlock(&lock); test_array.a = 8; pthread_rwlock_unlock(&lock); - time2 = get_cycles(); + time2 = caa_get_cycles(); writer_time[(unsigned long)arg] += time2 - time1; usleep(1); }