From 4536c55b81a87f3e3089891438f84dda96654564 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 24 Jul 2009 06:41:08 +0000 Subject: [PATCH] Reverted r10511. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10579 --- drd/tests/rwlock_test.c | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/drd/tests/rwlock_test.c b/drd/tests/rwlock_test.c index 34d99dae03..1c490c73bc 100644 --- a/drd/tests/rwlock_test.c +++ b/drd/tests/rwlock_test.c @@ -10,45 +10,25 @@ #include #include -#include // strerror() - #define NUM_ITERATIONS 1000 -#define PTH_CALL(expr) \ - do \ - { \ - int err = (expr); \ - if ((err) != 0) \ - { \ - fprintf(stderr, \ - "%s:%d %s returned error code %d (%s)\n", \ - __FILE__, \ - __LINE__, \ - #expr, \ - err, \ - strerror(err)); \ - } \ - } while (0) - - static pthread_rwlock_t s_rwlock; static int s_counter; - static void* thread_func(void* arg) { int i; int sum = 0; - for (i = 0; i < 1000; i++) + for (i = 0; i < NUM_ITERATIONS; i++) { - PTH_CALL(pthread_rwlock_rdlock(&s_rwlock)); + pthread_rwlock_rdlock(&s_rwlock); sum += s_counter; - PTH_CALL(pthread_rwlock_unlock(&s_rwlock)); - PTH_CALL(pthread_rwlock_wrlock(&s_rwlock)); + pthread_rwlock_unlock(&s_rwlock); + pthread_rwlock_wrlock(&s_rwlock); s_counter++; - PTH_CALL(pthread_rwlock_unlock(&s_rwlock)); + pthread_rwlock_unlock(&s_rwlock); } return 0; @@ -60,15 +40,15 @@ int main(int argc, char** argv) pthread_t tid[thread_count]; int i; - PTH_CALL(pthread_rwlock_init(&s_rwlock, NULL)); + pthread_rwlock_init(&s_rwlock, NULL); for (i = 0; i < thread_count; i++) { - PTH_CALL(pthread_create(&tid[i], 0, thread_func, 0)); + pthread_create(&tid[i], 0, thread_func, 0); } for (i = 0; i < thread_count; i++) { - PTH_CALL(pthread_join(tid[i], 0)); + pthread_join(tid[i], 0); } fprintf(stderr, "s_counter - thread_count * iterations = %d\n", -- 2.47.3