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().
Ivan Maidanski [Wed, 21 Sep 2011 09:14:29 +0000 (13:14 +0400)]
Fix configure for mingw-w64/32.
* configure.ac (PICFLAG, THREADDLLIBS): Define as empty for MinGW.
* configure.ac (have_pthreads): New definition (set to true unless
MinGW).
* configure.ac (HAVE_PTHREAD_H): New AM conditional (based on
have_pthreads value).
* tests/Makefile.am (test_atomic_pthreads_SOURCES,
test_atomic_pthreads_CPPFLAGS, test_atomic_pthreads_LDADD): Define
only if HAVE_PTHREAD_H.
* tests/Makefile.am (TESTS): Don't include test_atomic_pthreads unless
HAVE_PTHREAD_H.
* tests/Makefile.am (check_PROGRAMS): Define to TESTS value.
Ivan Maidanski [Wed, 21 Sep 2011 09:02:40 +0000 (13:02 +0400)]
Turn atomic_ops_malloc static mmap-related empty functions into macro
definitions in case of missing mmap() to eliminate a compiler warning
about unused arguments.
* src/atomic_ops_malloc.c (get_mmaped, AO_malloc_large,
AO_free_large): Turn static empty function into macro definition;
remove ARGSUSED comment-based annotation.
Ivan Maidanski [Wed, 21 Sep 2011 08:46:39 +0000 (12:46 +0400)]
tests: Invoke exit() instead of abort() in case of out of memory
* tests/test_malloc.c (cons, run_one_test): Call exit with a non-zero
code (instead of abort) if out of memory.
* tests/test_stack.c (add_elements): Likewise.
* tests/test_stack.c (main): Use a distinct exit code if a thread
creation failed.
Petter Urkedal [Sun, 14 Aug 2011 10:24:30 +0000 (12:24 +0200)]
Use libtool for linking but keep the libraries static.
* configure.ac: Use LT_INIT([disable-shared]) instead of AC_PROG_RANLIB.
Also, re-enable the m4 macro directory.
* Makefile.am (ACLOCAL_AMFLAGS): Add -I m4.
* m4/.keep: Create the m4 directory to avoid problems due to the above
m4 flag when running autoreconf for the first time.
Ivan Maidanski [Tue, 9 Aug 2011 16:42:05 +0000 (20:42 +0400)]
Improve Makefile for MS VC++.
* src/Makefile.msft: Remove list_atomic.c from the comment.
* src/Makefile.msft: Compile with -W3 option; replace -o option
with /Fo.
* src/Makefile.msft (clean): New target.
Ivan Maidanski [Tue, 9 Aug 2011 15:26:42 +0000 (19:26 +0400)]
Remove auto-generated tests/list_atomic.c and test_atomic_include.h
from the repo.
The files are still present in the distributive tar-ball as it is hard
to generate them on Windows (without Cygwin/MinGW). Note that these
files are used only for testing (unlike generalize-small.h).
The later remains even in the repo as it makes possible to use
libatomic_ops without running any script.
* .gitignore: add tests/list_atomic.c and test_atomic_include.h.
* src/Makefile.msft: Add comment about test_atomic_include.h; wrap
long lines.
* src/Makefile.msft (all): Build "libatomic_ops_gpl.lib" instead of
"check".
* tests/list_atomic.c, tests/test_atomic_include.h: Remove.
Ivan Maidanski [Tue, 9 Aug 2011 11:35:25 +0000 (15:35 +0400)]
Rename run_parallel.inc to run_parallel.h;
rename test_atomic.template to test_atomic_include.template.
* tests/Makefile.am(EXTRA_DIST): Adjust for run_parallel.h and
test_atomic_include.template files.
* tests/run_parallel.inc: Rename to tests/run_parallel.h.
* test_atomic.template: Rename to test_atomic_include.template.
* test_atomic.c, test_malloc.c: Adjust included file name.
Ivan Maidanski [Thu, 4 Aug 2011 18:49:51 +0000 (22:49 +0400)]
Fix compiler extra warnings.
* src/atomic_ops_stack.c (AO_stack_pop_explicit_aux_acquire): Remove
non-negative-value test for an unsigned value.
* src/atomic_ops_stack.h (AO_STACK_INITIALIZER): Add {} to match type
definition.
* tests/test_atomic.c (acqrel_thr): Fix code indentation.
* tests/test_atomic.c (test_and_set_thr): Print thread Id in case of error.
* tests/test_malloc.c (cons): Declare "i" local variable as unsigned (as it
is compared to another unsigned value).
* tests/test_malloc.c (check_list): Test upper bound as well, abort with the
appropriate message in case of mismatch.
* tests/test_malloc.c (run_one_test): Return "arg" parameter (to suppress
"unused parameter" compiler warning).
* 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.
ivmai [Tue, 7 Jun 2011 16:57:06 +0000 (16:57 +0000)]
2011-06-07 Ivan Maidanski <ivmai@mail.ru>
* src/atomic_ops/sysdeps/gcc/arm.h (AO_nop_full, AO_load): Do not
define for pre-ARMv6 directly (revert part of the previous
commit).
* src/atomic_ops/sysdeps/gcc/arm.h (AO_test_and_set,
AO_test_and_set_full): Refine the comment.
* src/atomic_ops/sysdeps/gcc/arm.h (AO_test_and_set_full): Define
SWP-based implementation at the end of file (if none of
AO_test_and_set functions are defined previously).
* src/atomic_ops/sysdeps/gcc/arm.h (AO_test_and_set): Remove
SWP-based implementation (revert part of the previous commit).
* src/atomic_ops/sysdeps/gcc/arm.h (AO_store): Remove redundant
definition at the file end (revert part of the previous commit).
ivmai [Tue, 7 Jun 2011 14:13:16 +0000 (14:13 +0000)]
2011-06-07 Ivan Maidanski <ivmai@mail.ru>
* src/atomic_ops/sysdeps/gcc/arm.h: Handle ARMv6M architecture.
* src/atomic_ops/sysdeps/gcc/arm.h (AO_test_and_set): Force "swp"
instruction usage (instead of ldrex/strex) if AO_FORCE_USE_SWP;
add a comment.
* src/atomic_ops/sysdeps/gcc/arm.h
(AO_compare_double_and_swap_double): Handle ARMv7EM architecture
(similar to ARMv7M).
* src/atomic_ops/sysdeps/gcc/arm.h (AO_test_and_set, AO_nop_full,
AO_load, AO_store): Define at the end of file (in case not defined
previously).
ivmai [Mon, 6 Jun 2011 20:28:43 +0000 (20:28 +0000)]
2011-06-06 Ivan Maidanski <ivmai@mail.ru>
* src/atomic_ops/sysdeps/gcc/arm.h (AO_THUMB_GO_ARM,
AO_THUMB_RESTORE_MODE): Use single-digit labels (to workaround
a bug in GCC v4.2.1 which reports "garbage following instruction"
otherwise).
* src/atomic_ops/sysdeps/gcc/arm.h (AO_compare_and_swap): Use "IT"
instruction only for Thumb-2 mode.
ivmai [Mon, 6 Jun 2011 13:34:11 +0000 (13:34 +0000)]
2011-06-06 Ivan Maidanski <ivmai@mail.ru>
* src/atomic_ops/sysdeps/gcc/arm.h (AO_THUMB_GO_ARM,
AO_THUMB_RESTORE_MODE, AO_THUMB_SWITCH_CLOBBERS): Define as empty
for Thumb-2 mode.
* src/atomic_ops/sysdeps/gcc/arm.h (AO_store, AO_test_and_set,
AO_fetch_and_add, AO_fetch_and_add1, AO_fetch_and_sub1,
AO_compare_and_swap, AO_compare_double_and_swap_double): Remove
unnecessary "memory" keyword from the list of clobbered registers
(revert part of the previous commit).
* src/atomic_ops/sysdeps/gcc/arm.h (AO_compare_and_swap): Add
a comment for "IT" instruction.
* src/atomic_ops/sysdeps/gcc/arm.h
(AO_compare_double_and_swap_double): Don't define on the
architectures where unimplemented; add a comment; replace return
(in the loop) statement with break.
ivmai [Mon, 6 Jun 2011 09:04:58 +0000 (09:04 +0000)]
2011-06-06 Ivan Maidanski <ivmai@mail.ru>
* src/atomic_ops/sysdeps/gcc/arm.h (AO_THUMB_GO_ARM,
AO_THUMB_RESTORE_MODE, AO_THUMB_SWITCH_CLOBBERS): Define new
macro (to switch temporarily CPU mode to ARM in inline assembler
if compiling in the Thumb mode and to restore it back on leave).
* src/atomic_ops/sysdeps/gcc/arm.h (AO_nop_full, AO_store,
AO_test_and_set, AO_fetch_and_add, AO_fetch_and_add1,
AO_fetch_and_sub1, AO_compare_and_swap, AO_test_and_set_full):
Enable compilation in the Thumb mode (use AO_THUMB_GO_ARM,
AO_THUMB_RESTORE_MODE and AO_THUMB_SWITCH_CLOBBERS macros).
* src/atomic_ops/sysdeps/gcc/arm.h (AO_store, AO_test_and_set,
AO_fetch_and_add, AO_fetch_and_add1, AO_fetch_and_sub1,
AO_compare_and_swap, AO_compare_double_and_swap_double): Add
"memory" to the list of clobbered registers.
ivmai [Fri, 3 Jun 2011 13:25:31 +0000 (13:25 +0000)]
2011-06-03 Ivan Maidanski <ivmai@mail.ru>
* tests/test_malloc.c (run_one_test): Test AO_malloc() result
(if out of memory then print the message and abort).
* tests/test_stack.c (add_elements): Ditto.
ivmai [Wed, 1 Jun 2011 22:43:19 +0000 (22:43 +0000)]
2011-06-01 Ivan Maidanski <ivmai@mail.ru>
* src/atomic_ops/sysdeps/gcc/arm.h
(AO_compare_double_and_swap_double,
AO_HAVE_compare_double_and_swap_double): Define only starting from
ARMv6K.
* src/atomic_ops/sysdeps/gcc/arm.h
(AO_compare_double_and_swap_double): Fix function name in
assembler code; replace while (1) loop with "do-while".
ivmai [Wed, 1 Jun 2011 13:57:18 +0000 (13:57 +0000)]
2011-06-01 Ivan Maidanski <ivmai@mail.ru>
* src/atomic_ops/sysdeps/sunc/x86.h (AO_test_and_set_full):
Specify "%b0" (instead of "%0") in "xchg" instruction (to
workaround a bug in Sun C 5.11).
* src/atomic_ops/sysdeps/sunc/x86_64.h (AO_test_and_set_full):
Ditto.
ivmai [Mon, 30 May 2011 16:52:54 +0000 (16:52 +0000)]
2011-05-30 Ivan Maidanski <ivmai@mail.ru>
* configure.ac (PIC): Add workaround for GCC v3.4.6 which does not
define the corresponding macro.
* configure.ac: Don't check for GCC twice.
* configure: Regenerate.
* tests/test_malloc.c (DEFAULT_NTHREADS): New macro.
* tests/test_malloc.c (run_one_test): Refine printed message (in
case of HAVE_MMAP).
* tests/test_malloc.c (main): Use DEFAULT_NTHREADS.
* tests/test_stack.c (main): Cast AO_stack_pop() returned pointer.
* src/atomic_ops_malloc.c (USE_MMAP_ANON, GC_MMAP_FLAGS,
OPT_MAP_ANON): New macro.
* src/atomic_ops_malloc.c (get_mmaped): Pass -1 (instead of 0) as
file descriptor to mmap() if MAP_ANONYMOUS (same as for MAP_ANON).
* src/atomic_ops_malloc.c (get_mmaped): Use USE_MMAP_ANON,
GC_MMAP_FLAGS and OPT_MAP_ANON macros; reformat code; check open()
returned value.