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.
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.
* src/atomic_ops/generalize-small.template
(AO_XSIZE_compare_and_swap_full, AO_XSIZE_compare_and_swap_acquire,
AO_XSIZE_compare_and_swap_release, AO_XSIZE_fetch_and_add_full,
AO_XSIZE_fetch_and_add_acquire, AO_XSIZE_fetch_and_add_release):
Fix type of function arguments (or local variables) by adding
'unsigned' to XCTYPE.
* src/atomic_ops/generalize-small.h: Regenerate.
H.J. Lu [Tue, 1 May 2012 10:31:30 +0000 (14:31 +0400)]
Fix for x32 by removing 'q' suffix in x86-64 instructions
We do not need the 'q' suffix on x86_64 atomic instructions for AO_t
which is defined as "unsigned long"; the later is 32-bit for x32
and 64-bit for x86-64; the register operand in x86-64 atomic
instructions is sufficient to properly determine the register size.
Ivan Maidanski [Wed, 28 Mar 2012 03:59:09 +0000 (07:59 +0400)]
Fix configure to define __PIC__ macro explicitly only if not done by GCC
* configure.ac (PICFLAG): Adjust AC_MSG_CHECKING message; report
"none" result if no -fPIC is needed (for Cygwin/MinGW); determine
whether GCC -fPIC option causes __PIC__ macro definition; pass
-D __PIC__ to PICFLAG (instead of CFLAGS) only if not defined
automatically in case -fPIC specified; update comment.
Ivan Maidanski [Mon, 26 Mar 2012 04:34:27 +0000 (08:34 +0400)]
Fix double_ptr_storage definition for GCC pre-v4 (x86_64)
* src/atomic_ops/sysdeps/standard_ao_double_t.h: Do not use __m128
if GCC pre-v4 (at least, xmmintrin.h is missing in gcc-3.4.3-x86_64
included in Solaris 10 distribution).
Ivan Maidanski [Wed, 7 Mar 2012 15:12:49 +0000 (19:12 +0400)]
Fix AO_compare_double_and_swap_double_full for gcc/x86 (PIC mode)
* src/atomic_ops/sysdeps/gcc/x86.h
(AO_compare_double_and_swap_double_full): Use EDI register for
"new_val1" argument instead of a memory operand and use XCHG assembler
instruction instead of push/pop in case of PIC mode (to workaround
a bug in GCC 4.6.1); update the comment.
Ivan Maidanski [Wed, 7 Mar 2012 03:31:55 +0000 (07:31 +0400)]
Fix a typo in comment
* src/atomic_ops/sysdeps/gcc/x86.h
(AO_compare_double_and_swap_double_full): Fix argument name in the
comment.
* src/atomic_ops/sysdeps/sunc/x86.h
(AO_compare_double_and_swap_double_full): Likewise.
Ivan Maidanski [Sun, 4 Mar 2012 18:21:40 +0000 (22:21 +0400)]
Replace pointer relational comparisons with non-pointer ones
* src/atomic_ops_malloc.c (initial_heap_lim): Remove static variable
(which holds a constant).
* src/atomic_ops_malloc.c (get_chunk): Replace "goto" with for/break;
remove "my_lim" local variable; cast AO_compare_and_swap_acquire()
unused result to void; replace less-or-equal comparison of pointers
with comparison of ptrdiff_t value.
* src/atomic_ops_malloc.c (add_chunk_as): Update comment; remove "sz"
argument; replace "first", "limit", "p", "next" pointer local variable
with "ofs", "limit" and "sz" variables of size_t; add assertion on
"sz" value; replace less-or-equal comparison of pointers with
comparison of size_t values.
* src/atomic_ops_malloc.c (AO_malloc): Remove "adj_sz" local variable;
do not pass adj_sz argument to add_chunk_as.
Ivan Maidanski [Thu, 19 Jan 2012 04:35:21 +0000 (08:35 +0400)]
test_stack: check_list() code refactoring and 'marks' size optimization
* tests/test_stack.c (marks): Set smaller size (according to the
maximum index passed to check_list).
* tests/test_stack.c (check_list): Store p->data to "i" local variable
(in the loop body) replacing multiple occurrences of p->data.
Ivan Maidanski [Wed, 11 Jan 2012 17:41:51 +0000 (21:41 +0400)]
Replace repeating '==' in documentation with a single one
* README: Replace sequences of repeating '==' identifying section
titles (which is also used by git-apply) with two '=' symbols at the
beginning and at the end of each title.
* TODO: Likewise.
* ChangeLog: Likewise.
* src/atomic_ops/sysdeps/gcc/arm.h: Break a sequence of repeating '=='
(in a comment) with a space.
Ivan Maidanski [Tue, 13 Dec 2011 06:36:24 +0000 (10:36 +0400)]
configure: Do not pass '-Wextra' option to GCC if unsupported
* configure.ac (WEXTRA): New variable (set to "-Wextra" if the latter
is supported by GCC, otherwise to "-W").
* configure.ac (CFLAGS): Use WEXTRA variable.
Ivan Maidanski [Mon, 12 Dec 2011 14:57:23 +0000 (18:57 +0400)]
Define NDEBUG via config.h instead of CFLAGS;
do not define NDEBUG if '--enable-assertions' passed to configure
* configure.ac (CFLAGS): Do not add "-DNDEBUG".
* configure.ac (assertions): New AC argument.
* configure.ac (NDEBUG): New AC macro (defined only if "assertions"
AC argument is not set to "yes").
Ivan Maidanski [Thu, 8 Dec 2011 13:17:21 +0000 (17:17 +0400)]
Recognize AO_PREFER_GENERALIZED to favor generalization over asm (MIPS)
* src/atomic_ops/sysdeps/gcc/mips.h (AO_fetch_and_add,
AO_HAVE_fetch_and_add, AO_test_and_set, AO_HAVE_test_and_set): Do not
define if AO_PREFER_GENERALIZED.
Ivan Maidanski [Wed, 30 Nov 2011 11:37:53 +0000 (15:37 +0400)]
Workaround ICE9 A1 chip LL bug (MIPS)
* src/atomic_ops/sysdeps/gcc/mips.h (AO_MIPS_LL_FIX): New macro (used
to workaround LL bug in some chips); test AO_ICE9A1_LLSC_WAR new macro.
* src/atomic_ops/sysdeps/gcc/mips.h (AO_fetch_and_add,
AO_test_and_set, AO_compare_and_swap, AO_fetch_compare_and_swap):
Insert AO_MIPS_LL_FIX after every "ll" operation.
Ivan Maidanski [Tue, 29 Nov 2011 17:11:06 +0000 (21:11 +0400)]
Include ao_t_is_int.h from atomic_ops.h after first generalization if
AO_T_IS_INT (new macro) is defined in 'sysdeps' file
* src/atomic_ops.h (AO_T_IS_INT): Test macro after first
generalization, if set then include ao_t_is_int.h file and force
AO_GENERALIZE_TWICE.
* src/atomic_ops/sysdeps/gcc/hexagon.h (AO_T_IS_INT): Define new macro
instead of ao_t_is_int.h inclusion.
* src/atomic_ops/sysdeps/gcc/ia64.h (AO_T_IS_INT): Likewise.
* src/atomic_ops/sysdeps/gcc/m68k.h (AO_T_IS_INT): Likewise.
* src/atomic_ops/sysdeps/gcc/mips.h (AO_T_IS_INT): Likewise.
* src/atomic_ops/sysdeps/gcc/powerpc.h (AO_T_IS_INT): Likewise.
* src/atomic_ops/sysdeps/gcc/x86.h (AO_T_IS_INT): Likewise.
* src/atomic_ops/sysdeps/hpc/ia64.h (AO_T_IS_INT): Likewise.
* src/atomic_ops/sysdeps/msftc/x86.h (AO_T_IS_INT): Likewise.
* src/atomic_ops/sysdeps/sunc/x86.h (AO_T_IS_INT): Likewise.
* src/atomic_ops/sysdeps/gcc/powerpc.h: Add place-holder comment (in
case of ppc64).
* src/atomic_ops/sysdeps/gcc/hexagon.h: Do not include generalize.h
any longer (since ao_t_is_int.h is included from atomic_ops.h now).
* src/atomic_ops/sysdeps/gcc/ia64.h: Likewise.
* src/atomic_ops/sysdeps/hpc/ia64.h: Likewise.
Ivan Maidanski [Tue, 29 Nov 2011 16:36:56 +0000 (20:36 +0400)]
Fix generalization for IA-64, Hexagon (include generalize.h before
ao_t_is_int.h to have AO_or, AO_..._read/write and some other
int-derived primitives got defined)
* src/atomic_ops/sysdeps/gcc/hexagon.h: Include generalize.h file
before ao_t_is_int.h one.
* src/atomic_ops/sysdeps/gcc/ia64.h: Likewise.
* src/atomic_ops/sysdeps/hpc/ia64.h: Likewise.
Ivan Maidanski [Thu, 3 Nov 2011 14:43:52 +0000 (18:43 +0400)]
Fix generalized AO_<type>_fetch_and_add() return type
* src/atomic_ops/generalize-small.template
(AO_XSIZE_fetch_and_add_full, AO_XSIZE_fetch_and_add_acquire,
AO_XSIZE_fetch_and_add_release): Change return type from AO_t to
XCTYPE.
* src/atomic_ops/generalize-small.h: Regenerate.
Ivan Maidanski [Mon, 24 Oct 2011 15:05:31 +0000 (19:05 +0400)]
Fix AO_compare_and_swap_full (GCC MIPS, PowerPC) returned value type
* src/atomic_ops/sysdeps/gcc/mips.h (AO_compare_and_swap_full):
Change "result" local variable type from AO_t to int.
* src/atomic_ops/sysdeps/gcc/powerpc.h (AO_compare_and_swap_full):
Likewise.
Ivan Maidanski [Fri, 21 Oct 2011 11:38:51 +0000 (15:38 +0400)]
Minor code refactoring of src/atomic_ops.c (remove duplicated code)
* src/atomic_ops.c (block_all_signals): New inline function (move the
code from AO_compare_and_swap_emulation).
* src/atomic_ops.c (AO_compare_and_swap_emulation,
AO_compare_double_and_swap_double_emulation): Use block_all_signals().