Ivan Maidanski [Thu, 14 Feb 2013 08:04:19 +0000 (12:04 +0400)]
Implement load/store via simple LDR/STR for ARMv6+ (msftc)
* src/atomic_ops/sysdeps/msftc/arm.h: Include
all_aligned_atomic_load_store.h instead of all_atomic_load_store.h
(since unaligned accesses are not guaranteed to be atomic).
* src/atomic_ops/sysdeps/msftc/arm.h (AO_load): Remove; include
all_aligned_atomic_load_store.h unconditionally instead (thus
implementing AO[_char/short]_load/store via simple LDR/STR; add
comment about Windows interrupt handlers.
* src/atomic_ops/sysdeps/msftc/arm.h: Add TODO item to implement
AO_test_and_set_full (for pre-ARMv6).
Ivan Maidanski [Thu, 14 Feb 2013 07:36:06 +0000 (11:36 +0400)]
Define AO_nop_full as compiler barrier for pre-ARMv6 single-core case
* src/atomic_ops/sysdeps/gcc/arm.h (AO_nop_full): Define for pre-ARMv6
as well (as a compiler barrier) if AO_UNIPROCESSOR; refine comment.
* src/atomic_ops/sysdeps/msftc/arm.h (AO_nop_full): Likewise.
* src/atomic_ops/sysdeps/msftc/arm.h: Eliminate duplicated include of
test_and_set_t_is_ao_t.h.
Ivan Maidanski [Tue, 5 Feb 2013 21:38:38 +0000 (01:38 +0400)]
Remove load_read, store_write redundant definition from ordered_X.h
(code refactoring)
* src/atomic_ops/sysdeps/loadstore/ordered_loads_only.template
(AO_XSIZE_load_read): Remove prototype (since defined by
generalize-small.template in the same way).
* src/atomic_ops/sysdeps/loadstore/ordered_stores_only.template
(AO_XSIZE_store_write): Likewise.
* src/atomic_ops/sysdeps/loadstore/ordered_stores_only.template
(AO_XSIZE_store_release): Define using AO_nop_write and AO_XSIZE_store
directly.
* src/atomic_ops/sysdeps/ordered_except_wr.h: Move include of
ordered_stores_only.h down to be after AO_nop_write definition.
* src/atomic_ops/sysdeps/read_ordered.h: Move include of
ordered_loads_only.h down to be after AO_nop_read definition.
* src/atomic_ops/sysdeps/loadstore/ordered_loads_only.h: Regenerate.
* src/atomic_ops/sysdeps/loadstore/ordered_stores_only.h: Likewise.
Ivan Maidanski [Tue, 5 Feb 2013 20:23:22 +0000 (21:23 +0100)]
Revert "Prevent load_acquire redefinition in ordered_loads_only.h"
(That change is not needed because the file defines really only
load_acquire, and load_read is the same as in generalize-small.h)
Ivan Maidanski [Sat, 2 Feb 2013 16:46:10 +0000 (20:46 +0400)]
Fix unsupported instruction use in char/short_fetch_and_add for ARMv6
* src/atomic_ops/sysdeps/gcc/arm.h (AO_ARM_HAVE_LDREXBH): Define new
macro for ARMv6K/Z+ (excluding ARMv6, ARMv6J, ARMv6T2).
* src/atomic_ops/sysdeps/gcc/arm.h (AO_char_store, AO_short_store,
AO_char_fetch_and_add, AO_short_fetch_and_add): Define (together with
the corresponding AO_HAVE_x macros) only if AO_ARM_HAVE_LDREXBH (since
otherwise LDREXB/STREXB, LDREXH/STREXH are not supported by the target
processor).
* src/atomic_ops/sysdeps/gcc/arm.h: Include char_atomic_store.h and
short_atomic_store.h only if AO_HAVE_char_store is not defined (by
gcc/arm.h itself).
Ivan Maidanski [Sat, 2 Feb 2013 09:40:27 +0000 (13:40 +0400)]
Implement char/short_fetch_and_add for ARMv6+ (GCC)
* src/atomic_ops/sysdeps/gcc/arm.h: Include char_atomic_store.h and
short_atomic_store.h only if not AO_BROKEN_TASKSWITCH_CLREX.
* src/atomic_ops/sysdeps/gcc/arm.h (AO_store): Update comment.
* src/atomic_ops/sysdeps/gcc/arm.h (AO_char_store, AO_short_store):
Implement using LDREXB/STREXB and LDREXH/STREXH, respectively, if
AO_BROKEN_TASKSWITCH_CLREX defined (only if AO_ARM_HAVE_LDREX).
* src/atomic_ops/sysdeps/gcc/arm.h (AO_char_fetch_and_add,
AO_short_fetch_and_add): Implement (based on using LDREXB/STREXB and
LDREXH/STREXH, respectively) if AO_ARM_HAVE_LDREX.
Ivan Maidanski [Sat, 2 Feb 2013 08:47:07 +0000 (12:47 +0400)]
Adjust type of 'flag' and 'tmp' local variables in gcc/arm.h
(code refactoring)
* src/atomic_ops/sysdeps/gcc/arm.h (AO_store,
AO_fetch_compare_and_swap): Change type of "flag" local variable from
AO_t to int (only if AO_BROKEN_TASKSWITCH_CLREX).
* src/atomic_ops/sysdeps/gcc/arm.h (AO_test_and_set, AO_fetch_and_add,
AO_fetch_and_add1, AO_fetch_and_sub1): Change type of "flag" local
variable from unsigned long to int.
* src/atomic_ops/sysdeps/gcc/arm.h (AO_fetch_and_add,
AO_fetch_and_add1, AO_fetch_and_sub1): Change type of "tmp" local
variable from unsigned long to AO_t.
Ivan Maidanski [Tue, 29 Jan 2013 22:33:22 +0000 (02:33 +0400)]
Implement char/short_store primitives at aligned addresses for ARM
* src/atomic_ops/sysdeps/gcc/arm.h: Include char_atomic_store.h and
short_atomic_store.h if AO_ARM_HAVE_LDREX (after
AO_ACCESS_x_CHECK_ALIGNED defined); add comment.
* src/atomic_ops/sysdeps/gcc/arm.h: Include
all_aligned_atomic_load_store.h instead of all_atomic_load_store.h
(only if not AO_ARM_HAVE_LDREX).
Ivan Maidanski [Sat, 26 Jan 2013 08:58:34 +0000 (12:58 +0400)]
Prevent load_acquire redefinition in ordered_loads_only.h
* src/atomic_ops/sysdeps/loadstore/ordered_loads_only.template
(AO_XSIZE_load_acquire, AO_HAVE_XSIZE_load_acquire): Do not define
if AO_HAVE_XSIZE_load_acquire already defined.
* src/atomic_ops/sysdeps/loadstore/ordered_loads_only.h: Regenerate.
Ivan Maidanski [Sun, 20 Jan 2013 19:12:12 +0000 (23:12 +0400)]
Add internal header containing only char/short/int/AO_t atomic loads
(code refactoring)
* src/Makefile.am (nobase_private_HEADERS): Add all_atomic_only_load.h
entry.
* src/atomic_ops/sysdeps/all_aligned_atomic_load_store.h: Include
all_atomic_load_store.h instead of including X_atomic_load.h and
X_atomic_store.h directly; add comment for char type.
* src/atomic_ops/sysdeps/all_atomic_load_store.h: Include
all_atomic_only_load.h instead of including X_atomic_load.h directly.
* src/atomic_ops/sysdeps/all_atomic_only_load.h: New file (contains
only inclusion of atomic_load.h, char_atomic_load.h,
short_atomic_load.h and int_atomic_load.h files.
Ivan Maidanski [Mon, 14 Jan 2013 20:56:35 +0000 (00:56 +0400)]
Fix README regarding _acquire_read barrier
* doc/README.txt (_acquire_read): Add information about memory
barrier (similar as in atomic_ops.h).
* doc/README.txt (_release_read): Remove information about
non-existing barrier.
Ivan Maidanski [Sun, 13 Jan 2013 18:42:52 +0000 (22:42 +0400)]
Fix return type of AO_int_X primitives defined in ao_t_is_int header
* src/atomic_ops/sysdeps/ao_t_is_int.h
(AO_int_fetch_compare_and_swap_full,
AO_int_fetch_compare_and_swap_acquire,
AO_int_fetch_compare_and_swap_release,
AO_int_fetch_compare_and_swap_write,
AO_int_fetch_compare_and_swap_read, AO_int_fetch_compare_and_swap,
AO_int_load_acquire, AO_int_fetch_and_add_full,
AO_int_fetch_and_add1_acquire, AO_int_fetch_and_add1_release,
AO_int_fetch_and_sub1_acquire, AO_int_fetch_and_sub1_release): Cast
result to unsigned int instead of signed int.
Ivan Maidanski [Sun, 13 Jan 2013 16:19:51 +0000 (20:19 +0400)]
Fix ordered_except_wr header inclusion for s390
* src/atomic_ops/sysdeps/gcc/s390.h: Move include of
ordered_except_wr.h down to be after all_aligned_atomic_load_store.h
inclusion (since the latter defines AO_X_load/store primitives used by
the former header).
Ivan Maidanski [Sun, 13 Jan 2013 16:04:36 +0000 (20:04 +0400)]
Fix read_ordered.h inclusion for ARM
* src/atomic_ops/sysdeps/armcc/arm_v6.h: Move include of read_ordered.h
down to the end of the file to be after AO_load/store definition
(since read_ordered.h depends on these primitives).
* src/atomic_ops/sysdeps/gcc/arm.h: Likewise.
* src/atomic_ops/sysdeps/msftc/arm.h: Likewise.
Ivan Maidanski [Sun, 13 Jan 2013 13:33:16 +0000 (17:33 +0400)]
Remove AO_store_full from msftc/arm.h in favor of generalized primitive
(code refactoring)
* src/atomic_ops/sysdeps/msftc/arm.h (AO_store_full): Remove since
similar definition exists in generalize-small.h.
* src/atomic_ops/sysdeps/msftc/arm.h: Add TODO item for AO_store().
Ivan Maidanski [Sat, 12 Jan 2013 19:55:52 +0000 (23:55 +0400)]
Add AO_double_store pthread-based implementation and tests
* src/atomic_ops/sysdeps/generic_pthread.h (AO_double_store_full): New
primitive.
* tests/test_atomic_include.template (test_atomicXX): Add test of
AO_double_storeXX.
Ivan Maidanski [Mon, 7 Jan 2013 16:17:49 +0000 (20:17 +0400)]
Define double-wide ordered loads/stores for x86
* src/Makefile.am (atomic_ops/sysdeps/loadstore/ordered_loads_only.h,
atomic_ops/sysdeps/loadstore/ordered_stores_only.h): Generate
primitives for AO_double_t as well (from the template).
* src/atomic_ops/sysdeps/gcc/x86.h: Move include of ordered_except_wr.h
(together with the comment) to the end of the file to be after
inclusion of double_atomic_load_store.h (because the former uses the
primitives defined the latter).
* src/atomic_ops/sysdeps/msftc/x86.h: Likewise.
* src/atomic_ops/sysdeps/sunc/x86.h: Likewise.
* src/atomic_ops/sysdeps/loadstore/ordered_loads_only.h: Regenerate.
* src/atomic_ops/sysdeps/loadstore/ordered_stores_only.h: Likewise.
Ivan Maidanski [Mon, 7 Jan 2013 15:24:02 +0000 (19:24 +0400)]
Fix return type of AO_char/short/int_load_read() in read_ordered.h
* src/atomic_ops/sysdeps/read_ordered.h (AO_char_load_read,
AO_short_load_read, AO_int_load_read): Change return type (and the
type of "result" local variable) from AO_t to the type matching the
name of the function (i.e., unsigned char/short/int, respectively).
Ivan Maidanski [Mon, 7 Jan 2013 08:52:59 +0000 (12:52 +0400)]
Implement AO_nop_full/write using 'dmb' instruction if available (gcc/arm)
* src/atomic_ops/sysdeps/gcc/arm.h (AO_ARM_HAVE_DMB): New macro
(defined for ARMv6M and ARMv7+).
* src/atomic_ops/sysdeps/gcc/arm.h (AO_nop_full): Update comment;
use "dmb" instruction if AO_ARM_HAVE_DMB (and not AO_UNIPROCESSOR).
* src/atomic_ops/sysdeps/gcc/arm.h (AO_nop_write): Implement using
"dmb st" instruction and define AO_HAVE_nop_write (only if
AO_ARM_HAVE_DMB and not AO_UNIPROCESSOR).
Ivan Maidanski [Mon, 7 Jan 2013 08:31:48 +0000 (12:31 +0400)]
Fix missing abort() usage in atomic_ops_malloc and tests on WinCE
* src/atomic_ops_malloc.c (abort): Define to _exit(-1) if _WIN32_WCE
or __MINGW32CE__ (since there is no abort() in WinCE).
* tests/run_parallel.h (abort): Likewise.
* tests/test_stack.c (abort): Likewise.
Ivan Maidanski [Sun, 6 Jan 2013 15:51:57 +0000 (19:51 +0400)]
Implement AO_double_load/store based on guaranteed x86 access atomicity
* src/atomic_ops/sysdeps/gcc/x86.h: Define
AO_ACCESS_double_CHECK_ALIGNED and include double_atomic_load_store.h
after inclusion of standard_ao_double_t.h (only if AO_t is 32-bit).
* src/atomic_ops/sysdeps/msftc/x86.h: Likewise.
* src/atomic_ops/sysdeps/sunc/x86.h: Likewise.
* src/atomic_ops/sysdeps/gcc/arm.h (AO_fetch_compare_and_swap): Remove
redundant "cc" clobber for assembly code that consists of a single
LDREXD instruction.
Ivan Maidanski [Sat, 5 Jan 2013 21:00:44 +0000 (01:00 +0400)]
Add generic implementation of AO_double_load primitives
* src/Makefile.am (nobase_private_HEADERS): Add
double_atomic_load_store.h entry.
* src/Makefile.am (atomic_ops/generalize-small.h):
Generate primitives for AO_double_t as well (from the template).
* src/atomic_ops/generalize-small.h: Regenerate.
* src/atomic_ops/sysdeps/generic_pthread.h (AO_double_load_full): New
primitive.
* src/atomic_ops/sysdeps/loadstore/double_atomic_load_store.h: New
header (most code copied from atomic_load_store template).
* tests/test_atomic_include.template (test_atomicXX): Add test of
AO_double_loadXX.
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).
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.
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).
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.
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.
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).
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).
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.
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.
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).
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).
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).
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.
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.
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).
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.
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).
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.
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).
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.
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.
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).
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.
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).