platform/upstream/libatomic_ops.git
11 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.

11 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).

11 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).

11 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.

11 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.

11 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).

11 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.

11 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.

11 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.

11 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.

11 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.

11 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.

11 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).

11 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.

11 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.

11 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).

11 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.

11 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.

11 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).

11 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.

11 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).

11 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.

11 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.

11 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.

11 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.

11 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.

11 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

11 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).

11 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.

11 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).

11 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.

11 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)

11 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.

11 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).

11 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).

11 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.

11 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.

11 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.

11 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).

11 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.

11 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.

11 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.

11 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.

11 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.

11 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).

11 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).

11 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.

11 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.

11 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

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

11 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.

11 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).

11 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.

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

11 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.

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

11 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.

11 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)

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

11 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.

12 years agoUpdate ChangeLog file (regarding v7.2d)
Ivan Maidanski [Mon, 2 Jul 2012 04:37:55 +0000 (08:37 +0400)]
Update ChangeLog file (regarding v7.2d)

12 years agoUpdate ChangeLog file
Ivan Maidanski [Sun, 1 Jul 2012 08:55:48 +0000 (12:55 +0400)]
Update ChangeLog file

12 years agoFix generalized AO_char/short_compare_and_swap/fetch_and_add CTYPE args
Ivan Maidanski [Sun, 1 Jul 2012 08:45:23 +0000 (12:45 +0400)]
Fix generalized AO_char/short_compare_and_swap/fetch_and_add CTYPE args

* 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.

12 years agoBump libatomic_ops version
Ivan Maidanski [Tue, 15 May 2012 07:36:37 +0000 (11:36 +0400)]
Bump libatomic_ops version

* README: Bump version to 7.3alpha3.
* configure.ac: Likewise.
* src/atomic_ops/ao_version.h (AO_VERSION_ALPHA): Likewise.

12 years ago[7.3alpha2] libatomic_ops-7_3alpha2
Ivan Maidanski [Fri, 11 May 2012 16:14:23 +0000 (20:14 +0400)]
[7.3alpha2]

Bump libatomic_ops version to 7.3alpha2

* ChangeLog: Set release dates.
* README: Bump version to 7.3alpha2.
* configure.ac: Likewise.
* src/atomic_ops/ao_version.h (AO_VERSION_ALPHA): Likewise.

12 years agoDefine AO_T_IS_INT for x32
H.J. Lu [Mon, 16 Apr 2012 16:23:51 +0000 (09:23 -0700)]
Define AO_T_IS_INT for x32

* src/atomic_ops/sysdeps/gcc/x86_64.h (AO_T_IS_INT): Defined
for x32.

12 years agoUpdate ChangeLog file
Ivan Maidanski [Tue, 1 May 2012 14:37:20 +0000 (18:37 +0400)]
Update ChangeLog file

12 years agoUpdate AUTHORS file
Ivan Maidanski [Tue, 1 May 2012 10:56:33 +0000 (14:56 +0400)]
Update AUTHORS file

12 years agoFix for x32 by removing 'q' suffix in x86-64 instructions
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.

* src/atomic_ops/sysdeps/gcc/x86_64.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 'q' suffix in asm instruction.

12 years agoFix autogen.sh to prevent reporting success if autoreconf failed
Ivan Maidanski [Wed, 28 Mar 2012 15:14:25 +0000 (19:14 +0400)]
Fix autogen.sh to prevent reporting success if autoreconf failed

* autogen.sh: Add "set -e" command to abort script execution on
autoreconf failure (thus not printing "ready" in that case).

12 years agoFix ChangeLog (regarding autoconf)
Ivan Maidanski [Wed, 28 Mar 2012 04:51:25 +0000 (08:51 +0400)]
Fix ChangeLog (regarding autoconf)

12 years agoUpdate ChangeLog
Ivan Maidanski [Wed, 28 Mar 2012 04:23:03 +0000 (08:23 +0400)]
Update ChangeLog

12 years agoFix configure to define __PIC__ macro explicitly only if not done by GCC
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.

12 years agoUpdate ChangeLog
Ivan Maidanski [Mon, 26 Mar 2012 04:52:17 +0000 (08:52 +0400)]
Update ChangeLog

12 years agoFix double_ptr_storage definition for GCC pre-v4 (x86_64)
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).

12 years agoFix a typo in comment in standard_ao_double_t.h
Ivan Maidanski [Mon, 26 Mar 2012 04:29:38 +0000 (08:29 +0400)]
Fix a typo in comment in standard_ao_double_t.h

12 years agoUpdate ChangeLog
Ivan Maidanski [Mon, 26 Mar 2012 04:21:47 +0000 (08:21 +0400)]
Update ChangeLog

12 years agoUse __builtin_expect in CAS failure loop condition checks (GCC only)
Ivan Maidanski [Mon, 26 Mar 2012 04:06:19 +0000 (08:06 +0400)]
Use __builtin_expect in CAS failure loop condition checks (GCC only)

* src/atomic_ops.c (lock, block_all_signals): Use AO_EXPECT_FALSE.
* src/atomic_ops.h (AO_EXPECT_FALSE): New macro.
* src/atomic_ops/generalize-small.template
(AO_XSIZE_fetch_and_add_full, AO_XSIZE_fetch_and_add_acquire,
AO_XSIZE_fetch_and_add_release): Use AO_EXPECT_FALSE for CAS failure
check.
* src/atomic_ops/generalize.h (AO_fetch_and_add_full,
AO_fetch_and_add_acquire, AO_fetch_and_add_release, AO_fetch_and_add,
AO_and_full, AO_or_full, AO_xor_full): Likewise.
* src/atomic_ops/sysdeps/gcc/arm.h
(AO_compare_double_and_swap_double): Likewise.
* src/atomic_ops_stack.c (AO_stack_push_explicit_aux_release,
AO_stack_pop_explicit_aux_acquire, AO_stack_push_release,
AO_stack_pop_acquire): Likewise.
* src/atomic_ops/generalize-small.h: Regenerate.

12 years agoUpdate ChangeLog
Ivan Maidanski [Mon, 19 Mar 2012 16:01:51 +0000 (20:01 +0400)]
Update ChangeLog

12 years agoUpdate ChangeLog
Ivan Maidanski [Wed, 7 Mar 2012 15:45:25 +0000 (19:45 +0400)]
Update ChangeLog

12 years agoFix AO_compare_double_and_swap_double_full for gcc/x86 (PIC mode)
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.

12 years agoUpdate TODO file (remove fixed item for clang/x86)
Ivan Maidanski [Wed, 7 Mar 2012 03:43:07 +0000 (07:43 +0400)]
Update TODO file (remove fixed item for clang/x86)

12 years agoFix AO_stack_push_release to workaround bug in clang-1.1/x86
Ivan Maidanski [Wed, 7 Mar 2012 03:41:23 +0000 (07:41 +0400)]
Fix AO_stack_push_release to workaround bug in clang-1.1/x86

* src/atomic_ops_stack.c (AO_stack_push_release): Make "cptr" local
variable volatile to workaround a bug in clang-1.1/x86 compiler; add
comment.

12 years agoFix a typo in 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.

12 years agoUpdate ChangeLog
Ivan Maidanski [Mon, 5 Mar 2012 16:51:28 +0000 (20:51 +0400)]
Update ChangeLog

12 years agoconfigure: Require automake 2.61 instead of 2.63
Ivan Maidanski [Mon, 5 Mar 2012 16:15:14 +0000 (20:15 +0400)]
configure: Require automake 2.61 instead of 2.63

* configure.ac (AC_PREREQ): Use value of 2.63 (relax requirement to
enable autoreconf on current Mac OS X).

12 years agoUpdate ChangeLog
Ivan Maidanski [Sun, 4 Mar 2012 18:43:18 +0000 (22:43 +0400)]
Update ChangeLog

12 years agoReplace pointer relational comparisons with non-pointer ones
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.

12 years agoFix a typo in comment
Ivan Maidanski [Sun, 4 Mar 2012 16:20:22 +0000 (20:20 +0400)]
Fix a typo in comment

* src/atomic_ops_malloc.h (AO_malloc_enable_mmap): Fix a typo in the
comment.

12 years agoconfigure: Require automake 2.63 (widely spread) instead of 2.64
Ivan Maidanski [Fri, 17 Feb 2012 15:15:41 +0000 (19:15 +0400)]
configure: Require automake 2.63 (widely spread) instead of 2.64

* configure.ac (AC_PREREQ): Use value of 2.63 (instead of 2.64).

12 years agoUpdate TODO file (add FIXME note for clang)
Ivan Maidanski [Tue, 7 Feb 2012 04:18:19 +0000 (08:18 +0400)]
Update TODO file (add FIXME note for clang)

12 years agoRemove unused and hide some inner symbols in atomic_ops_malloc
Ivan Maidanski [Mon, 6 Feb 2012 04:56:45 +0000 (08:56 +0400)]
Remove unused and hide some inner symbols in atomic_ops_malloc

* src/atomic_ops_malloc.c (AO_chunk_free_list): Remove unused global
variable.
* src/atomic_ops_malloc.c (msbs): Add 'const' keyword.
* src/atomic_ops_malloc.c (msb): Add 'static' keyword to inner
function declaration.

12 years agoSuppress compiler warning in atomic_ops_malloc
Ivan Maidanski [Mon, 6 Feb 2012 04:44:33 +0000 (08:44 +0400)]
Suppress compiler warning in atomic_ops_malloc

* src/atomic_ops_malloc.c (msb): Change shift-by-32 expression to
work around a warning issued by clang compiler.

12 years agoconfigure: Specify bug reports email in AC_INIT
Ivan Maidanski [Fri, 20 Jan 2012 18:36:39 +0000 (22:36 +0400)]
configure: Specify bug reports email in AC_INIT

12 years agoREADME: Add bug reports address
Ivan Maidanski [Fri, 20 Jan 2012 18:10:29 +0000 (22:10 +0400)]
README: Add bug reports address

12 years agotest_stack: check_list() code refactoring and 'marks' size optimization
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.

12 years agoChange function prototype specifications to follow strict ANSI C style
Ivan Maidanski [Thu, 19 Jan 2012 04:33:50 +0000 (08:33 +0400)]
Change function prototype specifications to follow strict ANSI C style

* tests/test_atomic.c (main): Put "void" keyword into the arguments
specification of the function prototype.
* tests/test_stack.c (main): Likewise.