From: ivmai Date: Thu, 14 Jul 2011 13:03:28 +0000 (+0000) Subject: 2011-07-14 Ivan Maidanski X-Git-Tag: upstream/7.6.8~34 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4fcfce2fa7d8177e7b815a3191b08d10d63e6fb9;p=platform%2Fupstream%2Flibatomic_ops.git 2011-07-14 Ivan Maidanski * 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. --- diff --git a/ChangeLog b/ChangeLog index 8f417b6..f40f329 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2011-07-14 Ivan Maidanski + + * 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. + 2011-06-27 Ivan Maidanski (really Jeremy Huddleston) * src/atomic_ops/sysdeps/gcc/x86.h (AO_test_and_set_full): diff --git a/tests/list_atomic.c b/tests/list_atomic.c index 1faf5c4..a71a4af 100644 --- a/tests/list_atomic.c +++ b/tests/list_atomic.c @@ -6,17 +6,17 @@ * see doc/COPYING for details. */ -/* This generates a compilable program. But it is really meant to be */ -/* be used only with cc -E, to inspect the expensions generated by */ -/* primitives. */ +/* This generates a compilable program. But it is really meant to be */ +/* be used only with cc -E, to inspect the expensions generated by */ +/* primitives. */ -/* The result will not link or run. */ +/* The result will not link or run. */ void list_atomic(void) { - AO_T *addr, val, newval, oldval; - AO_TS_T tsaddr; - long incr; + AO_T val, newval = 0, oldval = 0; + AO_TS_T ts; + long incr = 0; # if defined(AO_HAVE_nop) "AO_nop(): "; @@ -25,51 +25,48 @@ void list_atomic(void) "No AO_nop"; # endif # if defined(AO_HAVE_load) - "AO_load(addr):"; - AO_load(addr); + "AO_load(&val):"; + AO_load(&val); # else "No AO_load"; # endif # if defined(AO_HAVE_store) - "AO_store(addr, val):"; - AO_store(addr, val); + "AO_store(&val, newval):"; + AO_store(&val, newval); # else "No AO_store"; # endif # if defined(AO_HAVE_test_and_set) - "AO_test_and_set(tsaddr):"; - AO_test_and_set(tsaddr); + "AO_test_and_set(&ts):"; + AO_test_and_set(&ts); # else "No AO_test_and_set"; # endif # if defined(AO_HAVE_fetch_and_add1) - "AO_fetch_and_add1(addr):"; - AO_fetch_and_add1(addr); + "AO_fetch_and_add1(&val):"; + AO_fetch_and_add1(&val); # else "No AO_fetch_and_add1"; # endif # if defined(AO_HAVE_fetch_and_sub1) - "AO_fetch_and_sub1(addr):"; - AO_fetch_and_sub1(addr); + "AO_fetch_and_sub1(&val):"; + AO_fetch_and_sub1(&val); # else "No AO_fetch_and_sub1"; # endif # if defined(AO_HAVE_fetch_and_add) - "AO_fetch_and_add(addr, incr):"; - AO_fetch_and_add(addr, incr); + "AO_fetch_and_add(&val, incr):"; + AO_fetch_and_add(&val, incr); # else "No AO_fetch_and_add"; # endif # if defined(AO_HAVE_compare_and_swap) - "AO_compare_and_swap(addr, oldval, newval):"; - AO_compare_and_swap(addr, oldval, newval); + "AO_compare_and_swap(&val, oldval, newval):"; + AO_compare_and_swap(&val, oldval, newval); # else "No AO_compare_and_swap"; # endif } - - - /* * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved. * @@ -77,17 +74,17 @@ void list_atomic(void) * see doc/COPYING for details. */ -/* This generates a compilable program. But it is really meant to be */ -/* be used only with cc -E, to inspect the expensions generated by */ -/* primitives. */ +/* This generates a compilable program. But it is really meant to be */ +/* be used only with cc -E, to inspect the expensions generated by */ +/* primitives. */ -/* The result will not link or run. */ +/* The result will not link or run. */ void list_atomic_release(void) { - AO_T *addr, val, newval, oldval; - AO_TS_T tsaddr; - long incr; + AO_T val, newval = 0, oldval = 0; + AO_TS_T ts; + long incr = 0; # if defined(AO_HAVE_nop_release) "AO_nop_release(): "; @@ -96,51 +93,48 @@ void list_atomic_release(void) "No AO_nop_release"; # endif # if defined(AO_HAVE_load_release) - "AO_load_release(addr):"; - AO_load_release(addr); + "AO_load_release(&val):"; + AO_load_release(&val); # else "No AO_load_release"; # endif # if defined(AO_HAVE_store_release) - "AO_store_release(addr, val):"; - AO_store_release(addr, val); + "AO_store_release(&val, newval):"; + AO_store_release(&val, newval); # else "No AO_store_release"; # endif # if defined(AO_HAVE_test_and_set_release) - "AO_test_and_set_release(tsaddr):"; - AO_test_and_set_release(tsaddr); + "AO_test_and_set_release(&ts):"; + AO_test_and_set_release(&ts); # else "No AO_test_and_set_release"; # endif # if defined(AO_HAVE_fetch_and_add1_release) - "AO_fetch_and_add1_release(addr):"; - AO_fetch_and_add1_release(addr); + "AO_fetch_and_add1_release(&val):"; + AO_fetch_and_add1_release(&val); # else "No AO_fetch_and_add1_release"; # endif # if defined(AO_HAVE_fetch_and_sub1_release) - "AO_fetch_and_sub1_release(addr):"; - AO_fetch_and_sub1_release(addr); + "AO_fetch_and_sub1_release(&val):"; + AO_fetch_and_sub1_release(&val); # else "No AO_fetch_and_sub1_release"; # endif # if defined(AO_HAVE_fetch_and_add_release) - "AO_fetch_and_add_release(addr, incr):"; - AO_fetch_and_add_release(addr, incr); + "AO_fetch_and_add_release(&val, incr):"; + AO_fetch_and_add_release(&val, incr); # else "No AO_fetch_and_add_release"; # endif # if defined(AO_HAVE_compare_and_swap_release) - "AO_compare_and_swap_release(addr, oldval, newval):"; - AO_compare_and_swap_release(addr, oldval, newval); + "AO_compare_and_swap_release(&val, oldval, newval):"; + AO_compare_and_swap_release(&val, oldval, newval); # else "No AO_compare_and_swap_release"; # endif } - - - /* * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved. * @@ -148,17 +142,17 @@ void list_atomic_release(void) * see doc/COPYING for details. */ -/* This generates a compilable program. But it is really meant to be */ -/* be used only with cc -E, to inspect the expensions generated by */ -/* primitives. */ +/* This generates a compilable program. But it is really meant to be */ +/* be used only with cc -E, to inspect the expensions generated by */ +/* primitives. */ -/* The result will not link or run. */ +/* The result will not link or run. */ void list_atomic_acquire(void) { - AO_T *addr, val, newval, oldval; - AO_TS_T tsaddr; - long incr; + AO_T val, newval = 0, oldval = 0; + AO_TS_T ts; + long incr = 0; # if defined(AO_HAVE_nop_acquire) "AO_nop_acquire(): "; @@ -167,51 +161,48 @@ void list_atomic_acquire(void) "No AO_nop_acquire"; # endif # if defined(AO_HAVE_load_acquire) - "AO_load_acquire(addr):"; - AO_load_acquire(addr); + "AO_load_acquire(&val):"; + AO_load_acquire(&val); # else "No AO_load_acquire"; # endif # if defined(AO_HAVE_store_acquire) - "AO_store_acquire(addr, val):"; - AO_store_acquire(addr, val); + "AO_store_acquire(&val, newval):"; + AO_store_acquire(&val, newval); # else "No AO_store_acquire"; # endif # if defined(AO_HAVE_test_and_set_acquire) - "AO_test_and_set_acquire(tsaddr):"; - AO_test_and_set_acquire(tsaddr); + "AO_test_and_set_acquire(&ts):"; + AO_test_and_set_acquire(&ts); # else "No AO_test_and_set_acquire"; # endif # if defined(AO_HAVE_fetch_and_add1_acquire) - "AO_fetch_and_add1_acquire(addr):"; - AO_fetch_and_add1_acquire(addr); + "AO_fetch_and_add1_acquire(&val):"; + AO_fetch_and_add1_acquire(&val); # else "No AO_fetch_and_add1_acquire"; # endif # if defined(AO_HAVE_fetch_and_sub1_acquire) - "AO_fetch_and_sub1_acquire(addr):"; - AO_fetch_and_sub1_acquire(addr); + "AO_fetch_and_sub1_acquire(&val):"; + AO_fetch_and_sub1_acquire(&val); # else "No AO_fetch_and_sub1_acquire"; # endif # if defined(AO_HAVE_fetch_and_add_acquire) - "AO_fetch_and_add_acquire(addr, incr):"; - AO_fetch_and_add_acquire(addr, incr); + "AO_fetch_and_add_acquire(&val, incr):"; + AO_fetch_and_add_acquire(&val, incr); # else "No AO_fetch_and_add_acquire"; # endif # if defined(AO_HAVE_compare_and_swap_acquire) - "AO_compare_and_swap_acquire(addr, oldval, newval):"; - AO_compare_and_swap_acquire(addr, oldval, newval); + "AO_compare_and_swap_acquire(&val, oldval, newval):"; + AO_compare_and_swap_acquire(&val, oldval, newval); # else "No AO_compare_and_swap_acquire"; # endif } - - - /* * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved. * @@ -219,17 +210,17 @@ void list_atomic_acquire(void) * see doc/COPYING for details. */ -/* This generates a compilable program. But it is really meant to be */ -/* be used only with cc -E, to inspect the expensions generated by */ -/* primitives. */ +/* This generates a compilable program. But it is really meant to be */ +/* be used only with cc -E, to inspect the expensions generated by */ +/* primitives. */ -/* The result will not link or run. */ +/* The result will not link or run. */ void list_atomic_read(void) { - AO_T *addr, val, newval, oldval; - AO_TS_T tsaddr; - long incr; + AO_T val, newval = 0, oldval = 0; + AO_TS_T ts; + long incr = 0; # if defined(AO_HAVE_nop_read) "AO_nop_read(): "; @@ -238,51 +229,48 @@ void list_atomic_read(void) "No AO_nop_read"; # endif # if defined(AO_HAVE_load_read) - "AO_load_read(addr):"; - AO_load_read(addr); + "AO_load_read(&val):"; + AO_load_read(&val); # else "No AO_load_read"; # endif # if defined(AO_HAVE_store_read) - "AO_store_read(addr, val):"; - AO_store_read(addr, val); + "AO_store_read(&val, newval):"; + AO_store_read(&val, newval); # else "No AO_store_read"; # endif # if defined(AO_HAVE_test_and_set_read) - "AO_test_and_set_read(tsaddr):"; - AO_test_and_set_read(tsaddr); + "AO_test_and_set_read(&ts):"; + AO_test_and_set_read(&ts); # else "No AO_test_and_set_read"; # endif # if defined(AO_HAVE_fetch_and_add1_read) - "AO_fetch_and_add1_read(addr):"; - AO_fetch_and_add1_read(addr); + "AO_fetch_and_add1_read(&val):"; + AO_fetch_and_add1_read(&val); # else "No AO_fetch_and_add1_read"; # endif # if defined(AO_HAVE_fetch_and_sub1_read) - "AO_fetch_and_sub1_read(addr):"; - AO_fetch_and_sub1_read(addr); + "AO_fetch_and_sub1_read(&val):"; + AO_fetch_and_sub1_read(&val); # else "No AO_fetch_and_sub1_read"; # endif # if defined(AO_HAVE_fetch_and_add_read) - "AO_fetch_and_add_read(addr, incr):"; - AO_fetch_and_add_read(addr, incr); + "AO_fetch_and_add_read(&val, incr):"; + AO_fetch_and_add_read(&val, incr); # else "No AO_fetch_and_add_read"; # endif # if defined(AO_HAVE_compare_and_swap_read) - "AO_compare_and_swap_read(addr, oldval, newval):"; - AO_compare_and_swap_read(addr, oldval, newval); + "AO_compare_and_swap_read(&val, oldval, newval):"; + AO_compare_and_swap_read(&val, oldval, newval); # else "No AO_compare_and_swap_read"; # endif } - - - /* * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved. * @@ -290,17 +278,17 @@ void list_atomic_read(void) * see doc/COPYING for details. */ -/* This generates a compilable program. But it is really meant to be */ -/* be used only with cc -E, to inspect the expensions generated by */ -/* primitives. */ +/* This generates a compilable program. But it is really meant to be */ +/* be used only with cc -E, to inspect the expensions generated by */ +/* primitives. */ -/* The result will not link or run. */ +/* The result will not link or run. */ void list_atomic_write(void) { - AO_T *addr, val, newval, oldval; - AO_TS_T tsaddr; - long incr; + AO_T val, newval = 0, oldval = 0; + AO_TS_T ts; + long incr = 0; # if defined(AO_HAVE_nop_write) "AO_nop_write(): "; @@ -309,51 +297,48 @@ void list_atomic_write(void) "No AO_nop_write"; # endif # if defined(AO_HAVE_load_write) - "AO_load_write(addr):"; - AO_load_write(addr); + "AO_load_write(&val):"; + AO_load_write(&val); # else "No AO_load_write"; # endif # if defined(AO_HAVE_store_write) - "AO_store_write(addr, val):"; - AO_store_write(addr, val); + "AO_store_write(&val, newval):"; + AO_store_write(&val, newval); # else "No AO_store_write"; # endif # if defined(AO_HAVE_test_and_set_write) - "AO_test_and_set_write(tsaddr):"; - AO_test_and_set_write(tsaddr); + "AO_test_and_set_write(&ts):"; + AO_test_and_set_write(&ts); # else "No AO_test_and_set_write"; # endif # if defined(AO_HAVE_fetch_and_add1_write) - "AO_fetch_and_add1_write(addr):"; - AO_fetch_and_add1_write(addr); + "AO_fetch_and_add1_write(&val):"; + AO_fetch_and_add1_write(&val); # else "No AO_fetch_and_add1_write"; # endif # if defined(AO_HAVE_fetch_and_sub1_write) - "AO_fetch_and_sub1_write(addr):"; - AO_fetch_and_sub1_write(addr); + "AO_fetch_and_sub1_write(&val):"; + AO_fetch_and_sub1_write(&val); # else "No AO_fetch_and_sub1_write"; # endif # if defined(AO_HAVE_fetch_and_add_write) - "AO_fetch_and_add_write(addr, incr):"; - AO_fetch_and_add_write(addr, incr); + "AO_fetch_and_add_write(&val, incr):"; + AO_fetch_and_add_write(&val, incr); # else "No AO_fetch_and_add_write"; # endif # if defined(AO_HAVE_compare_and_swap_write) - "AO_compare_and_swap_write(addr, oldval, newval):"; - AO_compare_and_swap_write(addr, oldval, newval); + "AO_compare_and_swap_write(&val, oldval, newval):"; + AO_compare_and_swap_write(&val, oldval, newval); # else "No AO_compare_and_swap_write"; # endif } - - - /* * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved. * @@ -361,17 +346,17 @@ void list_atomic_write(void) * see doc/COPYING for details. */ -/* This generates a compilable program. But it is really meant to be */ -/* be used only with cc -E, to inspect the expensions generated by */ -/* primitives. */ +/* This generates a compilable program. But it is really meant to be */ +/* be used only with cc -E, to inspect the expensions generated by */ +/* primitives. */ -/* The result will not link or run. */ +/* The result will not link or run. */ void list_atomic_full(void) { - AO_T *addr, val, newval, oldval; - AO_TS_T tsaddr; - long incr; + AO_T val, newval = 0, oldval = 0; + AO_TS_T ts; + long incr = 0; # if defined(AO_HAVE_nop_full) "AO_nop_full(): "; @@ -380,51 +365,48 @@ void list_atomic_full(void) "No AO_nop_full"; # endif # if defined(AO_HAVE_load_full) - "AO_load_full(addr):"; - AO_load_full(addr); + "AO_load_full(&val):"; + AO_load_full(&val); # else "No AO_load_full"; # endif # if defined(AO_HAVE_store_full) - "AO_store_full(addr, val):"; - AO_store_full(addr, val); + "AO_store_full(&val, newval):"; + AO_store_full(&val, newval); # else "No AO_store_full"; # endif # if defined(AO_HAVE_test_and_set_full) - "AO_test_and_set_full(tsaddr):"; - AO_test_and_set_full(tsaddr); + "AO_test_and_set_full(&ts):"; + AO_test_and_set_full(&ts); # else "No AO_test_and_set_full"; # endif # if defined(AO_HAVE_fetch_and_add1_full) - "AO_fetch_and_add1_full(addr):"; - AO_fetch_and_add1_full(addr); + "AO_fetch_and_add1_full(&val):"; + AO_fetch_and_add1_full(&val); # else "No AO_fetch_and_add1_full"; # endif # if defined(AO_HAVE_fetch_and_sub1_full) - "AO_fetch_and_sub1_full(addr):"; - AO_fetch_and_sub1_full(addr); + "AO_fetch_and_sub1_full(&val):"; + AO_fetch_and_sub1_full(&val); # else "No AO_fetch_and_sub1_full"; # endif # if defined(AO_HAVE_fetch_and_add_full) - "AO_fetch_and_add_full(addr, incr):"; - AO_fetch_and_add_full(addr, incr); + "AO_fetch_and_add_full(&val, incr):"; + AO_fetch_and_add_full(&val, incr); # else "No AO_fetch_and_add_full"; # endif # if defined(AO_HAVE_compare_and_swap_full) - "AO_compare_and_swap_full(addr, oldval, newval):"; - AO_compare_and_swap_full(addr, oldval, newval); + "AO_compare_and_swap_full(&val, oldval, newval):"; + AO_compare_and_swap_full(&val, oldval, newval); # else "No AO_compare_and_swap_full"; # endif } - - - /* * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved. * @@ -432,17 +414,17 @@ void list_atomic_full(void) * see doc/COPYING for details. */ -/* This generates a compilable program. But it is really meant to be */ -/* be used only with cc -E, to inspect the expensions generated by */ -/* primitives. */ +/* This generates a compilable program. But it is really meant to be */ +/* be used only with cc -E, to inspect the expensions generated by */ +/* primitives. */ -/* The result will not link or run. */ +/* The result will not link or run. */ void list_atomic_release_write(void) { - AO_T *addr, val, newval, oldval; - AO_TS_T tsaddr; - long incr; + AO_T val, newval = 0, oldval = 0; + AO_TS_T ts; + long incr = 0; # if defined(AO_HAVE_nop_release_write) "AO_nop_release_write(): "; @@ -451,51 +433,48 @@ void list_atomic_release_write(void) "No AO_nop_release_write"; # endif # if defined(AO_HAVE_load_release_write) - "AO_load_release_write(addr):"; - AO_load_release_write(addr); + "AO_load_release_write(&val):"; + AO_load_release_write(&val); # else "No AO_load_release_write"; # endif # if defined(AO_HAVE_store_release_write) - "AO_store_release_write(addr, val):"; - AO_store_release_write(addr, val); + "AO_store_release_write(&val, newval):"; + AO_store_release_write(&val, newval); # else "No AO_store_release_write"; # endif # if defined(AO_HAVE_test_and_set_release_write) - "AO_test_and_set_release_write(tsaddr):"; - AO_test_and_set_release_write(tsaddr); + "AO_test_and_set_release_write(&ts):"; + AO_test_and_set_release_write(&ts); # else "No AO_test_and_set_release_write"; # endif # if defined(AO_HAVE_fetch_and_add1_release_write) - "AO_fetch_and_add1_release_write(addr):"; - AO_fetch_and_add1_release_write(addr); + "AO_fetch_and_add1_release_write(&val):"; + AO_fetch_and_add1_release_write(&val); # else "No AO_fetch_and_add1_release_write"; # endif # if defined(AO_HAVE_fetch_and_sub1_release_write) - "AO_fetch_and_sub1_release_write(addr):"; - AO_fetch_and_sub1_release_write(addr); + "AO_fetch_and_sub1_release_write(&val):"; + AO_fetch_and_sub1_release_write(&val); # else "No AO_fetch_and_sub1_release_write"; # endif # if defined(AO_HAVE_fetch_and_add_release_write) - "AO_fetch_and_add_release_write(addr, incr):"; - AO_fetch_and_add_release_write(addr, incr); + "AO_fetch_and_add_release_write(&val, incr):"; + AO_fetch_and_add_release_write(&val, incr); # else "No AO_fetch_and_add_release_write"; # endif # if defined(AO_HAVE_compare_and_swap_release_write) - "AO_compare_and_swap_release_write(addr, oldval, newval):"; - AO_compare_and_swap_release_write(addr, oldval, newval); + "AO_compare_and_swap_release_write(&val, oldval, newval):"; + AO_compare_and_swap_release_write(&val, oldval, newval); # else "No AO_compare_and_swap_release_write"; # endif } - - - /* * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved. * @@ -503,17 +482,17 @@ void list_atomic_release_write(void) * see doc/COPYING for details. */ -/* This generates a compilable program. But it is really meant to be */ -/* be used only with cc -E, to inspect the expensions generated by */ -/* primitives. */ +/* This generates a compilable program. But it is really meant to be */ +/* be used only with cc -E, to inspect the expensions generated by */ +/* primitives. */ -/* The result will not link or run. */ +/* The result will not link or run. */ void list_atomic_acquire_read(void) { - AO_T *addr, val, newval, oldval; - AO_TS_T tsaddr; - long incr; + AO_T val, newval = 0, oldval = 0; + AO_TS_T ts; + long incr = 0; # if defined(AO_HAVE_nop_acquire_read) "AO_nop_acquire_read(): "; @@ -522,48 +501,45 @@ void list_atomic_acquire_read(void) "No AO_nop_acquire_read"; # endif # if defined(AO_HAVE_load_acquire_read) - "AO_load_acquire_read(addr):"; - AO_load_acquire_read(addr); + "AO_load_acquire_read(&val):"; + AO_load_acquire_read(&val); # else "No AO_load_acquire_read"; # endif # if defined(AO_HAVE_store_acquire_read) - "AO_store_acquire_read(addr, val):"; - AO_store_acquire_read(addr, val); + "AO_store_acquire_read(&val, newval):"; + AO_store_acquire_read(&val, newval); # else "No AO_store_acquire_read"; # endif # if defined(AO_HAVE_test_and_set_acquire_read) - "AO_test_and_set_acquire_read(tsaddr):"; - AO_test_and_set_acquire_read(tsaddr); + "AO_test_and_set_acquire_read(&ts):"; + AO_test_and_set_acquire_read(&ts); # else "No AO_test_and_set_acquire_read"; # endif # if defined(AO_HAVE_fetch_and_add1_acquire_read) - "AO_fetch_and_add1_acquire_read(addr):"; - AO_fetch_and_add1_acquire_read(addr); + "AO_fetch_and_add1_acquire_read(&val):"; + AO_fetch_and_add1_acquire_read(&val); # else "No AO_fetch_and_add1_acquire_read"; # endif # if defined(AO_HAVE_fetch_and_sub1_acquire_read) - "AO_fetch_and_sub1_acquire_read(addr):"; - AO_fetch_and_sub1_acquire_read(addr); + "AO_fetch_and_sub1_acquire_read(&val):"; + AO_fetch_and_sub1_acquire_read(&val); # else "No AO_fetch_and_sub1_acquire_read"; # endif # if defined(AO_HAVE_fetch_and_add_acquire_read) - "AO_fetch_and_add_acquire_read(addr, incr):"; - AO_fetch_and_add_acquire_read(addr, incr); + "AO_fetch_and_add_acquire_read(&val, incr):"; + AO_fetch_and_add_acquire_read(&val, incr); # else "No AO_fetch_and_add_acquire_read"; # endif # if defined(AO_HAVE_compare_and_swap_acquire_read) - "AO_compare_and_swap_acquire_read(addr, oldval, newval):"; - AO_compare_and_swap_acquire_read(addr, oldval, newval); + "AO_compare_and_swap_acquire_read(&val, oldval, newval):"; + AO_compare_and_swap_acquire_read(&val, oldval, newval); # else "No AO_compare_and_swap_acquire_read"; # endif } - - - diff --git a/tests/list_atomic.template b/tests/list_atomic.template index a3d36e3..958e44f 100644 --- a/tests/list_atomic.template +++ b/tests/list_atomic.template @@ -5,17 +5,17 @@ * see doc/COPYING for details. */ -/* This generates a compilable program. But it is really meant to be */ -/* be used only with cc -E, to inspect the expensions generated by */ -/* primitives. */ +/* This generates a compilable program. But it is really meant to be */ +/* be used only with cc -E, to inspect the expensions generated by */ +/* primitives. */ -/* The result will not link or run. */ +/* The result will not link or run. */ void list_atomicXX(void) { - AO_T *addr, val, newval, oldval; - AO_TS_T tsaddr; - long incr; + AO_T val, newval = 0, oldval = 0; + AO_TS_T ts; + long incr = 0; # if defined(AO_HAVE_nopXX) "AO_nopXX(): "; @@ -24,48 +24,45 @@ void list_atomicXX(void) "No AO_nopXX"; # endif # if defined(AO_HAVE_loadXX) - "AO_loadXX(addr):"; - AO_loadXX(addr); + "AO_loadXX(&val):"; + AO_loadXX(&val); # else "No AO_loadXX"; # endif # if defined(AO_HAVE_storeXX) - "AO_storeXX(addr, val):"; - AO_storeXX(addr, val); + "AO_storeXX(&val, newval):"; + AO_storeXX(&val, newval); # else "No AO_storeXX"; # endif # if defined(AO_HAVE_test_and_setXX) - "AO_test_and_setXX(tsaddr):"; - AO_test_and_setXX(tsaddr); + "AO_test_and_setXX(&ts):"; + AO_test_and_setXX(&ts); # else "No AO_test_and_setXX"; # endif # if defined(AO_HAVE_fetch_and_add1XX) - "AO_fetch_and_add1XX(addr):"; - AO_fetch_and_add1XX(addr); + "AO_fetch_and_add1XX(&val):"; + AO_fetch_and_add1XX(&val); # else "No AO_fetch_and_add1XX"; # endif # if defined(AO_HAVE_fetch_and_sub1XX) - "AO_fetch_and_sub1XX(addr):"; - AO_fetch_and_sub1XX(addr); + "AO_fetch_and_sub1XX(&val):"; + AO_fetch_and_sub1XX(&val); # else "No AO_fetch_and_sub1XX"; # endif # if defined(AO_HAVE_fetch_and_addXX) - "AO_fetch_and_addXX(addr, incr):"; - AO_fetch_and_addXX(addr, incr); + "AO_fetch_and_addXX(&val, incr):"; + AO_fetch_and_addXX(&val, incr); # else "No AO_fetch_and_addXX"; # endif # if defined(AO_HAVE_compare_and_swapXX) - "AO_compare_and_swapXX(addr, oldval, newval):"; - AO_compare_and_swapXX(addr, oldval, newval); + "AO_compare_and_swapXX(&val, oldval, newval):"; + AO_compare_and_swapXX(&val, oldval, newval); # else "No AO_compare_and_swapXX"; # endif } - - - diff --git a/tests/run_parallel.inc b/tests/run_parallel.inc index 1a87c8b..8c326ab 100644 --- a/tests/run_parallel.inc +++ b/tests/run_parallel.inc @@ -33,9 +33,17 @@ #include "atomic_ops.h" +#ifndef _WIN64 +# define AO_PTRDIFF_T long +#elif defined(__int64) +# define AO_PTRDIFF_T __int64 +#else +# define AO_PTRDIFF_T long long +#endif + typedef void * (* thr_func)(void *); -typedef int (* test_func)(void); /* Returns != 0 on success */ +typedef int (* test_func)(void); /* Returns != 0 on success */ void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name); @@ -48,7 +56,7 @@ void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name) int code; fprintf(stderr, "Testing %s\n", name); - if (nthreads > 100) + if (nthreads > 100) { fprintf(stderr, "run_parallel: requested too many threads\n"); abort(); @@ -59,7 +67,7 @@ void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name) /* Increase it. */ if (pthread_default_stacksize_np(1024*1024, 0) != 0) { fprintf(stderr, "pthread_default_stacksize_np failed. " - "OK after first call.\n"); + "OK after first call.\n"); } # endif @@ -68,19 +76,19 @@ void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name) for (i = 0; i < nthreads; ++i) { if ((code = pthread_create(thr + i, &attr, f1, (void *)(long)i)) != 0) - { - perror("Thread creation failed"); - fprintf(stderr, "Pthread_create returned %d, thread %d\n", code, i); - abort(); + { + perror("Thread creation failed"); + fprintf(stderr, "Pthread_create returned %d, thread %d\n", code, i); + abort(); } } for (i = 0; i < nthreads; ++i) { if ((code = pthread_join(thr[i], NULL)) != 0) - { - perror("Thread join failed"); - fprintf(stderr, "Pthread_join returned %d, thread %d\n", code, i); - abort(); + { + perror("Thread join failed"); + fprintf(stderr, "Pthread_join returned %d, thread %d\n", code, i); + abort(); } } if (t()) @@ -103,7 +111,7 @@ void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name) int i; fprintf(stderr, "Testing %s\n", name); - if (nthreads > 100) + if (nthreads > 100) { fprintf(stderr, "run_parallel: requested too many threads\n"); taskSuspend(0); @@ -114,10 +122,10 @@ void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name) thr[i] = taskSpawn((char*) name, 180, 0, 32768, (FUNCPTR) f1, i, 1, 2, 3, 4, 5, 6, 7, 8, 9); if (thr[i] == ERROR) - { - fprintf(stderr, "taskSpawn failed with %d, thread %d\n", - errno, i); - taskSuspend(0); + { + fprintf(stderr, "taskSpawn failed with %d, thread %d\n", + errno, i); + taskSuspend(0); } } for (i = 0; i < nthreads; ++i) @@ -149,7 +157,7 @@ DWORD WINAPI tramp(LPVOID param) { struct tramp_args *args = (struct tramp_args *)param; - return (DWORD)(args -> fn)((LPVOID)(args -> arg)); + return (DWORD)(AO_PTRDIFF_T)(*args->fn)((LPVOID)(AO_PTRDIFF_T)args->arg); } void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name) @@ -160,7 +168,7 @@ void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name) DWORD code; fprintf(stderr, "Testing %s\n", name); - if (nthreads > 100) + if (nthreads > 100) { fprintf(stderr, "run_parallel: requested too many threads\n"); abort(); @@ -171,22 +179,22 @@ void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name) args[i].fn = f1; args[i].arg = i; if ((thr[i] = CreateThread(NULL, 0, tramp, (LPVOID)(args+i), 0, NULL)) - == NULL) - { - perror("Thread creation failed"); - fprintf(stderr, "CreateThread failed with %d, thread %d\n", - GetLastError(), i); - abort(); + == NULL) + { + perror("Thread creation failed"); + fprintf(stderr, "CreateThread failed with %lu, thread %d\n", + (unsigned long)GetLastError(), i); + abort(); } } for (i = 0; i < nthreads; ++i) { if ((code = WaitForSingleObject(thr[i], INFINITE)) != WAIT_OBJECT_0) - { - perror("Thread join failed"); - fprintf(stderr, "WaitForSingleObject returned %d, thread %d\n", - code, i); - abort(); + { + perror("Thread join failed"); + fprintf(stderr, "WaitForSingleObject returned %lu, thread %d\n", + (unsigned long)code, i); + abort(); } } if (t()) @@ -201,4 +209,3 @@ void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name) return 0; } #endif /* USE_WINTHREADS */ - 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; } diff --git a/tests/test_stack.c b/tests/test_stack.c index a51d244..9b2e7b2 100644 --- a/tests/test_stack.c +++ b/tests/test_stack.c @@ -16,6 +16,17 @@ # include "config.h" #endif +#if defined(__vxworks) || defined(_MSC_VER) || defined(_WIN32_WINCE) \ + || (defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)) + + /* Skip the test if no pthreads. */ + int main(void) + { + return 0; + } + +#else + #include #include #include @@ -239,3 +250,5 @@ int main(int argc, char **argv) # endif /* !NO_TIMES */ return 0; } + +#endif /* !_MSC_VER */