X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=tests%2Ftest_rwlock_timing.c;h=628bed459af61e38afada3626e2b05e8dd659ab6;hp=869017ea9a1d0dc8a250d3a88de47d7d86ec02d4;hb=1f689e13ea7e519b1afc001e9c55a7b1b60b599f;hpb=94b343fd8d68512d78d8646c646c15a1b3f84186 diff --git a/tests/test_rwlock_timing.c b/tests/test_rwlock_timing.c index 869017e..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,15 @@ #include #include #include -#include #include #include #include +#ifdef __linux__ +#include +#endif + #if defined(_syscall0) _syscall0(pid_t, gettid) #elif defined(__NR_gettid) @@ -74,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) { @@ -86,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); @@ -94,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; @@ -116,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); }