summaryrefslogtreecommitdiff
path: root/tests/test_atomic.c
diff options
context:
space:
mode:
authorivmai <ivmai>2011-07-14 13:03:28 +0000
committerIvan Maidanski <ivmai@mail.ru>2011-07-25 16:03:27 +0400
commit4fcfce2fa7d8177e7b815a3191b08d10d63e6fb9 (patch)
treece0a20fb58b7f22bb85bcbd08d7ba2f662bb92cc /tests/test_atomic.c
parentd923334022938240c43c167d66549b1211aed2ba (diff)
downloadlibatomic_ops-4fcfce2fa7d8177e7b815a3191b08d10d63e6fb9.tar.gz
2011-07-14 Ivan Maidanski <ivmai@mail.ru>
* tests/list_atomic.template (list_atomicXX): Remove "addr" local variable (use "&val" instead); initialize "newval" and "oldval" local variables; rename "tsaddr" local variable to "ts" one. * tests/list_atomic.template (list_atomicXX): Fix AO_test_and_setXX call (pass address instead of value). * tests/list_atomic.template: Expand all tabs to spaces; remove trailing spaces at EOLn. * tests/run_parallel.inc: Ditto. * tests/test_atomic.c: Ditto. * tests/list_atomic.c: Regenerate. * tests/run_parallel.inc (AO_PTRDIFF_T): New macro. * tests/run_parallel.inc (tramp): Cast between pointer and integer types via casting to AO_PTRDIFF_T. * tests/test_atomic.c (add1sub1_thr, acqrel_thr): Ditto. * tests/run_parallel.inc (run_parallel): Adjust printf format specifiers for DWORD parameters. * tests/test_stack.c: Skip test if no pthreads.
Diffstat (limited to 'tests/test_atomic.c')
-rw-r--r--tests/test_atomic.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/tests/test_atomic.c b/tests/test_atomic.c
index d31297d..7d59393 100644
--- a/tests/test_atomic.c
+++ b/tests/test_atomic.c
@@ -1,11 +1,11 @@
-/*
+/*
* Copyright (c) 2003-2005 Hewlett-Packard Development Company, L.P.
* Original Author: Hans Boehm
*
* This file may be redistributed and/or modified under the
* terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2, or (at your option) any later version.
- *
+ *
* It is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License in the
@@ -40,7 +40,7 @@ AO_t counter = 0;
void * add1sub1_thr(void * id)
{
- int me = (int)(long)id;
+ int me = (int)(AO_PTRDIFF_T)id;
int i;
@@ -68,7 +68,7 @@ AO_t counter2 = 0;
void * acqrel_thr(void *id)
{
- int me = (int)(long)id;
+ int me = (int)(AO_PTRDIFF_T)id;
int i;
@@ -76,36 +76,36 @@ void * acqrel_thr(void *id)
if (me & 1)
{
AO_t my_counter1;
- if (me != 1)
- fprintf(stderr, "acqrel test: too many threads\n");
- my_counter1 = AO_load(&counter1);
- AO_store(&counter1, my_counter1 + 1);
- AO_store_release_write(&counter2, my_counter1 + 1);
+ if (me != 1)
+ fprintf(stderr, "acqrel test: too many threads\n");
+ my_counter1 = AO_load(&counter1);
+ AO_store(&counter1, my_counter1 + 1);
+ AO_store_release_write(&counter2, my_counter1 + 1);
}
else
{
- AO_t my_counter1a, my_counter2a;
- AO_t my_counter1b, my_counter2b;
-
- my_counter2a = AO_load_acquire_read(&counter2);
- my_counter1a = AO_load(&counter1);
- /* Redo this, to make sure that the second load of counter1 */
- /* is not viewed as a common subexpression. */
- my_counter2b = AO_load_acquire_read(&counter2);
- my_counter1b = AO_load(&counter1);
- if (my_counter1a < my_counter2a)
- {
- fprintf(stderr, "Saw release store out of order: %lu < %lu\n",
- (unsigned long)my_counter1a, (unsigned long)my_counter2a);
- abort();
- }
- if (my_counter1b < my_counter2b)
- {
- fprintf(stderr,
- "Saw release store out of order (bad CSE?): %lu < %lu\n",
- (unsigned long)my_counter1b, (unsigned long)my_counter2b);
- abort();
- }
+ AO_t my_counter1a, my_counter2a;
+ AO_t my_counter1b, my_counter2b;
+
+ my_counter2a = AO_load_acquire_read(&counter2);
+ my_counter1a = AO_load(&counter1);
+ /* Redo this, to make sure that the second load of counter1 */
+ /* is not viewed as a common subexpression. */
+ my_counter2b = AO_load_acquire_read(&counter2);
+ my_counter1b = AO_load(&counter1);
+ if (my_counter1a < my_counter2a)
+ {
+ fprintf(stderr, "Saw release store out of order: %lu < %lu\n",
+ (unsigned long)my_counter1a, (unsigned long)my_counter2a);
+ abort();
+ }
+ if (my_counter1b < my_counter2b)
+ {
+ fprintf(stderr,
+ "Saw release store out of order (bad CSE?): %lu < %lu\n",
+ (unsigned long)my_counter1b, (unsigned long)my_counter2b);
+ abort();
+ }
}
return 0;
@@ -136,7 +136,7 @@ void * test_and_set_thr(void * id)
if (locked_counter != 1)
{
fprintf(stderr, "Test and set failure 1, counter = %ld\n",
- locked_counter);
+ locked_counter);
abort();
}
locked_counter *= 2;
@@ -146,7 +146,7 @@ void * test_and_set_thr(void * id)
if (locked_counter != 1)
{
fprintf(stderr, "Test and set failure 2, counter = %ld\n",
- locked_counter);
+ locked_counter);
abort();
}
--locked_counter;
@@ -180,11 +180,11 @@ int main()
# endif
# if defined(AO_HAVE_store_release_write) && defined(AO_HAVE_load_acquire_read)
run_parallel(3, acqrel_thr, acqrel_test,
- "store_release_write/load_acquire_read");
+ "store_release_write/load_acquire_read");
# endif
# if defined(AO_HAVE_test_and_set_acquire)
run_parallel(5, test_and_set_thr, test_and_set_test,
- "test_and_set");
+ "test_and_set");
# endif
return 0;
}