X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=tests%2Ftest_rwlock_timing.c;h=628bed459af61e38afada3626e2b05e8dd659ab6;hp=b26f83dcc9035c20ea878896bc8b1477eaa64a76;hb=6d5c0ca90ae4e999cdf4366ff615a6c619e7257e;hpb=ec4e58a3aba2084440012f8ccac3a31eb6101183 diff --git a/tests/test_rwlock_timing.c b/tests/test_rwlock_timing.c index b26f83d..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 + #include -/* Make this big enough to include the POWER5+ L3 cacheline size of 256B */ -#define CACHE_LINE_SIZE 4096 +#ifdef __linux__ +#include +#endif #if defined(_syscall0) _syscall0(pid_t, gettid) @@ -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); }