From e695db0f2d97cbba2832e0f3dc25af5add1f16ac Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 12 Jan 2015 17:03:45 +0100 Subject: MDEV-7437 remove suport for "atomics" with rwlocks --- unittest/mysys/my_atomic-t.c | 34 ---------------------------------- unittest/mysys/thr_template.c | 8 -------- 2 files changed, 42 deletions(-) (limited to 'unittest/mysys') diff --git a/unittest/mysys/my_atomic-t.c b/unittest/mysys/my_atomic-t.c index 35e782eb360..0f21c33455e 100644 --- a/unittest/mysys/my_atomic-t.c +++ b/unittest/mysys/my_atomic-t.c @@ -17,7 +17,6 @@ volatile uint32 b32; volatile int32 c32; -my_atomic_rwlock_t rwl; /* add and sub a random number in a loop. Must get 0 at the end */ pthread_handler_t test_atomic_add(void *arg) @@ -27,13 +26,8 @@ pthread_handler_t test_atomic_add(void *arg) for (x= ((int)(intptr)(&m)); m ; m--) { x= (x*m+0x87654321) & INT_MAX32; - my_atomic_rwlock_wrlock(&rwl); my_atomic_add32(&bad, x); - my_atomic_rwlock_wrunlock(&rwl); - - my_atomic_rwlock_wrlock(&rwl); my_atomic_add32(&bad, -x); - my_atomic_rwlock_wrunlock(&rwl); } pthread_mutex_lock(&mutex); if (!--running_threads) pthread_cond_signal(&cond); @@ -50,13 +44,8 @@ pthread_handler_t test_atomic_add64(void *arg) for (x= ((int64)(intptr)(&m)); m ; m--) { x= (x*m+0xfdecba987654321LL) & INT_MAX64; - my_atomic_rwlock_wrlock(&rwl); my_atomic_add64(&a64, x); - my_atomic_rwlock_wrunlock(&rwl); - - my_atomic_rwlock_wrlock(&rwl); my_atomic_add64(&a64, -x); - my_atomic_rwlock_wrunlock(&rwl); } pthread_mutex_lock(&mutex); if (!--running_threads) @@ -82,31 +71,17 @@ pthread_handler_t test_atomic_fas(void *arg) int m= *(int *)arg; int32 x; - my_atomic_rwlock_wrlock(&rwl); x= my_atomic_add32(&b32, 1); - my_atomic_rwlock_wrunlock(&rwl); - my_atomic_rwlock_wrlock(&rwl); my_atomic_add32(&bad, x); - my_atomic_rwlock_wrunlock(&rwl); for (; m ; m--) - { - my_atomic_rwlock_wrlock(&rwl); x= my_atomic_fas32(&c32, x); - my_atomic_rwlock_wrunlock(&rwl); - } if (!x) - { - my_atomic_rwlock_wrlock(&rwl); x= my_atomic_fas32(&c32, x); - my_atomic_rwlock_wrunlock(&rwl); - } - my_atomic_rwlock_wrlock(&rwl); my_atomic_add32(&bad, -x); - my_atomic_rwlock_wrunlock(&rwl); pthread_mutex_lock(&mutex); if (!--running_threads) pthread_cond_signal(&cond); @@ -125,19 +100,13 @@ pthread_handler_t test_atomic_cas(void *arg) int32 x, y; for (x= ((int)(intptr)(&m)); m ; m--) { - my_atomic_rwlock_wrlock(&rwl); y= my_atomic_load32(&bad); - my_atomic_rwlock_wrunlock(&rwl); x= (x*m+0x87654321) & INT_MAX32; do { - my_atomic_rwlock_wrlock(&rwl); ok= my_atomic_cas32(&bad, &y, (uint32)y+x); - my_atomic_rwlock_wrunlock(&rwl); } while (!ok) ; do { - my_atomic_rwlock_wrlock(&rwl); ok= my_atomic_cas32(&bad, &y, y-x); - my_atomic_rwlock_wrunlock(&rwl); } while (!ok) ; } pthread_mutex_lock(&mutex); @@ -154,7 +123,6 @@ void do_tests() bad= my_atomic_initialize(); ok(!bad, "my_atomic_initialize() returned %d", bad); - my_atomic_rwlock_init(&rwl); b32= c32= 0; test_concurrently("my_atomic_add32", test_atomic_add, THREADS, CYCLES); @@ -178,6 +146,4 @@ void do_tests() } a64=0; test_concurrently("my_atomic_add64", test_atomic_add64, THREADS, CYCLES); - - my_atomic_rwlock_destroy(&rwl); } diff --git a/unittest/mysys/thr_template.c b/unittest/mysys/thr_template.c index 7304eb50955..38999022da0 100644 --- a/unittest/mysys/thr_template.c +++ b/unittest/mysys/thr_template.c @@ -64,15 +64,7 @@ int main(int argc __attribute__((unused)), char **argv) pthread_attr_init(&thr_attr); pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED); -#ifdef MY_ATOMIC_MODE_RWLOCKS -#if defined(HPUX11) || defined(__POWERPC__) /* showed to be very slow (scheduler-related) */ -#define CYCLES 300 -#else #define CYCLES 3000 -#endif -#else -#define CYCLES 3000 -#endif #define THREADS 30 diag("N CPUs: %d, atomic ops: %s", my_getncpus(), MY_ATOMIC_MODE); -- cgit v1.2.1