]> granicus.if.org Git - libatomic_ops/log
libatomic_ops
11 years agoRemove X_aligned_atomic_load_store headers and template
Ivan Maidanski [Sat, 5 Jan 2013 14:56:53 +0000 (18:56 +0400)]
Remove X_aligned_atomic_load_store headers and template
(code refactoring)

* src/Makefile.am (EXTRA_DIST): Remove
aligned_atomic_load_store.template entry.
* src/Makefile.am (BUILT_SOURCES, nobase_private_HEADERS): Remove
aligned_atomic_load_store.h, int_aligned_atomic_load_store.h,
short_aligned_atomic_load_store.h entries.
* src/Makefile.am
(atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.h,
atomic_ops/sysdeps/loadstore/int_aligned_atomic_load_store.h,
atomic_ops/sysdeps/loadstore/short_aligned_atomic_load_store.h):
Remove rules.
* src/atomic_ops/sysdeps/all_aligned_atomic_load_store.h: Refine
comment; include X_atomic_load_store.h instead of the corresponding
X_aligned_atomic_load_store.h file.
* src/atomic_ops/sysdeps/all_aligned_atomic_load_store.h
(AO_ACCESS_CHECK_ALIGNED, AO_ACCESS_short_CHECK_ALIGNED,
AO_ACCESS_int_CHECK_ALIGNED): New macros (defined before inclusion
of the corresponding X_atomic_load_store.h file).
* src/atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.h:
Remove.
* src/atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.template:
Likewise.
* src/atomic_ops/sysdeps/loadstore/int_aligned_atomic_load_store.h:
Likewise.
* src/atomic_ops/sysdeps/loadstore/short_aligned_atomic_load_store.h:
Likewise.
* src/atomic_ops/sysdeps/loadstore/atomic_load_store.template
(AO_XSIZE_load, AO_XSIZE_store): Add conditional assertion check of
(*addr) alignment (enabled only if AO_ACCESS_<XSIZE>_CHECK_ALIGNED).
* src/atomic_ops/sysdeps/loadstore/short_atomic_load_store.h:
Regenerate.
* src/atomic_ops/sysdeps/loadstore/int_atomic_load_store.h: Likewise.
* src/atomic_ops/sysdeps/loadstore/char_atomic_load_store.h: Likewise.
* src/atomic_ops/sysdeps/loadstore/atomic_load_store.h: Likewise.

11 years agoAdd missing 'const' in aligned-atomic AO_XSIZE_load implementation
Ivan Maidanski [Sat, 5 Jan 2013 09:43:57 +0000 (13:43 +0400)]
Add missing 'const' in aligned-atomic AO_XSIZE_load implementation

* src/atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.template
(AO_XSIZE_load): Add missing 'const' (when casting away volatile).
* src/atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.h:
Regenerate.
* src/atomic_ops/sysdeps/loadstore/int_aligned_atomic_load_store.h:
Likewise.
* src/atomic_ops/sysdeps/loadstore/short_aligned_atomic_load_store.h:
Likewise.

11 years agoGenerate 'loadstore' headers from templates
Ivan Maidanski [Fri, 4 Jan 2013 17:27:42 +0000 (21:27 +0400)]
Generate 'loadstore' headers from templates

* src/Makefile.am (EXTRA_DIST): Add acquire_release_volatile.template,
aligned_atomic_load_store.template, atomic_load_store.template
entires.
* src/Makefile.am (BUILT_SOURCES): Add acquire_release_volatile.h,
aligned_atomic_load_store.h, atomic_load_store.h,
char_acquire_release_volatile.h, char_atomic_load_store.h,
int_acquire_release_volatile.h, int_aligned_atomic_load_store.h,
int_atomic_load_store.h, short_acquire_release_volatile.h,
short_aligned_atomic_load_store.h, short_atomic_load_store.h entires.
* src/Makefile.am
(atomic_ops/sysdeps/loadstore/acquire_release_volatile.h,
atomic_ops/sysdeps/loadstore/char_acquire_release_volatile.h,
atomic_ops/sysdeps/loadstore/int_acquire_release_volatile.h,
atomic_ops/sysdeps/loadstore/short_acquire_release_volatile.h,
atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.h,
atomic_ops/sysdeps/loadstore/int_aligned_atomic_load_store.h,
atomic_ops/sysdeps/loadstore/short_aligned_atomic_load_store.h,
atomic_ops/sysdeps/loadstore/atomic_load_store.h,
atomic_ops/sysdeps/loadstore/char_atomic_load_store.h,
atomic_ops/sysdeps/loadstore/int_atomic_load_store.h,
atomic_ops/sysdeps/loadstore/short_atomic_load_store.h): New rules (to
generate header from the corresponding template).
* src/atomic_ops/sysdeps/loadstore/acquire_release_volatile.template:
New template header (code copied from the corresponding header of
"loadstore" folder and parameterized with XSIZE and XCTYPE); update
header comment.
* src/atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.template:
Likewise.
* src/atomic_ops/sysdeps/loadstore/atomic_load_store.template:
Likewise.
* src/atomic_ops/sysdeps/loadstore/acquire_release_volatile.template
(AO_GCC_BARRIER): Add TODO item.
* src/atomic_ops/sysdeps/loadstore/acquire_release_volatile.h:
Regenerate.
* src/atomic_ops/sysdeps/loadstore/char_acquire_release_volatile.h:
Likewise.
* src/atomic_ops/sysdeps/loadstore/int_acquire_release_volatile.h:
Likewise.
* src/atomic_ops/sysdeps/loadstore/short_acquire_release_volatile.h:
Likewise.
* src/atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.h:
Likewise.
* src/atomic_ops/sysdeps/loadstore/int_aligned_atomic_load_store.h:
Likewise.
* src/atomic_ops/sysdeps/loadstore/short_aligned_atomic_load_store.h:
Likewise.
* src/atomic_ops/sysdeps/loadstore/atomic_load_store.h: Likewise.
* src/atomic_ops/sysdeps/loadstore/char_atomic_load_store.h: Likewise.
* src/atomic_ops/sysdeps/loadstore/int_atomic_load_store.h: Likewise.
* src/atomic_ops/sysdeps/loadstore/short_atomic_load_store.h:
Likewise.

11 years agoGroup all X_acquire_release_volatile.h and X_[aligned_]atomic_load_store.h
Ivan Maidanski [Fri, 4 Jan 2013 11:49:45 +0000 (15:49 +0400)]
Group all X_acquire_release_volatile.h and X_[aligned_]atomic_load_store.h
in separate folder

* src/Makefile.am (nobase_private_HEADERS): Update path to
acquire_release_volatile.h, aligned_atomic_load_store.h,
atomic_load_store.h, char_acquire_release_volatile.h,
char_atomic_load_store.h, int_acquire_release_volatile.h,
int_aligned_atomic_load_store.h, int_atomic_load_store.h,
short_acquire_release_volatile.h, short_aligned_atomic_load_store.h,
short_atomic_load_store.h entries (add "loadstore" to prefix).
* src/atomic_ops/sysdeps/all_acquire_release_volatile.h: Likewise.
* src/atomic_ops/sysdeps/all_aligned_atomic_load_store.h: Likewise.
* src/atomic_ops/sysdeps/all_atomic_load_store.h: Likewise.
* src/atomic_ops/sysdeps/gcc/alpha.h: Likewise.
* src/atomic_ops/sysdeps/gcc/mips.h: Likewise.
* src/atomic_ops/sysdeps/hpc/hppa.h: Likewise.
* src/atomic_ops/sysdeps/acquire_release_volatile.h: Move file to
src/atomic_ops/sysdeps/loadstore folder.
* src/atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.h:
Likewise.
* src/atomic_ops/sysdeps/loadstore/atomic_load_store.h: Likewise.
* src/atomic_ops/sysdeps/loadstore/char_acquire_release_volatile.h:
Likewise.
* src/atomic_ops/sysdeps/loadstore/char_atomic_load_store.h: Likewise.
* src/atomic_ops/sysdeps/loadstore/int_acquire_release_volatile.h:
Likewise.
* src/atomic_ops/sysdeps/loadstore/int_aligned_atomic_load_store.h:
Likewise.
* src/atomic_ops/sysdeps/loadstore/int_atomic_load_store.h: Likewise.
* src/atomic_ops/sysdeps/loadstore/short_acquire_release_volatile.h:
Likewise.
* src/atomic_ops/sysdeps/loadstore/short_aligned_atomic_load_store.h:
Likewise.
* src/atomic_ops/sysdeps/loadstore/short_atomic_load_store.h:
Likewise.
* src/atomic_ops/sysdeps/all_acquire_release_volatile.h: Reformat
comment.
* src/atomic_ops/sysdeps/all_aligned_atomic_load_store.h: Likewise.
* src/atomic_ops/sysdeps/all_atomic_load_store.h: Likewise.

11 years agoFix template-based headers regeneration order in src/Makefile
Ivan Maidanski [Fri, 4 Jan 2013 19:28:42 +0000 (23:28 +0400)]
Fix template-based headers regeneration order in src/Makefile

* src/Makefile.am (BUILT_SOURCES): Define to force regeneration
of generalize-arithm.h, generalize-small.h (if the corresponding
source template is changed) before compilation of .c files (that use
atomic_ops.h).

11 years agoAdd AO_load primitives generalization based on CAS
Ivan Maidanski [Thu, 3 Jan 2013 20:09:50 +0000 (00:09 +0400)]
Add AO_load primitives generalization based on CAS

* src/atomic_ops/generalize-small.template (AO_XSIZE_load_acquire,
AO_XSIZE_load, AO_XSIZE_load_read, AO_XSIZE_load_acquire_read,
AO_XSIZE_load_full, AO_XSIZE_load_dd_acquire_read,
AO_XSIZE_store_release, AO_XSIZE_store, AO_XSIZE_store_write,
AO_XSIZE_store_release_write, AO_XSIZE_store_full): Move primitive
down to be after CAS defintion section.
* src/atomic_ops/generalize-small.template (AO_XSIZE_load_read,
AO_XSIZE_load_full, AO_XSIZE_load_acquire, AO_XSIZE_load): Add
generalization template primitive based on CAS.
* src/atomic_ops/generalize-small.h: Regenerate.

11 years agoEnable generalization of all variants of CAS via fetch_compare_and_swap
Ivan Maidanski [Thu, 3 Jan 2013 15:18:11 +0000 (19:18 +0400)]
Enable generalization of all variants of CAS via fetch_compare_and_swap

* src/atomic_ops/generalize.h (AO_compare_and_swap_full,
AO_compare_and_swap_acquire, AO_compare_and_swap_release,
AO_compare_and_swap, AO_TS_COMPARE_AND_SWAP_FULL,
AO_TS_COMPARE_AND_SWAP_ACQUIRE, AO_TS_COMPARE_AND_SWAP_RELEASE,
AO_TS_COMPARE_AND_SWAP): Define (in this file) only if required for
AO_test_and_set_X generalization.
* src/atomic_ops/generalize-arithm.template
(AO_XSIZE_compare_and_swap_write, AO_XSIZE_compare_and_swap_read,
AO_XSIZE_compare_and_swap_release_write,
AO_XSIZE_compare_and_swap_acquire_read,
AO_XSIZE_compare_and_swap_dd_acquire_read): Add missing variant of
generalized template CAS primitives based fetch_compare_and_swap; add
the corresponding AO_HAVE_XSIZE_compare_and_swap_X macros.
* src/atomic_ops/generalize-arithm.h: Regenerate.

11 years agoMove generalized arithmetical primitives to 'generalize-arithm' template
Ivan Maidanski [Thu, 3 Jan 2013 11:57:35 +0000 (15:57 +0400)]
Move generalized arithmetical primitives to 'generalize-arithm' template
(code refactoring)

* src/Makefile.am (EXTRA_DIST): Add generalize-arithm.template.
* src/Makefile.am (nobase_private_HEADERS): Add generalize-arithm.h.
* src/Makefile.am (atomic_ops/generalize-arithm.h): New rule (similar
as generalize-small.h but using generalize-arithm.template).
* src/atomic_ops/generalize-arithm.template: New file.
* src/atomic_ops/generalize-small.template: Move compare_and_swap
(only which is based on fetch_compare_and_swap), fetch_and_add,
fetch_and_add, fetch_and_add1, fetch_and_sub1, and/or/xor template
primitives to generalize-arithm.template).
* src/atomic_ops/generalize-arithm.h: Regenerate (new file).
* src/atomic_ops/generalize-small.h: Regenerate.
* src/atomic_ops/generalize.h: Include generalize-arithm.h (just after
inclusion of generalize-small.h).

11 years agoRemote duplicate definition of test_and_set_acquire in generalize.h
Ivan Maidanski [Wed, 2 Jan 2013 21:02:08 +0000 (01:02 +0400)]
Remote duplicate definition of test_and_set_acquire in generalize.h

* src/atomic_ops/generalize.h (AO_test_and_set_acquire): Remove
redundant (duplicate) definition.

11 years agoAdd generalized CAS primitives of char/short/int size
Ivan Maidanski [Wed, 2 Jan 2013 20:30:33 +0000 (00:30 +0400)]
Add generalized CAS primitives of char/short/int size

* src/atomic_ops/generalize-small.template
(AO_XSIZE_fetch_compare_and_swap_acquire,
AO_XSIZE_fetch_compare_and_swap_release,
AO_XSIZE_fetch_compare_and_swap_write,
AO_XSIZE_fetch_compare_and_swap_read, AO_XSIZE_fetch_compare_and_swap,
AO_XSIZE_fetch_compare_and_swap_full,
AO_XSIZE_fetch_compare_and_swap_release_write,
AO_XSIZE_fetch_compare_and_swap_acquire_read,
AO_XSIZE_fetch_compare_and_swap_dd_acquire_read,
AO_XSIZE_compare_and_swap_acquire, AO_XSIZE_compare_and_swap_release,
AO_XSIZE_compare_and_swap_write, AO_XSIZE_compare_and_swap_read,
AO_XSIZE_compare_and_swap, AO_XSIZE_compare_and_swap_full,
AO_XSIZE_compare_and_swap_release_write,
AO_XSIZE_compare_and_swap_acquire_read,
AO_XSIZE_compare_and_swap_dd_acquire_read): New template primitive
(code copied from generalize.h for AO_t); define the corresponding
AO_HAVE_XSIZE_x.
* src/atomic_ops/generalize-small.h: Regenerate.
* src/atomic_ops/generalize.h (AO_compare_and_swap_acquire,
AO_compare_and_swap_release, AO_compare_and_swap_write,
AO_compare_and_swap_read, AO_compare_and_swap,
AO_compare_and_swap_full, AO_compare_and_swap_release_write,
AO_compare_and_swap_acquire_read, AO_compare_and_swap_dd_acquire_read,
AO_fetch_compare_and_swap_acquire, AO_fetch_compare_and_swap_release,
AO_fetch_compare_and_swap_write, AO_fetch_compare_and_swap_read,
AO_fetch_compare_and_swap, AO_fetch_compare_and_swap_full,
AO_fetch_compare_and_swap_release_write,
AO_fetch_compare_and_swap_acquire_read,
AO_fetch_compare_and_swap_dd_acquire_read): Remove (since present in
the auto-generated generalize-small.h) together with the corresponding
AO_HAVE_x.

11 years agoAdd generalized atomic and/or/xor operations for char/short/int types
Ivan Maidanski [Wed, 2 Jan 2013 18:22:17 +0000 (22:22 +0400)]
Add generalized atomic and/or/xor operations for char/short/int types

* src/atomic_ops/generalize-small.template (AO_XSIZE_and_full,
AO_XSIZE_and_release, AO_XSIZE_and_acquire, AO_XSIZE_and_write,
AO_XSIZE_and_read, AO_XSIZE_and, AO_XSIZE_and_release_write,
AO_XSIZE_and_acquire_read, AO_XSIZE_or_full, AO_XSIZE_or_release,
AO_XSIZE_or_acquire, AO_XSIZE_or_write, AO_XSIZE_or_read,
AO_XSIZE_or, AO_XSIZE_or_release_write, AO_XSIZE_or_acquire_read,
AO_XSIZE_xor_full, AO_XSIZE_xor_release, AO_XSIZE_xor_acquire,
AO_XSIZE_xor_write, AO_XSIZE_xor_read, AO_XSIZE_xor,
AO_XSIZE_xor_release_write, AO_XSIZE_xor_acquire_read): New template
primitive (code copied from generalize.h for AO_t); define the
corresponding AO_HAVE_x.
* src/atomic_ops/generalize-small.h: Regenerate.
* src/atomic_ops/generalize.h (AO_and_full, AO_and_release,
AO_and_acquire, AO_and_write, AO_and_read, AO_and,
AO_and_release_write, AO_and_acquire_read, AO_or_full,
AO_or_release, AO_or_acquire, AO_or_write, AO_or_read, AO_xor,
AO_or_release_write, AO_or_acquire_read, AO_xor_full, AO_xor_release,
AO_xor_acquire, AO_xor_write, AO_xor_read, AO_xor,
AO_xor_release_write, AO_xor_acquire_read): Remove (since present in
the autogenerated generalize-small.h) together with the corresponding
AO_HAVE_x.
* src/atomic_ops/sysdeps/generic_pthread.h (AO_char_and_full,
AO_char_or_full, AO_char_xor_full, AO_short_and_full,
AO_short_or_full, AO_short_xor_full, AO_int_and_full, AO_int_or_full,
AO_int_xor_full): Implement primitive (and define the corresponding
AO_HAVE_x).

11 years agoAdd lock-based implementation of char/short/int_fetch_compare_and_swap
Ivan Maidanski [Wed, 2 Jan 2013 14:34:00 +0000 (18:34 +0400)]
Add lock-based implementation of char/short/int_fetch_compare_and_swap

* src/atomic_ops/sysdeps/generic_pthread.h
(AO_char_fetch_compare_and_swap_full,
AO_short_fetch_compare_and_swap_full,
AO_int_fetch_compare_and_swap_full): Implement primitives.

11 years agoGenerate generalized AO_t load/store/fetch_and_add primitives from template
Ivan Maidanski [Wed, 2 Jan 2013 13:51:04 +0000 (17:51 +0400)]
Generate generalized AO_t load/store/fetch_and_add primitives from template
(code refactoring)

* src/Makefile.am (atomic_ops/generalize-small.h): Append
generalize-small.template to generalize-small.h replacing XCTYPE with
AO_t (and "XSIZE_" with empty sequence).
* src/atomic_ops/generalize-small.h: Regenerate.
* src/atomic_ops/generalize.h (AO_load_acquire, AO_load, AO_load_read,
AO_load_acquire_read, AO_load_full, AO_load_dd_acquire_read,
AO_store_release, AO_store, AO_store_write, AO_store_release_write,
AO_store_full, AO_fetch_and_add_full, AO_fetch_and_add_acquire,
AO_fetch_and_add_release, AO_fetch_and_add, AO_fetch_and_add_write,
AO_fetch_and_add_read, AO_fetch_and_add_release_write,
AO_fetch_and_add_acquire_read, AO_fetch_and_add_dd_acquire_read,
AO_fetch_and_add1_full, AO_fetch_and_add1_release,
AO_fetch_and_add1_acquire, AO_fetch_and_add1_write,
AO_fetch_and_add1_read, AO_fetch_and_add1_release_write,
AO_fetch_and_add1_acquire_read, AO_fetch_and_add1,
AO_fetch_and_add1_dd_acquire_read, AO_fetch_and_sub1_full,
AO_fetch_and_sub1_release, AO_fetch_and_sub1_acquire,
AO_fetch_and_sub1_write, AO_fetch_and_sub1_read,
AO_fetch_and_sub1_release_write, AO_fetch_and_sub1_acquire_read,
AO_fetch_and_sub1, AO_fetch_and_sub1_dd_acquire_read): Remove
generalized primitives (and the corresponding AO_HAVE_x macros) that
exist in auto-generated generalize-small.h file.

11 years agoAdd missing generalization of no-barrier CAS in template
Ivan Maidanski [Wed, 2 Jan 2013 09:40:21 +0000 (13:40 +0400)]
Add missing generalization of no-barrier CAS in template

* src/atomic_ops/generalize-small.template
(AO_XSIZE_compare_and_swap): Add missed definition (based on
AO_XSIZE_fetch_compare_and_swap).
* src/atomic_ops/generalize-small.template
(AO_XSIZE_fetch_and_add_full): Add comment (copy from generalize.h).
* src/atomic_ops/generalize-small.h: Regenerate.

11 years agoMove 'unsigned' keyword to XCTYPE in generalize-small template
Ivan Maidanski [Tue, 1 Jan 2013 16:26:28 +0000 (20:26 +0400)]
Move 'unsigned' keyword to XCTYPE in generalize-small template
(code refactoring)

* src/Makefile.am (atomic_ops/generalize-small.h): Add trailing '_'
to XSIZE and to its replacement; add "unsigned" prefix to the types
replacing XCTYPE (using empty comment as a delimiter between
"unsigned" keyword and char/short).
* src/atomic_ops/generalize-small.template: Remove "unsigned" keyword
at every XCTYPE.
* src/atomic_ops/generalize-small.h: Regenerate.

11 years agoFix generalize-small template adding missed CAS-based fetch_and_add
Ivan Maidanski [Wed, 2 Jan 2013 09:10:34 +0000 (13:10 +0400)]
Fix generalize-small template adding missed CAS-based fetch_and_add

* src/atomic_ops/generalize-small.template (AO_XSIZE_fetch_and_add):
Add missed definition based on CAS.
* src/atomic_ops/generalize-small.h: Regenerate.

11 years agoFix AO_XSIZE_load/store definition order in generalize-small template
Ivan Maidanski [Wed, 2 Jan 2013 08:31:08 +0000 (12:31 +0400)]
Fix AO_XSIZE_load/store definition order in generalize-small template

* src/atomic_ops/generalize-small.template (AO_XSIZE_load): Move
definition (which is based on AO_XSIZE_load_acquire) down to be after
AO_XSIZE_load_acquire definition.
* src/atomic_ops/generalize-small.template (AO_XSIZE_store): Move
definition (which is based on AO_XSIZE_store_release) down to be after
AO_XSIZE_store_release definition.
* src/atomic_ops/generalize-small.h : Regenerate.

11 years agoUse AO_ prefix for internal functions in arm_v6.h
Ivan Maidanski [Sun, 16 Dec 2012 16:07:02 +0000 (20:07 +0400)]
Use AO_ prefix for internal functions in arm_v6.h
(code refactoring)

* src/atomic_ops/sysdeps/armcc/arm_v6.h (AO_fetch_and_add,
AO_fetch_and_add1, AO_fetch_and_sub1, AO_compare_and_swap): Remove
useless comment.
* src/atomic_ops/sysdeps/armcc/arm_v6.h (load_ex, store_ex): Add
"AO_" prefix.

12 years agoUpdate TODO (add more targets with test_stack failure)
Ivan Maidanski [Sat, 15 Dec 2012 09:26:16 +0000 (13:26 +0400)]
Update TODO (add more targets with test_stack failure)

12 years agoUse AO_ prefix for inner routines in hppa.h; define AO_ldcw_align inner
Ivan Maidanski [Sat, 15 Dec 2012 09:09:45 +0000 (13:09 +0400)]
Use AO_ prefix for inner routines in hppa.h; define AO_ldcw_align inner
macro as expressions instead of block statement (code refactoring)

* src/atomic_ops/sysdeps/gcc/hppa.h (__ldcw, __PA_LDCW_ALIGNMENT,
__ldcw_align): Add "AO" prefix.
* src/atomic_ops/sysdeps/hpc/hppa.h (__ldcw, __PA_LDCW_ALIGNMENT,
__ldcw_align): Likewise.
* src/atomic_ops/sysdeps/gcc/hppa.h (AO_ldcw): Pass "ret" variable
name as macro argument instead of returning value; remove "{", "}"
braces.
* src/atomic_ops/sysdeps/gcc/hppa.h (AO_ldcw_align): Rename "a"
argument to "addr"; convert macro body from block statement to
expression.
* src/atomic_ops/sysdeps/hpc/hppa.h (AO_ldcw_align): Likewise.
* src/atomic_ops/sysdeps/gcc/hppa.h (AO_test_and_set_full): Declare
"ret" local volatile varible, pass it to AO_ldcw and return.
* src/atomic_ops/sysdeps/gcc/hppa.h (AO_test_and_set_full): Cast
result to AO_TS_VAL_t.
* src/atomic_ops/sysdeps/hpc/hppa.h (AO_test_and_set_full): Likewise.
* src/atomic_ops/sysdeps/hpc/hppa.h (AO_ldcw): Remove redundant
trailing ';' symbol.
* src/atomic_ops/sysdeps/hpc/hppa.h (AO_ldcw_align): Remove "ret"
argument, pass returned value as expression result instead; cast
returned value to "volatile unsigned *" type.
* src/atomic_ops/sysdeps/hpc/hppa.h (AO_pa_clear): Change "a" local
variable type from "unsigned long" to "volatile unsigned *" (matching
AO_ldcw_align returned value type).

12 years agoAdd missing parentheses to GC_MMAP_FLAGS in atomic_ops_malloc
Ivan Maidanski [Sat, 15 Dec 2012 08:24:24 +0000 (12:24 +0400)]
Add missing parentheses to GC_MMAP_FLAGS in atomic_ops_malloc

* src/atomic_ops_malloc.c (GC_MMAP_FLAGS): Add missing outermost
parentheses.

12 years agoImprove debug printing in test_stack
Thorsten Glaser [Sun, 9 Dec 2012 06:29:54 +0000 (10:29 +0400)]
Improve debug printing in test_stack

* tests/test_stack.c (main): Add debug printing of exper_n, nthreads,
max_nthreads and list_length before add_elements call (if VERBOSE).

12 years agoUpdate TODO file (remove gcc/alpha bug)
Ivan Maidanski [Fri, 9 Nov 2012 05:15:05 +0000 (09:15 +0400)]
Update TODO file (remove gcc/alpha bug)

12 years agoFix AO_stack_pop_explicit_aux_acquire for gcc-4.6.3/alpha
Ivan Maidanski [Fri, 9 Nov 2012 04:36:28 +0000 (08:36 +0400)]
Fix AO_stack_pop_explicit_aux_acquire for gcc-4.6.3/alpha

* src/atomic_ops_stack.c (AO_stack_pop_explicit_aux_acquire): Do not
use AO_EXPECT_FALSE for gcc-4/alpha (to workaround GCC v4.6.3 bug
causing test_stack failure).

12 years agoAdjust fprintf arguments type matching format specifier in test_stack
Ivan Maidanski [Tue, 23 Oct 2012 03:33:34 +0000 (07:33 +0400)]
Adjust fprintf arguments type matching format specifier in test_stack

* tests/test_stack.c (main): Cast "code" argument of fprintf calls to
unsigned int to match printf format specifier.

12 years agoAdd comment to AO_nop_write in ordered_except_wr.h
Ivan Maidanski [Tue, 23 Oct 2012 03:23:39 +0000 (07:23 +0400)]
Add comment to AO_nop_write in ordered_except_wr.h

* src/atomic_ops/sysdeps/ordered_except_wr.h (AO_nop_write): Add
comment (to outline that the implementation matches that of
AO_nop_read).

12 years agoSpecify AO_fetch_and_add/sub1 result is unused in test_atomic
Ivan Maidanski [Thu, 18 Oct 2012 15:53:34 +0000 (19:53 +0400)]
Specify AO_fetch_and_add/sub1 result is unused in test_atomic

* tests/test_atomic.c (add1sub1_thr): Explicitly cast result of
AO_fetch_and_sub1 and AO_fetch_and_add1 to void (to outline that the
result is unused intentionally); reformat code.

12 years agoUpdate ChangeLog file
Ivan Maidanski [Tue, 9 Oct 2012 07:44:04 +0000 (11:44 +0400)]
Update ChangeLog file

12 years agoReorder AO_double_t union elements for AO_DOUBLE_T_INITIALIZER portability
Ivan Maidanski [Tue, 9 Oct 2012 06:30:28 +0000 (10:30 +0400)]
Reorder AO_double_t union elements for AO_DOUBLE_T_INITIALIZER portability

* src/atomic_ops/sysdeps/standard_ao_double_t.h (AO_double_t):
Make "AO_parts" element to be the first one in the enum so that
AO_DOUBLE_T_INITIALIZER could be defined both strictly complying with
ANSI C standard (thus preventing "missing braces around initializer"
64-bit compiler warning) and independently of __m128 type definition;
add comment.
* src/atomic_ops/sysdeps/standard_ao_double_t.h
(AO_DOUBLE_T_INITIALIZER): Update to reflect the change in AO_double_t.

12 years agoEliminate warning for fetch_and_add argument in test_atomic_include
Ivan Maidanski [Mon, 8 Oct 2012 20:14:46 +0000 (00:14 +0400)]
Eliminate warning for fetch_and_add argument in test_atomic_include

* tests/test_atomic_include.template (test_atomicXX): Cast negative
"incr" argument (passed to fetch_and_add) to the unsigned proper type
(to eliminate MS VC compiler "signed/unsigned mismatch" warning).

12 years agoFix variable type to match printf format specifier in test_stack
Ivan Maidanski [Mon, 8 Oct 2012 20:06:19 +0000 (00:06 +0400)]
Fix variable type to match printf format specifier in test_stack

* tests/test_stack.c (run_one_test): Change type of "index" local
variable from long to int to match printf format specifier (when
VERBOSE defined); cast from "arg" pointer to integer via size_t (to
avoid 64-bit compiler warning).

12 years agoMerge branch 'fix-double-cas-x32'
Ivan Maidanski [Mon, 8 Oct 2012 17:02:54 +0000 (21:02 +0400)]
Merge branch 'fix-double-cas-x32'

12 years agoUpdate TODO file (add item regarding __sync intrinsic)
Ivan Maidanski [Mon, 8 Oct 2012 14:23:19 +0000 (18:23 +0400)]
Update TODO file (add item regarding __sync intrinsic)

12 years agoUse built-in __sync CAS for double-CAS if AO_USE_SYNC_CAS_BUILTIN for x86
Ivan Maidanski [Mon, 8 Oct 2012 14:09:40 +0000 (18:09 +0400)]
Use built-in __sync CAS for double-CAS if AO_USE_SYNC_CAS_BUILTIN for x86

* src/atomic_ops/sysdeps/gcc/x86.h
(AO_compare_double_and_swap_double_full): Do not define if
AO_USE_SYNC_CAS_BUILTIN, define AO_double_compare_and_swap_full
(based on __sync_bool_compare_and_swap) instead (for x86).

12 years agoRemove gcc/x86_64.h to eliminate gcc/x86.h code duplication
Ivan Maidanski [Mon, 8 Oct 2012 11:45:30 +0000 (15:45 +0400)]
Remove gcc/x86_64.h to eliminate gcc/x86.h code duplication

* src/Makefile.am (nobase_private_HEADERS): Remove reference to
gcc/x86_64.h.
* src/atomic_ops.h: Include gcc/x86.h both for x86 and x86_64 (if
__sun defined but not GCC); do not define AO_USE_PENTIUM4_INSTRS;
do not test __ILP32__ here.
* src/atomic_ops/sysdeps/gcc/x86.h: Include standard_ao_double_t.h
only if AO_compare_double_and_swap_double_full (or
AO_double_compare_and_swap_full) defined.
* src/atomic_ops/sysdeps/gcc/x86.h (AO_USE_PENTIUM4_INSTRS):
Explicitly define for x86_64 chips.
* src/atomic_ops/sysdeps/gcc/x86.h (AO_fetch_and_add_full,
AO_and_full, AO_or_full, AO_xor_full, AO_compare_and_swap_full,
AO_fetch_compare_and_swap_full): Remove "l" suffix (the size is
properly determined by operands).
* src/atomic_ops/sysdeps/gcc/x86.h (AO_double_compare_and_swap_full,
AO_HAVE_double_compare_and_swap_full): Define only if __ILP32__.
* src/atomic_ops/sysdeps/gcc/x86.h (AO_T_IS_INT): Define only for
32-bit mode.
* src/atomic_ops/sysdeps/gcc/x86.h (AO_int_fetch_and_add_full,
AO_HAVE_int_fetch_and_add_full,
AO_compare_double_and_swap_double_full): Move definition from
gcc/x86_64.h; define only for true 64-bit mode.
* src/atomic_ops/sysdeps/gcc/x86_64.h: Delete this file.
* src/atomic_ops/sysdeps/msftc/x86_64.h
(AO_compare_double_and_swap_double_full): Update comment.

12 years agoRemove generalized compare_double_and_swap_double from gcc/x86.h
Ivan Maidanski [Mon, 8 Oct 2012 11:04:01 +0000 (15:04 +0400)]
Remove generalized compare_double_and_swap_double from gcc/x86.h

* src/atomic_ops/sysdeps/gcc/x86.h
(AO_compare_double_and_swap_double_full,
AO_HAVE_compare_double_and_swap_double_full): Remove already defined
in generalize.h file; remove TODO item.

12 years agoProperly fix compare_double_and_swap_double for gcc/x32 (use built-in CAS)
Ivan Maidanski [Mon, 8 Oct 2012 10:51:30 +0000 (14:51 +0400)]
Properly fix compare_double_and_swap_double for gcc/x32 (use built-in CAS)

* src/atomic_ops/sysdeps/gcc/x86.h (AO_double_compare_and_swap_full):
New function (only if __x86_64__) implemented using GCC built-in
__sync CAS primitive available for x32.
* src/atomic_ops/sysdeps/gcc/x86.h
(AO_HAVE_double_compare_and_swap_full): New macro (for x32 only).
* src/atomic_ops/sysdeps/gcc/x86.h
(AO_compare_double_and_swap_double_full): Implement using
double_compare_and_swap_full instead of cmpxchg8b for x32 (since
x86_64 has available cmpxchg and cmpxchg16b but not cmpxchg8b).

12 years agoFix double_ptr_storage definition for gcc/x32
Ivan Maidanski [Mon, 1 Oct 2012 10:48:43 +0000 (14:48 +0400)]
Fix double_ptr_storage definition for gcc/x32

* src/atomic_ops/sysdeps/standard_ao_double_t.h (double_ptr_storage):
Define as "unsigned long long" instead of __m128 for gcc/x32 (i.e.,
ILP32 on x86_64); update and reformat comment.

12 years agoFix compare_double_and_swap_double_full for gcc/x32
Ivan Maidanski [Tue, 18 Sep 2012 16:48:08 +0000 (20:48 +0400)]
Fix compare_double_and_swap_double_full for gcc/x32

* src/atomic_ops.h: Include gcc/x86.h instead of gcc/x86_64.h if
gcc/x32 (i.e., GCC (or Intel compiler), __x86_64__ is defined, and
__ILP32__ is defined) to have AO_compare_double_and_swap_double_full
defined properly (based on cmpxchg8b); explicitly define
AO_USE_PENTIUM4_INSTRS for gcc/x32.
* src/atomic_ops/sysdeps/gcc/x86_64.h: Remove ILP32-specific code
(AO_T_IS_INT definition).

12 years agoImplement char/short/int_fetch_and_add for msftc/x86[_64] (Win32)
Ivan Maidanski [Mon, 8 Oct 2012 09:33:30 +0000 (13:33 +0400)]
Implement char/short/int_fetch_and_add for msftc/x86[_64] (Win32)

* src/atomic_ops/sysdeps/msftc/x86.h (AO_NO_ASM_XADD): Recognize new
macro.
* src/atomic_ops/sysdeps/msftc/x86.h (AO_char_fetch_and_add_full,
AO_short_fetch_and_add_full): New primitive implemented using __asm
(only unless AO_NO_ASM_XADD).
* src/atomic_ops/sysdeps/msftc/x86.h (AO_HAVE_char_fetch_and_add_full,
AO_HAVE_short_fetch_and_add_full): New macro (accompanying the
corresponding primitive).
* src/atomic_ops/sysdeps/msftc/x86_64.h
(AO_HAVE_int_fetch_and_add_full, AO_HAVE_char_fetch_and_add_full,
AO_HAVE_short_fetch_and_add_full): Likewise.
* src/atomic_ops/sysdeps/msftc/x86_64.h (_InterlockedExchangeAdd): Add
pragma to specify the intrinsic.
* src/atomic_ops/sysdeps/msftc/x86_64.h (AO_int_fetch_and_add_full):
New primitive (implemented using 32-bit InterlockedExchangeAdd).
* src/atomic_ops/sysdeps/msftc/x86_64.h  (AO_char_fetch_and_add_full,
AO_short_fetch_and_add_full): New primitive implemented using 64-bit
__asm (only if AO_ASM_X64_AVAILABLE).

12 years agoMake AO_ASSUME_VISTA also enables Win98 code in msftc/x86.h (Win32)
Ivan Maidanski [Mon, 8 Oct 2012 09:21:11 +0000 (13:21 +0400)]
Make AO_ASSUME_VISTA also enables Win98 code in msftc/x86.h (Win32)

* src/atomic_ops/sysdeps/msftc/x86.h (AO_ASSUME_WINDOWS98): Explicitly
define if AO_ASSUME_VISTA.

12 years agoAdjust quotes in echo command of Makefile.msft (Win32)
Ivan Maidanski [Mon, 8 Oct 2012 09:08:19 +0000 (13:08 +0400)]
Adjust quotes in echo command of Makefile.msft (Win32)

* src/Makefile.msft (check): Use '@' for "echo" command (not to print
the echo command itself); put echo messages into double quotes;
replace incorrectly escaped double quotes (inside echo messages) with
single quotes.

12 years agoEnable Makefile.msft for Win64
Ivan Maidanski [Mon, 8 Oct 2012 08:15:48 +0000 (12:15 +0400)]
Enable Makefile.msft for Win64

* src/Makefile.msft (libatomic_ops_gpl.lib): Do not pass
"/MACHINE:i386" option to "lib" tool (to select the proper target
architecture automatically).

12 years agoAdd test_stack to Makefile.msft
Ivan Maidanski [Mon, 8 Oct 2012 07:19:55 +0000 (11:19 +0400)]
Add test_stack to Makefile.msft

* src/Makefile.msft (test_stack): New compile target.
* src/Makefile.msft (check): Add test_stack to dependencies and
execution lists.

12 years agoMove default compiler options to CFLAGS in Makefile.msft
Ivan Maidanski [Mon, 8 Oct 2012 07:04:41 +0000 (11:04 +0400)]
Move default compiler options to CFLAGS in Makefile.msft

* src/Makefile.msft (CFLAGS): New script variable (containing default
compiler options).
* src/Makefile.msft (atomic_ops.obj, atomic_ops_stack.obj,
atomic_ops_malloc.obj, test_atomic, test_malloc): Use CFLAGS.
* src/Makefile.msft (test_malloc): Remove unnecessary
test_atomic_include.h from dependencies list.

12 years agoEnable test_stack for Win32 (with native threads)
Ivan Maidanski [Sun, 7 Oct 2012 21:00:08 +0000 (01:00 +0400)]
Enable test_stack for Win32 (with native threads)

* tests/test_stack.c (main): Do not skip for Win32 (i.e., skip test
only on VxWorks).
* tests/test_stack.c (USE_WINTHREADS): Define new macro for Win32 but
not Cygwin or pthreads-w32.
* tests/test_stack.c: Include windows.h (instead of pthread.h) if
USE_WINTHREADS.
* tests/test_stack.c: Include sys/timeb.h (instead of
[sys/]time.h) if USE_WINTHREADS or  AO_USE_WIN32_PTHREADS.
* tests/test_stack.c (get_msecs): Implement for Win32 (except for
Cygwin) using ftime() (unless NO_TIME).
* tests/test_stack.c (run_one_test): Use DWORD return type and WINAPI
calling conventions if USE_WINTHREADS.
* tests/test_stack.c (main): Declare "thread_id" local variable if
USE_WINTHREADS; declare threads[] local variable of HANDLE type
(instead of pthread_t) if USE_WINTHREADS; use CreateThread/GetLastError
and WaitForSingleObject (instead of pthread_create and pthread_join)
if USE_WINTHREADS; cast between integer value and pointer (passed to
pthread_create) via size_t.
* tests/test_stack.c (main): Print pushes/pops/threads summary even if
NO_TIMES.

12 years agoAdd information about AO_ASSUME_VISTA to README_win32
Ivan Maidanski [Sun, 7 Oct 2012 13:34:35 +0000 (17:34 +0400)]
Add information about AO_ASSUME_VISTA to README_win32

* doc/README_win32.txt (AO_ASSUME_VISTA): Document.

12 years agoFix Makefile.msft, README_win32 after AO_pause removal in atomic_ops_stack
Ivan Maidanski [Sun, 7 Oct 2012 13:29:44 +0000 (17:29 +0400)]
Fix Makefile.msft, README_win32 after AO_pause removal in atomic_ops_stack
(fix commit 'a5a424e')

* doc/README_win32.txt: Update description of libatomic_ops_gpl.lib
contents.
* src/Makefile.msft: Update header comment.
* src/Makefile.msft (LIB_OBJS): Add atomic_ops.obj entry.
* src/Makefile.msft (atomic_ops.obj): Add rule to build atomic_ops.

12 years agoEliminate 64-bit compiler warnings in atomic_ops_malloc
Ivan Maidanski [Sun, 7 Oct 2012 13:06:15 +0000 (17:06 +0400)]
Eliminate 64-bit compiler warnings in atomic_ops_malloc

* src/atomic_ops_malloc.c (add_chunk_as): Cast shifted value to size_t
(the type of assigned variable, at least to eliminate compiler warning
for 64-bit targets).
* src/atomic_ops_malloc.c (AO_free): Cast (*base) to int (the type of
assigned variable) to eliminate MS VC compiler warning.

12 years agoFix double old/new_w local variables declaration in test_atomic_include
Ivan Maidanski [Sun, 7 Oct 2012 12:54:02 +0000 (16:54 +0400)]
Fix double old/new_w local variables declaration in test_atomic_include

* tests/test_atomic_include.template (test_atomicXX): Move old_w and
new_w local variables declaration up to precede the first statement
(only if AO_HAVE_double_compare_and_swapXX).

12 years agoDefine AO_int_X operations for ARM and avr32
Ivan Maidanski [Sat, 6 Oct 2012 17:32:40 +0000 (21:32 +0400)]
Define AO_int_X operations for ARM and avr32

* src/atomic_ops/sysdeps/armcc/arm_v6.h (AO_T_IS_INT): Define macro
(signifying that AO_t is in fact int and, thus, defining AO_int_...
primitives).
* src/atomic_ops/sysdeps/gcc/arm.h b/src/atomic_ops/sysdeps/gcc/arm.h
(AO_T_IS_INT): Likewise.
* src/atomic_ops/sysdeps/gcc/avr32.h (AO_T_IS_INT): Likewise.
* src/atomic_ops/sysdeps/msftc/arm.h (AO_T_IS_INT): Likewise.
* src/atomic_ops/sysdeps/gcc/arm.h (AO_T_IS_INT): Add FIXME
(AO_T_IS_INT should be defined conditionally on adding 64-bit ABI
support).
* src/atomic_ops/sysdeps/gcc/mips.h (AO_T_IS_INT): Likewise.

12 years agoGeneralize compare_double_and_swap_double using double_compare_and_swap
Ivan Maidanski [Fri, 5 Oct 2012 17:41:19 +0000 (21:41 +0400)]
Generalize compare_double_and_swap_double using double_compare_and_swap

* src/atomic_ops/generalize.h (AO_compare_double_and_swap_double,
AO_compare_double_and_swap_double_full): New inline function (move
code from gcc/arm.h and msftc/x86.h) based on the corresponding
double_compare_and_swap (only if AO_HAVE_DOUBLE_PTR_STORAGE and
AO_HAVE_double_compare_and_swap[_full] defined but not
AO_HAVE_compare_double_and_swap_double[_full]).
* src/atomic_ops/generalize.h (AO_HAVE_compare_double_and_swap_double,
AO_HAVE_compare_double_and_swap_double_full): New macro (moved
from gcc/arm.h and msftc/x86.h, respectively).
* src/atomic_ops/sysdeps/gcc/arm.h
(AO_compare_double_and_swap_double): Remove definition from this file;
remove TODO item.
* src/atomic_ops/sysdeps/msftc/x86.h
(AO_compare_double_and_swap_double_full): Likewise.

12 years agoFix typos in atomic_ops.h comments
Ivan Maidanski [Fri, 5 Oct 2012 17:12:47 +0000 (21:12 +0400)]
Fix typos in atomic_ops.h comments

* src/atomic_ops.h: Fix typos in comments (update generalize.h
filename).

12 years agoRemove redundant include atomic_ops.h in test_stack
Ivan Maidanski [Fri, 5 Oct 2012 17:07:37 +0000 (21:07 +0400)]
Remove redundant include atomic_ops.h in test_stack

* tests/test_stack.c: Remove redundant include atomic_ops.h.

12 years agoMake compare_double_and_swap_double based on double_compare_and_swap
Ivan Maidanski [Fri, 5 Oct 2012 15:35:52 +0000 (19:35 +0400)]
Make compare_double_and_swap_double based on double_compare_and_swap
(gcc/arm, msftc/x86)

* src/atomic_ops/sysdeps/gcc/arm.h
(AO_compare_double_and_swap_double): Replace with new
AO_double_compare_and_swap (with old/new_val arguments of AO_double_t
type).
* src/atomic_ops/sysdeps/gcc/arm.h (AO_HAVE_double_compare_and_swap):
New macro.
* src/atomic_ops/sysdeps/gcc/arm.h
(AO_compare_double_and_swap_double): Convert arguments and invoke
AO_double_compare_and_swap; add TODO item.
* src/atomic_ops/sysdeps/msftc/x86.h
(AO_compare_double_and_swap_double_full): Invoke
AO_double_compare_and_swap_full (instead of calling
_InterlockedCompareExchange64 directly); add TODO item.

12 years agoEliminate arithmetic shifts in double-CAS (gcc/arm, msftc/x86)
Ivan Maidanski [Fri, 5 Oct 2012 11:10:40 +0000 (15:10 +0400)]
Eliminate arithmetic shifts in double-CAS (gcc/arm, msftc/x86)

* src/atomic_ops/sysdeps/gcc/arm.h
(AO_compare_double_and_swap_double): Make double values by setting
their AO_val1/2 parts instead of using arithmetic shifts; replace
old/new_val with old/new_w.AO_whole.
* src/atomic_ops/sysdeps/msftc/x86.h
(AO_compare_double_and_swap_double_full): Likewise.
* src/atomic_ops/sysdeps/msftc/x86.h
(AO_double_compare_and_swap_full): Add comment.
* src/atomic_ops/sysdeps/msftc/x86.h (AO_double_compare_and_swap_full,
AO_compare_double_and_swap_double_full): Cast result of
_InterlockedCompareExchange64 to double_ptr_storage (to eliminate
signed/unsigned values comparison mismatch compiler warning).

12 years agoEnable double_compare_and_swap for non-cpp code (msftc/x86.h)
Ivan Maidanski [Fri, 5 Oct 2012 09:59:01 +0000 (13:59 +0400)]
Enable double_compare_and_swap for non-cpp code (msftc/x86.h)

* src/atomic_ops/sysdeps/msftc/x86.h (AO_double_compare_and_swap_full,
AO_HAVE_double_compare_and_swap_full): Define even if no __cplusplus;
define before compare_double_and_swap_double.

12 years agoBetter document AO_double_t
Ivan Maidanski [Fri, 5 Oct 2012 08:33:13 +0000 (12:33 +0400)]
Better document AO_double_t

* src/atomic_ops/sysdeps/standard_ao_double_t.h (AO_double_t): Add
comment (regarding correspondence between AO_v1/2 and AO_whole).

12 years agoPerform only few list reversals in test_malloc if AO based on pthreads
Ivan Maidanski [Fri, 5 Oct 2012 07:57:38 +0000 (11:57 +0400)]
Perform only few list reversals in test_malloc if AO based on pthreads

* tests/test_malloc.c (N_REVERSALS): Set to 4 (instead of 1000) if
AO_USE_PTHREAD_DEFS.

12 years agoInclude proper files in atomic_ops_malloc (code refactoring)
Ivan Maidanski [Fri, 5 Oct 2012 07:37:57 +0000 (11:37 +0400)]
Include proper files in atomic_ops_malloc (code refactoring)

* src/atomic_ops_malloc.c: Include atomic_ops_malloc.h instead of
atomic_ops_stack.h (to verify function definitions match prototypes).
* src/atomic_ops_malloc.c: Include assert.h (since assert() is used).
* src/atomic_ops_malloc.h: Include stddef.h instead of stdlib.h for
size_t definition.

12 years agoDo not include standard_ao_double_t.h if no double-CAS (gcc/arm)
Ivan Maidanski [Thu, 4 Oct 2012 18:32:51 +0000 (22:32 +0400)]
Do not include standard_ao_double_t.h if no double-CAS (gcc/arm)

* src/atomic_ops/sysdeps/gcc/arm.h: Include standard_ao_double_t.h
only if AO_ARM_HAVE_LDREXD.

12 years agoRemove duplicate AO_spin and AO_pause definition in atomic_ops_stack
Ivan Maidanski [Thu, 4 Oct 2012 12:49:03 +0000 (16:49 +0400)]
Remove duplicate AO_spin and AO_pause definition in atomic_ops_stack

* src/atomic_ops.c (AO_REQUIRE_CAS): Undefine and include atomic_ops.h
unconditionally.
* src/atomic_ops.c (AO_USE_WIN32_PTHREADS): Define macro (and include
windows.h) if Win32 (non-POSIX) to have Sleep-based implementation of
AO_pause.
* src/atomic_ops.c (dummy, AO_spin, AO_pause): Define unconditionally
(to be always available for atomic_ops_stack).
* src/atomic_ops.c (dummy): Rename to spin_dummy.
* src/atomic_ops_stack.c (dummy, AO_spin, AO_pause): Remove definition
(for Win32); remove FIXME.
* src/atomic_ops_stack.c (AO_pause): Declare if
AO_USE_ALMOST_LOCK_FREE defined.

12 years agoEnable test_stack for pthreads-w32
Ivan Maidanski [Thu, 4 Oct 2012 11:14:10 +0000 (15:14 +0400)]
Enable test_stack for pthreads-w32

* tests/test_stack.c: Do not skip this test if AO_USE_WIN32_PTHREADS.
* tests/test_stack.c (main): Report (to stdout) if the test skipped;
always include stdio.h.
* tests/test_stack.c (LIMIT): Allow to specify alternate value from
command line; use smaller value (by 50 times) if AO_USE_PTHREAD_DEFS.

12 years ago.gitignore: Ignore .dll, .so files and pthreads-w32* library folder
Ivan Maidanski [Thu, 4 Oct 2012 11:08:57 +0000 (15:08 +0400)]
.gitignore: Ignore .dll, .so files and pthreads-w32* library folder

12 years agoFix AO_pause sleep delay for particular argument values (Win32)
Ivan Maidanski [Wed, 3 Oct 2012 14:02:03 +0000 (18:02 +0400)]
Fix AO_pause sleep delay for particular argument values (Win32)

* src/atomic_ops.c (AO_pause): Fix millis value (passed to Win32
Sleep) for the case of 'n' argument in range between 12 and 21,
inclusive if AO_USE_WIN32_PTHREADS (sleep for 1 ms in this case).
* src/atomic_ops_stack.c (AO_pause): Evaluate 'msecs' value using the
same algorithm as in atomic_ops.c (Win32 only).

12 years agoOptimize AO_spin manually to minimize compiler influence on its duration
Ivan Maidanski [Wed, 3 Oct 2012 09:02:13 +0000 (13:02 +0400)]
Optimize AO_spin manually to minimize compiler influence on its duration

* src/atomic_ops.c (dummy, AO_spin): Use AO_t instead of deprecated
AO_T.
* src/atomic_ops_stack.c (AO_spin): Likewise.
* src/atomic_ops.c (AO_spin): Define as static (since not needed
outside).
* src/atomic_ops.c (AO_spin): Optimize code manually to minimize
speed dependency on compiler optimization level; add comment.
* src/atomic_ops_stack.c (AO_spin): Likewise.

12 years agoFix visibility and initial value of 'dummy' variable in atomic_ops_stack
Ivan Maidanski [Wed, 3 Oct 2012 07:59:33 +0000 (11:59 +0400)]
Fix visibility and initial value of 'dummy' variable in atomic_ops_stack

* src/atomic_ops_stack.c (dummy): Define as static (to make symbol
without AO_ prefix visible only within this file); initialize to 1
(same as in atomic_ops.c, so that AO_spin would never really alter
its value).

12 years agoReplace some FIXME items with TODO in atomic_ops.c and sysdeps headers
Ivan Maidanski [Wed, 3 Oct 2012 06:46:19 +0000 (10:46 +0400)]
Replace some FIXME items with TODO in atomic_ops.c and sysdeps headers

* src/atomic_ops.c (AO_HASH_SIZE): Replace FIXME item with TODO one.
* src/atomic_ops/sysdeps/gcc/alpha.h (AO_fetch_compare_and_swap):
Likewise.
* src/atomic_ops/sysdeps/gcc/avr32.h (AO_fetch_compare_and_swap):
Likewise.
* src/atomic_ops/sysdeps/gcc/ia64.h (AO_compare_double_and_swap_double,
AO_compare_and_swap_double): Likewise.
* src/atomic_ops/sysdeps/gcc/m68k.h (AO_fetch_compare_and_swap):
Likewise.
* src/atomic_ops/sysdeps/gcc/mips.h (AO_and, AO_or, AO_xor): Likewise.
* src/atomic_ops/sysdeps/gcc/s390.h (AO_nop_full,
AO_fetch_compare_and_swap, AO_compare_double_and_swap_double):
Likewise.
* src/atomic_ops/sysdeps/gcc/sparc.h: Likewise.
* src/atomic_ops/sysdeps/ibmc/powerpc.h (AO_fetch_and_add, AO_and,
AO_or, AO_xor): Likewise.
* src/atomic_ops/sysdeps/msftc/arm.h
(AO_compare_double_and_swap_double): Likewise.
* src/atomic_ops/sysdeps/sunc/sparc.h: Likewise.
* src/atomic_ops/sysdeps/ao_t_is_int.h: Add TODO item.
* src/atomic_ops/sysdeps/gcc/sh.h: Likewise.

12 years agoUpdate TODO file (regarding Debian/alpha bug)
Ivan Maidanski [Tue, 2 Oct 2012 20:15:35 +0000 (00:15 +0400)]
Update TODO file (regarding Debian/alpha bug)

12 years agoDo not include standard_ao_double_t.h where double-CAS is unimplemented
Ivan Maidanski [Tue, 2 Oct 2012 20:08:23 +0000 (00:08 +0400)]
Do not include standard_ao_double_t.h where double-CAS is unimplemented

* src/atomic_ops/sysdeps/gcc/mips.h: Comment out include
standard_ao_double_t.h (since double-CAS is not implemented).
* src/atomic_ops/sysdeps/msftc/arm.h: Likewise.
* src/atomic_ops/sysdeps/gcc/mips.h: Add TODO item for
AO_compare_double_and_swap_double.
* src/atomic_ops/sysdeps/gcc/x86_64.h: Include standard_ao_double_t.h
only if AO_compare_double_and_swap_double_full defined.
* src/atomic_ops/sysdeps/msftc/x86_64.h: Likewise.
* src/atomic_ops/sysdeps/sunc/x86.h: Likewise.

12 years agoFix AO_load primitive name in comment
Ivan Maidanski [Tue, 2 Oct 2012 12:59:58 +0000 (16:59 +0400)]
Fix AO_load primitive name in comment

* src/atomic_ops.h: Fix 'load' primitive name in comment (replace
AO_load_release_read with AO_load_acquire_read).

12 years agoDo not report absence of meaningless nop, load and store in test_atomic
Ivan Maidanski [Tue, 2 Oct 2012 12:02:17 +0000 (16:02 +0400)]
Do not report absence of meaningless nop, load and store in test_atomic

* tests/test_atomic_include.template (test_atomicXX): Do not report
missing useless AO_nop_acquire[_read]/release[_write],
AO_[char/short/int_]store_read/acquire[_read] and
AO_[char/short/int_]load_write/release[_write] primitives (by checking
the presence of all the meaningful primitives of the same group).

12 years agoAdd double_compare_and_swap_read/write to generalization
Ivan Maidanski [Tue, 2 Oct 2012 09:43:35 +0000 (13:43 +0400)]
Add double_compare_and_swap_read/write to generalization

* src/atomic_ops/generalize.h (AO_double_compare_and_swap_read,
AO_double_compare_and_swap_write,
AO_double_compare_and_swap_release_write,
AO_double_compare_and_swap_acquire_read): New function (only if
corresponding AO_HAVE_compare_double_and_swap_double_XXX and not
AO_HAVE_double_compare_and_swap_XXX) completing double-CAS family;
add accompanying AO_HAVE_double_compare_and_swap_XXX macro.

12 years agoTest double_compare_and_swap in test_atomic
Ivan Maidanski [Tue, 2 Oct 2012 09:25:01 +0000 (13:25 +0400)]
Test double_compare_and_swap in test_atomic

* tests/test_atomic_include.template (test_atomicXX): Define old_w
and new_w local variables (only if AO_HAVE_double_compare_and_swapXX);
add tests for AO_double_compare_and_swapXX if available.

12 years agoAdd negative double-CAS test cases to test_atomic_include
Ivan Maidanski [Tue, 2 Oct 2012 08:25:11 +0000 (12:25 +0400)]
Add negative double-CAS test cases to test_atomic_include

* tests/test_atomic_include.template (test_atomicXX): Add more negative
tests for compare_double_and_swap_double and compare_and_swap_double;
restore zero 'w' value using double-CAS.

12 years agoAdd no-barrier double_compare_and_swap to generalization
Ivan Maidanski [Tue, 2 Oct 2012 07:24:16 +0000 (11:24 +0400)]
Add no-barrier double_compare_and_swap to generalization

* src/atomic_ops/generalize.h (AO_double_compare_and_swap):
New function (only if AO_HAVE_compare_double_and_swap_double and
not AO_HAVE_double_compare_and_swap) completing double-CAS family;
reformat comment.
* src/atomic_ops/generalize.h (AO_HAVE_double_compare_and_swap):
Define macro (accompanying AO_double_compare_and_swap).

12 years agoFix compare_double_and_swap_double_full definition condition in emul_cas
Ivan Maidanski [Tue, 2 Oct 2012 07:12:24 +0000 (11:12 +0400)]
Fix compare_double_and_swap_double_full definition condition in emul_cas

* src/atomic_ops/sysdeps/emul_cas.h
(AO_compare_double_and_swap_double_full): Test (define if)
AO_HAVE_compare_double_and_swap_double_full macro instead of
AO_HAVE_compare_double_and_swap_double.

12 years agoRemove unsafe emulation-based implementation of double CAS (SunCC/x86)
Ivan Maidanski [Sat, 29 Sep 2012 18:28:45 +0000 (22:28 +0400)]
Remove unsafe emulation-based implementation of double CAS (SunCC/x86)

* src/atomic_ops/sysdeps/sunc/x86.h
(AO_compare_double_and_swap_double_full): Do not test
AO_WEAK_DOUBLE_CAS_EMULATION and remove emulation-based implementation
since it is unsafe (not atomic with respect to other kinds of updates)
leading to test_stack failure.
* configure.ac (AO_WEAK_DOUBLE_CAS_EMULATION): Update and refine
documentation.
* src/atomic_ops/sysdeps/sunc/x86.h
(AO_compare_double_and_swap_double_full): Likewise.

12 years agoRemove sunc/x86_64.h to eliminate sunc/x86.h code duplication
Ivan Maidanski [Tue, 18 Sep 2012 17:55:36 +0000 (21:55 +0400)]
Remove sunc/x86_64.h to eliminate sunc/x86.h code duplication

* src/Makefile.am (nobase_private_HEADERS): Remove reference to
sunc/x86_64.h.
* src/atomic_ops.h: Include sunc/x86.h both for x86 and x86_64 (if
__sun defined but not GCC).
* src/atomic_ops/sysdeps/sunc/x86.h (AO_USE_PENTIUM4_INSTRS):
Explicitly define for x86_64 chips.
* src/atomic_ops/sysdeps/sunc/x86.h (AO_fetch_and_add_full,
AO_and_full, AO_or_full, AO_xor_full, AO_compare_and_swap_full,
AO_fetch_compare_and_swap_full): Remove "l" suffix (the size is
properly determined by operands).
* src/atomic_ops/sysdeps/sunc/x86.h
(AO_compare_double_and_swap_double_full): Use cmpxchg8b instruction
only in 32-bit mode (if __i386 defined) if avaialble, otherwise use
either cmpxchg16b (if AO_CMPXCHG16B_AVAILABLE) or emulation (if
AO_WEAK_DOUBLE_CAS_EMULATION).
* src/atomic_ops/sysdeps/sunc/x86.h (AO_T_IS_INT): Define only for
32-bit mode.
* src/atomic_ops/sysdeps/sunc/x86.h (AO_int_fetch_and_add_full,
AO_HAVE_int_fetch_and_add_full): Move definition from sunc/x86_64.h;
define only for 64-bit mode.
* src/atomic_ops/sysdeps/sunc/x86_64.h: Delete this file.

12 years agoFix cmpxchg16b-based compare_double_and_swap_double for SunCC/x86_64
Ivan Maidanski [Tue, 18 Sep 2012 15:03:19 +0000 (19:03 +0400)]
Fix cmpxchg16b-based compare_double_and_swap_double for SunCC/x86_64

* src/atomic_ops/sysdeps/sunc/x86_64.h
(AO_compare_double_and_swap_double_full): Fix inline assembly
arguments commenting out "m"(*addr) one (similar to that in
sunc/x86.h) if AO_CMPXCHG16B_AVAILABLE defined.

12 years agoRemove nested AO_USE_PTHREAD_DEFS macro check in atomic_ops.h (gcc/arm)
Ivan Maidanski [Sun, 23 Sep 2012 12:24:08 +0000 (16:24 +0400)]
Remove nested AO_USE_PTHREAD_DEFS macro check in atomic_ops.h (gcc/arm)

* src/atomic_ops.h: Remove redundant (nested) AO_USE_PTHREAD_DEFS
macro test for gcc/arm.

12 years agoFix AO_DOUBLE_T_INITIALIZER definition (x86_64)
Ivan Maidanski [Wed, 19 Sep 2012 16:29:25 +0000 (20:29 +0400)]
Fix AO_DOUBLE_T_INITIALIZER definition (x86_64)

* src/atomic_ops/sysdeps/standard_ao_double_t.h
(AO_DOUBLE_T_INITIALIZER): Fix definition for x86_64 (remove cast of
zero since __m128 type is a vector).

12 years agoEliminate 'missing initializer' warning for AO_stack_t value initializer
Ivan Maidanski [Tue, 18 Sep 2012 20:28:36 +0000 (00:28 +0400)]
Eliminate 'missing initializer' warning for AO_stack_t value initializer

* src/atomic_ops/sysdeps/generic_pthread.h (AO_DOUBLE_T_INITIALIZER):
New API macro definition.
* src/atomic_ops/sysdeps/standard_ao_double_t.h
(AO_DOUBLE_T_INITIALIZER): Likewise.
* src/atomic_ops_stack.h (AO_STACK_INITIALIZER): Define using
AO_DOUBLE_T_INITIALIZER (only if not AO_USE_ALMOST_LOCK_FREE).

12 years agoFix a typo in comment of compare_double_and_swap_double (x86_64)
Ivan Maidanski [Tue, 18 Sep 2012 17:21:47 +0000 (21:21 +0400)]
Fix a typo in comment of compare_double_and_swap_double (x86_64)

* src/atomic_ops/sysdeps/gcc/x86_64.h
(AO_compare_double_and_swap_double_full): Fix a typo in comment.
* src/atomic_ops/sysdeps/sunc/x86_64.h
(AO_compare_double_and_swap_double_full): Likewise.

12 years agoAlign code and comments of gcc/x86.h and sunc/x86.h
Ivan Maidanski [Tue, 18 Sep 2012 15:29:46 +0000 (19:29 +0400)]
Align code and comments of gcc/x86.h and sunc/x86.h

* src/atomic_ops/sysdeps/gcc/x86.h (AO_and_full, AO_or_full,
AO_xor_full, AO_test_and_set_full,
AO_compare_double_and_swap_double_full): Align code and comments.
* src/atomic_ops/sysdeps/sunc/x86.h: Likewise.

12 years agoAdd TODO item to gcc/alpha.h
Ivan Maidanski [Tue, 18 Sep 2012 13:41:18 +0000 (17:41 +0400)]
Add TODO item to gcc/alpha.h

12 years agoUpdate ChangeLog file
Ivan Maidanski [Tue, 18 Sep 2012 12:20:31 +0000 (16:20 +0400)]
Update ChangeLog file

12 years agotests: Log messages to stdout instead of stderr
Ivan Maidanski [Tue, 18 Sep 2012 11:21:16 +0000 (15:21 +0400)]
tests: Log messages to stdout instead of stderr

* tests/run_parallel.h (run_parallel): Print logging (non-error)
messages using printf() instead of fprintf(stderr).
* tests/test_atomic_include.template (MISSING): Likewise.
* tests/test_malloc.c (print_list): Likewise.
* tests/run_parallel.h (run_parallel): Reformat code.

12 years agoRemove useless 'perror' call in tests run_parallel.h
Ivan Maidanski [Tue, 18 Sep 2012 11:10:47 +0000 (15:10 +0400)]
Remove useless 'perror' call in tests run_parallel.h

* tests/run_parallel.h (run_parallel): Remove useless perror() call
(since error code is returned by pthread primitive or GetLastError).

12 years agoTerminate tests with abort after error reported
Ivan Maidanski [Tue, 18 Sep 2012 10:54:48 +0000 (14:54 +0400)]
Terminate tests with abort after error reported

* tests/test_atomic.c (acqrel_thr): Call abort() after fprintf(stderr).
* tests/test_malloc.c (run_one_test): Likewise.
* tests/test_stack.c (check_list, main): Likewise.

12 years agoUpdate ChangeLog file
Ivan Maidanski [Wed, 5 Sep 2012 04:56:37 +0000 (08:56 +0400)]
Update ChangeLog file

12 years agoImplement compare_double_and_swap_double for SunCC/x86
Ivan Maidanski [Wed, 5 Sep 2012 04:55:04 +0000 (08:55 +0400)]
Implement compare_double_and_swap_double for SunCC/x86
(Tested only with Sun C 5.11 SunOS_i386.)

* src/atomic_ops/sysdeps/sunc/x86.h
(AO_compare_double_and_swap_double_full): Implement (define only if
AO_NO_CMPXCHG8B unset) using same algorithm as for gcc/x86 non-PIC.

12 years agoUpdate ChangeLog and TODO files
Ivan Maidanski [Wed, 5 Sep 2012 04:53:41 +0000 (08:53 +0400)]
Update ChangeLog and TODO files

12 years agoFix compare_double_and_swap_double for clang/x86 in PIC mode
Ivan Maidanski [Wed, 5 Sep 2012 04:25:24 +0000 (08:25 +0400)]
Fix compare_double_and_swap_double for clang/x86 in PIC mode

* src/atomic_ops/sysdeps/gcc/x86.h
(AO_compare_double_and_swap_double_full): Re-implement for PIC mode
saving EBX to a local variable (instead of pushing it to stack) and
saving memory operand address to a register (edi which is manually
preserved), so that the whole code could also work even if EBX points
to memory operand (e.g., in Clang); test __PIC__ using ifdef (instead
of "if"); update comments; reformat code.

12 years agoTODO: Add FIXME item (Ubuntu/x86)
Ivan Maidanski [Thu, 30 Aug 2012 14:12:23 +0000 (18:12 +0400)]
TODO: Add FIXME item (Ubuntu/x86)

12 years agoUpdate ChangeLog file
Ivan Maidanski [Wed, 1 Aug 2012 18:38:50 +0000 (22:38 +0400)]
Update ChangeLog file

12 years agoFix AO_compiler_barrier missing parentheses
Ivan Maidanski [Wed, 1 Aug 2012 18:35:17 +0000 (22:35 +0400)]
Fix AO_compiler_barrier missing parentheses

* src/atomic_ops.h (AO_compiler_barrier): Add parentheses and cast to
void.

12 years agoUpdate ChangeLog file
Ivan Maidanski [Sun, 22 Jul 2012 08:34:35 +0000 (12:34 +0400)]
Update ChangeLog file

12 years agoTODO file: add FIXME items (regarding Debian)
Ivan Maidanski [Wed, 18 Jul 2012 11:58:43 +0000 (15:58 +0400)]
TODO file: add FIXME items (regarding Debian)

12 years agoFix AO_compare_double_and_swap_double_full for gcc-4.2.1/x86 in PIC mode
Ivan Maidanski [Wed, 4 Jul 2012 04:32:03 +0000 (08:32 +0400)]
Fix AO_compare_double_and_swap_double_full for gcc-4.2.1/x86 in PIC mode

* src/atomic_ops/sysdeps/gcc/x86.h
(AO_compare_double_and_swap_double_full): Use EDI register for
"new_val1" argument in PIC mode only for GCC 4.3+ to workaround
a problem with older compiler versions (e.g., GCC 4.2.1 [FreeBSD])
that do not recognize 'D' as a valid register specification; update
comment.