platform/upstream/libatomic_ops.git
8 years agoUse GCC atomic intrinsics for MIPS (GCC 4.9+ and clang 3.5+)
Ivan Maidanski [Mon, 4 Apr 2016 21:27:50 +0000 (00:27 +0300)]
Use GCC atomic intrinsics for MIPS (GCC 4.9+ and clang 3.5+)

* src/atomic_ops/sysdeps/gcc/mips.h: Include generic.h and do not
include all_aligned_atomic_load_store.h if AO_PREFER_BUILTIN_ATOMICS or
GCC 4.9+ or clang 3.5+ unless AO_DISABLE_GCC_ATOMICS.
* src/atomic_ops/sysdeps/gcc/mips.h (AO_MIPS_SET_ISA, AO_MIPS_LL_1,
AO_MIPS_SC, AO_MIPS_LL, AO_nop_full, AO_fetch_and_add, AO_test_and_set,
AO_compare_and_swap, AO_fetch_compare_and_swap): Do not define if
generic.h included.

8 years agoImplement CAS_acquire/release/full using __atomic_compare_exchange_n (gcc)
Ivan Maidanski [Fri, 8 Apr 2016 08:29:08 +0000 (11:29 +0300)]
Implement CAS_acquire/release/full using __atomic_compare_exchange_n (gcc)

* src/atomic_ops/sysdeps/gcc/generic-small.h: Regenerate.
* src/atomic_ops/sysdeps/gcc/generic-small.template
(AO_XSIZE_fetch_compare_and_swap, AO_XSIZE_compare_and_swap): Use
__atomic_compare_exchange_n(RELAXED) instead of
__sync_val/bool_compare_and_swap.
* src/atomic_ops/sysdeps/gcc/generic.h (AO_double_compare_and_swap):
Likewise.
* src/atomic_ops/sysdeps/gcc/generic-small.template
[AO_GCC_HAVE_XSIZE_SYNC_CAS] (AO_XSIZE_fetch_compare_and_swap_acquire,
AO_XSIZE_fetch_compare_and_swap_release,
AO_XSIZE_fetch_compare_and_swap_full): New inline function; remove
TODO item.
* src/atomic_ops/sysdeps/gcc/generic-small.template
[AO_GCC_HAVE_XSIZE_SYNC_CAS && !AO_GENERALIZE_ASM_BOOL_CAS]
(AO_XSIZE_compare_and_swap_acquire, AO_XSIZE_compare_and_swap_release,
AO_XSIZE_compare_and_swap_full): Likewise.
* src/atomic_ops/sysdeps/gcc/generic.h [AO_GCC_HAVE_double_SYNC_CAS]
(AO_double_compare_and_swap_acquire,
AO_double_compare_and_swap_release, AO_double_compare_and_swap_full):
Likewise.
* src/atomic_ops/sysdeps/gcc/generic.h (AO_compare_and_swap_acquire):
Reformat code.

8 years agoAvoid atomic_compare_exchange_n if no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n
Ivan Maidanski [Wed, 6 Apr 2016 08:40:45 +0000 (11:40 +0300)]
Avoid atomic_compare_exchange_n if no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n

* src/atomic_ops/sysdeps/gcc/aarch64.h (AO_GCC_FORCE_HAVE_CAS,
AO_GCC_HAVE_double_SYNC_CAS): Define macro before include generic.h
if __clang__ (workaround).
* src/atomic_ops/sysdeps/gcc/generic-small.h: Regenerate.
* src/atomic_ops/sysdeps/gcc/generic-small.template
(AO_XSIZE_fetch_compare_and_swap, AO_XSIZE_compare_and_swap): Do not
define unless AO_GCC_HAVE_XSIZE_SYNC_CAS.
* src/atomic_ops/sysdeps/gcc/generic.h (AO_GCC_HAVE_char_SYNC_CAS,
AO_GCC_HAVE_short_SYNC_CAS, AO_GCC_HAVE_int_SYNC_CAS,
AO_GCC_HAVE_SYNC_CAS): New internal macro (based on
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_<n> or AO_GCC_FORCE_HAVE_CAS presence).
* src/atomic_ops/sysdeps/gcc/generic.h (AO_GCC_HAVE_double_SYNC_CAS):
New internal macro if AO_HAVE_DOUBLE_PTR_STORAGE.
* src/atomic_ops/sysdeps/gcc/generic.h (AO_double_compare_and_swap):
Check AO_GCC_HAVE_double_SYNC_CAS instead of AO_HAVE_DOUBLE_PTR_STORAGE.

8 years agoEliminate redundant lwsync 2nd call in CAS_full on fail (gcc/PowerPC)
Ivan Maidanski [Tue, 5 Apr 2016 21:10:56 +0000 (00:10 +0300)]
Eliminate redundant lwsync 2nd call in CAS_full on fail (gcc/PowerPC)

* src/atomic_ops/sysdeps/gcc/powerpc.h (AO_compare_and_swap_full,
AO_fetch_compare_and_swap_full): Do not call AO_lwsync 2nd time if
CAS is not successful.

8 years agoDefine AO_TS_SET as __GCC_ATOMIC_TEST_AND_SET_TRUEVAL if applicable
Ivan Maidanski [Mon, 4 Apr 2016 06:58:22 +0000 (09:58 +0300)]
Define AO_TS_SET as __GCC_ATOMIC_TEST_AND_SET_TRUEVAL if applicable

* src/atomic_ops/sysdeps/gcc/aarch64.h (AO_GCC_ATOMIC_TEST_AND_SET):
Define (before include test_and_set_t_is_ao_t.h).
* src/atomic_ops/sysdeps/gcc/nios2.h (AO_GCC_ATOMIC_TEST_AND_SET):
Likewise.
* src/atomic_ops/sysdeps/test_and_set_t_is_ao_t.h: Refine comment.
* src/atomic_ops/sysdeps/test_and_set_t_is_char.h: Likewise.
* src/atomic_ops/sysdeps/test_and_set_t_is_ao_t.h (AO_TS_SET_TRUEVAL):
New internal macro (defined via __GCC_ATOMIC_TEST_AND_SET_TRUEVAL).
* src/atomic_ops/sysdeps/test_and_set_t_is_char.h (AO_TS_SET_TRUEVAL):
Likewise.
* src/atomic_ops/sysdeps/test_and_set_t_is_ao_t.h (AO_TS_val): Use
AO_TS_SET_TRUEVAL instead of 1.
* src/atomic_ops/sysdeps/test_and_set_t_is_char.h (AO_BYTE_TS_val):
Use AO_TS_SET_TRUEVAL instead of 0xff; reformat code.
* src/atomic_ops/sysdeps/test_and_set_t_is_char.h (AO_TS_t): Move down
(to be after AO_TS_SET).

8 years agoNew macro AO_PREFER_BUILTIN_ATOMICS to rely on C11 atomics fully (AArch64)
Ivan Maidanski [Fri, 1 Apr 2016 17:34:30 +0000 (20:34 +0300)]
New macro AO_PREFER_BUILTIN_ATOMICS to rely on C11 atomics fully (AArch64)

If AO_PREFER_BUILTIN_ATOMICS is defined then inline assembly
implementation is not used.

* src/atomic_ops/sysdeps/gcc/aarch64.h (AO_SKIPATOMIC_double_load,
AO_SKIPATOMIC_double_load_acquire): Define if AO_PREFER_BUILTIN_ATOMICS.
* src/atomic_ops/sysdeps/gcc/aarch64.h (AO_nop_write, AO_double_load,
AO_double_load_acquire, AO_double_store, AO_double_store_release,
AO_double_compare_and_swap, AO_double_compare_and_swap_acquire,
AO_double_compare_and_swap_release, AO_double_compare_and_swap_full):
Do not define if AO_PREFER_BUILTIN_ATOMICS.
* src/atomic_ops/sysdeps/gcc/aarch64.h (AO_nop_write): Add comment;
remove TODO.
* src/atomic_ops/sysdeps/gcc/generic.h: Remove TODO about including
this header for other targets.
* src/atomic_ops/sysdeps/gcc/generic.h (AO_double_load): Do not define
if AO_SKIPATOMIC_double_load.
* src/atomic_ops/sysdeps/gcc/generic.h (AO_double_load_acquire): Do not
define if AO_SKIPATOMIC_double_load_acquire.

8 years agoRemove obsolete information from README about C++0x standard future
Ivan Maidanski [Thu, 24 Mar 2016 20:32:39 +0000 (23:32 +0300)]
Remove obsolete information from README about C++0x standard future

* doc/README.txt (Future directions): Remove.

8 years agoUpdate ChangeLog file
Ivan Maidanski [Thu, 17 Mar 2016 08:29:13 +0000 (11:29 +0300)]
Update ChangeLog file

8 years agoUpdate ChangeLog file (v7.4 changes)
Ivan Maidanski [Thu, 17 Mar 2016 08:21:18 +0000 (11:21 +0300)]
Update ChangeLog file (v7.4 changes)

8 years agoUpdate ChangeLog file
Ivan Maidanski [Thu, 17 Mar 2016 07:23:42 +0000 (10:23 +0300)]
Update ChangeLog file
(v7.2 - v7.4 changes only)

8 years agoUpdate AUTHORS file
Ivan Maidanski [Tue, 15 Mar 2016 07:11:05 +0000 (10:11 +0300)]
Update AUTHORS file

8 years agoAdd initial nios2 architecture support
Marek Vasut [Tue, 15 Mar 2016 07:09:26 +0000 (10:09 +0300)]
Add initial nios2 architecture support

* src/Makefile.am (nobase_private_HEADERS): Add nios2.h.
* src/atomic_ops.h: Include nios2.h if __nios2__.
* src/atomic_ops/sysdeps/gcc/nios2.h: New file.

8 years agoUpdate AUTHORS file
Ivan Maidanski [Fri, 4 Mar 2016 18:12:53 +0000 (21:12 +0300)]
Update AUTHORS file

8 years agoInitial ibmc/powerpc (xlc) support
Fabrizio Fabbri [Wed, 2 Mar 2016 16:35:47 +0000 (11:35 -0500)]
Initial ibmc/powerpc (xlc) support

* src/atomic_ops/sysdeps/ibmc/powerpc.h: Include
test_and_set_t_is_ao_t.h.
* src/atomic_ops/sysdeps/ibmc/powerpc.h (AO_test_and_set,
AO_fetch_compare_and_swap): Implement.

8 years agoEliminate 'signed-to-unsigned value extension' compiler warning in AO_malloc
Ivan Maidanski [Mon, 8 Feb 2016 07:13:47 +0000 (10:13 +0300)]
Eliminate 'signed-to-unsigned value extension' compiler warning in AO_malloc

* src/atomic_ops_malloc.c (msbs): Change type from int to unsigned
char.
* src/atomic_ops_malloc.c (msb): Change return type from int to
unsigned.
* src/atomic_ops_malloc.c (msb, AO_malloc): Change type of v, result,
log_sz local variables from int to unsigned.

9 years agoSupport NaCl/arm
Ivan Maidanski [Wed, 14 Oct 2015 08:02:49 +0000 (11:02 +0300)]
Support NaCl/arm

* src/atomic_ops/sysdeps/gcc/arm.h (AO_MASK_PTR, AO_BR_ALIGN): New
macro (empty unless __native_client__).
* src/atomic_ops/sysdeps/gcc/arm.h (AO_THUMB_GO_ARM,
AO_THUMB_RESTORE_MODE, AO_store, AO_char_store, AO_short_store,
AO_test_and_set, AO_fetch_and_add, AO_fetch_and_add1,
AO_fetch_and_sub1, AO_and, AO_or, AO_xor, AO_char_fetch_and_add,
AO_short_fetch_and_add, AO_compare_and_swap,
AO_fetch_compare_and_swap): Insert AO_BR_ALIGN after label.
* src/atomic_ops/sysdeps/gcc/arm.h (AO_store, AO_char_store,
AO_short_store, AO_test_and_set, AO_fetch_and_add, AO_fetch_and_add1,
AO_fetch_and_sub1, AO_and, AO_or, AO_xor, AO_char_fetch_and_add,
AO_short_fetch_and_add, AO_compare_and_swap, AO_fetch_compare_and_swap,
AO_double_load, AO_double_store, AO_double_compare_and_swap,
AO_test_and_set_full): Insert AO_MASK_PTR before each pointer access.

9 years agoRemove TODO file (items moved to Issues on Github)
Ivan Maidanski [Wed, 30 Sep 2015 23:35:07 +0000 (02:35 +0300)]
Remove TODO file (items moved to Issues on Github)

9 years agoFix GCC 5.x compatibility for AArch64 double-wide primitives
Frank Schaefer [Tue, 9 Jun 2015 22:10:00 +0000 (17:10 -0500)]
Fix GCC 5.x compatibility for AArch64 double-wide primitives

Small change to make aarch64 support work with gcc 5.x. Otherwise it
demands gcc -latomic and still fails test_stack.

* src/atomic_ops/sysdeps/gcc/aarch64.h (AO_double_load,
AO_double_load_acquire, AO_double_store, AO_double_store_release,
AO_double_compare_and_swap, AO_double_compare_and_swap_acquire,
AO_double_compare_and_swap_release, AO_double_compare_and_swap_full):
Use assembly implementation even for GCC v5+ (not just GCC 4.x).

9 years agoNew configure option (--enable-werror) to treat warnings as compiler errors
Ivan Maidanski [Sun, 17 May 2015 18:16:29 +0000 (21:16 +0300)]
New configure option (--enable-werror) to treat warnings as compiler errors

* configure.ac (werror): Test --enable-werror option to add -Werror
to CFLAGS.

9 years agoUpdate AUTHORS file
Ivan Maidanski [Tue, 12 May 2015 21:46:40 +0000 (00:46 +0300)]
Update AUTHORS file

9 years agoSupport n32 ABI for mips64
Frank Schaefer [Sat, 9 May 2015 05:26:43 +0000 (05:26 +0000)]
Support n32 ABI for mips64

Without the proposed change, the existing preprocessor checks for
mips64 support do not account for the n32 ABI (when building with
"gcc -mabi=n32", test_atomic and test_stack both fail, and
test_malloc appears to hang indefinitely while spinning at 100%).

* src/atomic_ops/sysdeps/gcc/mips.h (AO_MIPS_SET_ISA, AO_MIPS_LL_1,
AO_MIPS_SC): Define depending on _MIPS_SIM value.

9 years agoUpdate ChangeLog file
Ivan Maidanski [Wed, 4 Feb 2015 17:57:58 +0000 (20:57 +0300)]
Update ChangeLog file

9 years agoUpdate ChangeLog file
Ivan Maidanski [Fri, 30 Jan 2015 16:59:54 +0000 (19:59 +0300)]
Update ChangeLog file
(v7.2 - v7.4 changes only)

9 years agoUpdate AUTHORS file
Ivan Maidanski [Fri, 30 Jan 2015 16:47:35 +0000 (19:47 +0300)]
Update AUTHORS file

9 years agoUpdate AUTHORS file
Ivan Maidanski [Fri, 9 Jan 2015 20:26:46 +0000 (23:26 +0300)]
Update AUTHORS file

9 years agoMinor fix of code alignment in mips AO_compare_and_swap
James Cowgill [Thu, 8 Jan 2015 16:14:22 +0000 (16:14 +0000)]
Minor fix of code alignment in mips AO_compare_and_swap

9 years agoRemove inclusion of acquire_release_volatile.h on mips
James Cowgill [Thu, 8 Jan 2015 16:05:57 +0000 (16:05 +0000)]
Remove inclusion of acquire_release_volatile.h on mips

I'm not entirely sure how this ended up here. It might have been the case
that MIPS processors used to do this, but the ISA manuals don't say anything
about volatile loads / stores having aquire / release semnatics, so just
remove it to be safe.

9 years agoUse LLD and SCD instructions on mips64
James Cowgill [Thu, 8 Jan 2015 16:00:38 +0000 (16:00 +0000)]
Use LLD and SCD instructions on mips64

10 years agoUpdate AUTHORS file
Ivan Maidanski [Wed, 29 Oct 2014 22:26:32 +0000 (01:26 +0300)]
Update AUTHORS file

10 years agoRelax shareability domain for dmb st in AO_nop_write (ARM/AArch64)
Steve Capper [Wed, 29 Oct 2014 22:16:14 +0000 (01:16 +0300)]
Relax shareability domain for dmb st in AO_nop_write (ARM/AArch64)

* src/atomic_ops/sysdeps/gcc/aarch64.h (AO_nop_write): Replace "dmb st"
to "dmb ishst" (this way the barriers will occupy the inner shareable
domain).
* src/atomic_ops/sysdeps/gcc/arm.h (AO_nop_write): Likewise.

10 years agoFix missing output folder on making auto-generated test files (Automake)
Ivan Maidanski [Sat, 25 Oct 2014 16:58:06 +0000 (20:58 +0400)]
Fix missing output folder on making auto-generated test files (Automake)

* tests/Makefile.am (test_atomic_include.h, list_atomic.c,
list_atomic.i): Add mkdir for output folder.

10 years agoUpdate AUTHORS file
Ivan Maidanski [Sat, 25 Oct 2014 07:37:41 +0000 (11:37 +0400)]
Update AUTHORS file

10 years agoFix missing output folder on making auto-generated headers (Automake)
Kochin Chang [Fri, 12 Sep 2014 17:35:53 +0000 (13:35 -0400)]
Fix missing output folder on making auto-generated headers (Automake)

Create the directories before sed needs them (otherwise build fails
when sed tries to redirect output to a non-existent directory in case
of build root folder is not identical to source root folder).

* src/Makefile.am (atomic_ops/generalize-small.h,
atomic_ops/generalize-arithm.h, atomic_ops/sysdeps/ao_t_is_int.h,
atomic_ops/sysdeps/gcc/generic-arithm.h,
atomic_ops/sysdeps/loadstore/*.h): Add mkdir for output folder.

10 years agoEliminate 'variable set but not used' Cppcheck warnings in test_stack
Ivan Maidanski [Fri, 13 Jun 2014 12:35:55 +0000 (16:35 +0400)]
Eliminate 'variable set but not used' Cppcheck warnings in test_stack

* tests/test_stack.c (run_one_test): Define "j" local variable only
if VERBOSE.
* tests/test_stack.c (main): Do not define "sum" local variable (and
don not compute the sum) if NO_TIMES.

10 years agoFix missing casts to match printf format specifier in test_atomic
Ivan Maidanski [Fri, 13 Jun 2014 08:17:08 +0000 (12:17 +0400)]
Fix missing casts to match printf format specifier in test_atomic

* tests/test_atomic.c (test_and_set_thr): Add missing casts to long
for locked_counter (which is unsigned long) to match printf format
specifier.

10 years ago.gitignore: Ignore .dirstamp
Ivan Maidanski [Mon, 26 May 2014 20:00:00 +0000 (00:00 +0400)]
.gitignore: Ignore .dirstamp

10 years ago.gitignore: Ignore tests/.libs (generated if configure --enable-shared)
Ivan Maidanski [Sun, 18 May 2014 13:28:54 +0000 (17:28 +0400)]
.gitignore: Ignore tests/.libs (generated if configure --enable-shared)

10 years agoFix makefile preventing AO_pause undefined in libatomic_ops_gpl
Pavel Raiskup [Tue, 13 May 2014 11:46:23 +0000 (13:46 +0200)]
Fix makefile preventing AO_pause undefined in libatomic_ops_gpl

* src/Makefile.am (libatomic_ops_gpl_la_LIBADD): New dependency.

10 years agoRestore contribution info in ChangeLog for authors not listed in git log
Ivan Maidanski [Sun, 4 May 2014 12:25:40 +0000 (16:25 +0400)]
Restore contribution info in ChangeLog for authors not listed in git log
(deleted in commit 36a9c66)

* ChangeLog (7.0, 1.0): Add information about contribution of persons
mentioned in AUTHORS but not recorded in git log.
* src/atomic_ops/sysdeps/gcc/cris.h: Move contribution information
from comment to ChangeLog.

10 years agoUpdate ChangeLog file
Ivan Maidanski [Fri, 2 May 2014 07:07:20 +0000 (11:07 +0400)]
Update ChangeLog file

10 years agoMerge pull request #8 from badboy/patch-1
Ivan Maidanski [Mon, 31 Mar 2014 21:58:31 +0000 (14:58 -0700)]
Merge pull request #8 from badboy/patch-1

Fix a typo in doc/README.txt (remove redundant "an" article)

10 years agoRemoved unnecessary "an"
Jan-Erik Rediger [Fri, 28 Mar 2014 13:12:31 +0000 (14:12 +0100)]
Removed unnecessary "an"

10 years agoUpdate emails/links due to project site transition
Ivan Maidanski [Thu, 20 Feb 2014 20:39:54 +0000 (00:39 +0400)]
Update emails/links due to project site transition

* AUTHORS: Update email.
* README.md: Update links to BDWGC/libatomic_ops site.
* doc/README_stack.txt: Likewise.
* README.md: Update mailing list info.
* configure.ac: Likewise.

10 years agoBump atomic_ops version
Ivan Maidanski [Fri, 31 Jan 2014 17:44:45 +0000 (21:44 +0400)]
Bump atomic_ops version

* README.md: Bump version to 7.5.0.
* configure.ac: Likewise.
* src/atomic_ops/ao_version.h (AO_VERSION_MINOR): Likewise.

10 years ago[7.4.0] libatomic_ops-7_4_0
Ivan Maidanski [Sun, 17 Nov 2013 15:15:26 +0000 (19:15 +0400)]
[7.4.0]

Bump version to 7.4.0; change policy regarding version numbers

* ChangeLog: Update.
* README.md: Bump version.
* configure.ac (AC_INIT): Likewise.
* src/atomic_ops/ao_version.h (AO_VERSION_MINOR): Likewise.
* src/atomic_ops/ao_version.h (AO_VERSION_ALPHA): Replace to
AO_VERSION_MICRO; add comment.

10 years agoPut README.md to 'dist' package (Automake)
Ivan Maidanski [Sun, 17 Nov 2013 15:06:53 +0000 (19:06 +0400)]
Put README.md to 'dist' package (Automake)

* Makefile.am (dist_pkgdata_DATA): Add README.md item.

11 years agoUpdate ChangeLog file
Ivan Maidanski [Sun, 10 Nov 2013 10:23:23 +0000 (14:23 +0400)]
Update ChangeLog file

11 years agoConvert README to Markdown format
Ivan Maidanski [Thu, 12 Sep 2013 05:35:59 +0000 (09:35 +0400)]
Convert README to Markdown format

* README: Rename to README.md; adjust formatting to follow Markdown
syntax.

11 years agoRemove broken link to INSTALL file from README
Ivan Maidanski [Tue, 3 Sep 2013 04:50:55 +0000 (08:50 +0400)]
Remove broken link to INSTALL file from README

* README (Installation and Usage): Remove reference to INSTALL file
(not generated by autoreconf as AM_INIT_AUTOMAKE specifies "foreign"
strictness).
* .gitignore (INSTALL): Remove.

11 years agoPut autogen.sh to 'dist' package (Automake)
Ivan Maidanski [Sat, 31 Aug 2013 09:22:57 +0000 (13:22 +0400)]
Put autogen.sh to 'dist' package (Automake)

* Makefile.am (EXTRA_DIST): Add "autogen.sh" item.

11 years ago.gitignore: Ignore test-driver (generated by autoreconf)
Ivan Maidanski [Sat, 31 Aug 2013 08:04:20 +0000 (12:04 +0400)]
.gitignore: Ignore test-driver (generated by autoreconf)

11 years ago.gitignore: Ignore test*.log, test*.trs
Ivan Maidanski [Sat, 31 Aug 2013 07:16:19 +0000 (11:16 +0400)]
.gitignore: Ignore test*.log, test*.trs
(Apply commit 5cce9c5 from 'release-7_2' branch.)

Conflicts:

    .gitignore

11 years agoUpdate ChangeLog file
Ivan Maidanski [Wed, 21 Aug 2013 12:14:14 +0000 (16:14 +0400)]
Update ChangeLog file

11 years agoDo not use LDREXD/STREXD for Clang3.2/arm (and earlier)
Ivan Maidanski [Sat, 17 Aug 2013 11:05:36 +0000 (15:05 +0400)]
Do not use LDREXD/STREXD for Clang3.2/arm (and earlier)

* src/atomic_ops/sysdeps/gcc/arm.h (AO_ARM_HAVE_LDREXD): Do not define
for pre-Clang3.3 (since it does not allocate register pairs for
LDREXD/STREXD instructions properly); add comment.

11 years agoFix ARM char/short fetch_and_add and double-CAS operands width (GCC/Clang)
Ivan Maidanski [Sat, 17 Aug 2013 09:58:59 +0000 (13:58 +0400)]
Fix ARM char/short fetch_and_add and double-CAS operands width (GCC/Clang)

* src/atomic_ops/sysdeps/gcc/arm.h (AO_char_fetch_and_add,
AO_short_fetch_and_add): Use 32-bit int type for "tmp" and "result"
local variables instead of char/short type (resolve Clang3.3 warning
"size being stored is truncated, use a modifier to specify the size"
enabled by -Wasm-operand-widths compiler option); cast "incr"
argument to int to prevent Clang3.2 warning about value
truncation.
* src/atomic_ops/sysdeps/gcc/arm.h (AO_double_compare_and_swap): Swap
assembly code operands ("new_val.AO_whole" and "addr") to prevent
Clang3.3 warning about operand truncation.

11 years agoFix ARMv7 LDREXD/STREXD double-wide operand specification (GCC/Clang)
Ivan Maidanski [Sat, 17 Aug 2013 07:48:59 +0000 (11:48 +0400)]
Fix ARMv7 LDREXD/STREXD double-wide operand specification (GCC/Clang)

* src/atomic_ops/sysdeps/gcc/arm.h (AO_double_load, AO_double_store,
AO_double_compare_and_swap): Specify that LDREXD and STREXD use 2
adjacent registers (thus preventing Clang3.3 from register allocation
failures leading to "registers may not be the same" or
"even register required" GAS errors).

11 years agoTests: workaround GCC 4.4.3 warning reported for list_atomic.c 'val'
Ivan Maidanski [Sat, 17 Aug 2013 09:04:23 +0000 (13:04 +0400)]
Tests: workaround GCC 4.4.3 warning reported for list_atomic.c 'val'

* tests/list_atomic.template (XSIZE_list_atomicXX): Use "static"
modifier for "val" local variable to initialize it (cannot use direct
assignment to zero because "val" type could be a SIMD vector type if
XCTYPE is AO_double_t) to workaround GCC v4.4.3
"'val' is used uninitialized in this function" warning reported for
AO_load.

11 years agoSupport ARMv8 target (gcc/arm)
Ivan Maidanski [Sat, 17 Aug 2013 08:13:40 +0000 (12:13 +0400)]
Support ARMv8 target (gcc/arm)

* src/atomic_ops/sysdeps/gcc/arm.h (__ARM_ARCH_8A__): Detect new macro
(treated same as __ARM_ARCH_7A__).
* src/atomic_ops/sysdeps/gcc/arm.h (AO_ARM_HAVE_SWP): Do not define
for ARMv8 (since SWP{B} obsoleted); add comment.
* src/atomic_ops/sysdeps/gcc/arm.h (AO_compare_and_swap): Add TODO
item (for deprecated IT block containing wide Thumb instruction).

11 years agotests: Fix makefile sed rule for list_atomic
Ivan Maidanski [Fri, 16 Aug 2013 21:06:28 +0000 (01:06 +0400)]
tests: Fix makefile sed rule for list_atomic

* tests/Makefile.am (test_atomic_include.h, list_atomic.c): Replace
all occurrences of 'XX' (instead of only the first one) on every line.

11 years agotests: Add char/short/int/AO_double_t and dd_acquire cases to list_atomic
Ivan Maidanski [Tue, 13 Aug 2013 20:40:04 +0000 (00:40 +0400)]
tests: Add char/short/int/AO_double_t and dd_acquire cases to list_atomic

* tests/Makefile.am (list_atomic.c): Iterate over XSIZE/XCTYPE (in
addition to XX); expand XX also as _dd_acquire_read.
* tests/list_atomic.template (XSIZE_list_atomicXX): Define 'val' local
variable only if used (needed for AO_double_t case).

11 years agotests: Add and/or/xor entries to list_atomic
Ivan Maidanski [Sun, 11 Aug 2013 10:57:35 +0000 (14:57 +0400)]
tests: Add and/or/xor entries to list_atomic

* tests/list_atomic.template (list_atomicXX): Add AO_XSIZE_andXX,
AO_XSIZE_orXX, AO_XSIZE_xorXX invocations.

11 years agotests: Parameterize list_atomic template with XSIZE
Ivan Maidanski [Sun, 11 Aug 2013 10:49:05 +0000 (14:49 +0400)]
tests: Parameterize list_atomic template with XSIZE

* tests/Makefile.am (list_atomic.c): Substitute XSIZE/XCTYPE for AO_t.
* tests/list_atomic.template (list_atomicXX): Parameterize with XSIZE
and XCTYPE (except for AO_nop and AO_test_and_set).

11 years agolist_atomic: Add makefile rule to test list_atomic.template syntax
Ivan Maidanski [Sun, 11 Aug 2013 07:33:12 +0000 (11:33 +0400)]
list_atomic: Add makefile rule to test list_atomic.template syntax

* tests/Makefile.am (BUILT_SOURCES, CLEANFILES): Add "list_atomic.o".
* tests/Makefile.am (list_atomic.o): New rule (to verify list_atomic.c
is valid C code).
* tests/list_atomic.template (list_atomicXX): Use "volatile" for "val"
local variable.
* tests/list_atomic.template (list_atomicXX): Define "oldval", "newval",
"ts" and "incr" local variables only if used; cast string literals to
void (to prevent compiler warnings).
* tests/list_atomic.template (list_atomicXX): Use AO_t type for "incr"
local variable instead of C long type.
* tests/list_atomic.template (list_atomicXX): Define "oldval",
"newval", "incr" as statitc local variables, and remove explicit
initialization to zero (to void problems with initialization of these
variables for AO_double_t case if the latter is a struct).

11 years agotests: Do not use deprecated AO_T and AO_TS_T
Ivan Maidanski [Sun, 11 Aug 2013 07:21:20 +0000 (11:21 +0400)]
tests: Do not use deprecated AO_T and AO_TS_T

* tests/list_atomic.template (list_atomicXX): Use AO_t instead of
deprecated AO_T.
* tests/list_atomic.template (list_atomicXX): Use AO_TS_t instead of
deprecated AO_TS_T.
* tests/test_atomic.c (lock): Likewise.

11 years agoFix typo in comment of generalize-small.template
Ivan Maidanski [Mon, 29 Jul 2013 21:18:38 +0000 (01:18 +0400)]
Fix typo in comment of generalize-small.template

* src/atomic_ops/generalize-arithm.template: Fix a typo in comment
("acquire").
* src/atomic_ops/generalize-arithm.h: Regenerate.

11 years agoAdd comment about store_full implementation for x86
Ivan Maidanski [Sun, 26 May 2013 13:16:20 +0000 (17:16 +0400)]
Add comment about store_full implementation for x86

* src/atomic_ops/sysdeps/gcc/x86.h: Add comment about AO_store_full
generalization.

11 years agoAdd non-generalized double-CAS-full implementation for AArch64
Ivan Maidanski [Sun, 26 May 2013 13:08:27 +0000 (17:08 +0400)]
Add non-generalized double-CAS-full implementation for AArch64

* src/atomic_ops/sysdeps/gcc/aarch64.h
(AO_double_compare_and_swap_full): New function.

11 years agoDefine AO_NO_PTHREADS in configure if no pthreads (Win32 and VxWorks)
Ivan Maidanski [Sun, 26 May 2013 12:32:32 +0000 (16:32 +0400)]
Define AO_NO_PTHREADS in configure if no pthreads (Win32 and VxWorks)

* configure.ac (have_pthreads): Do not define to true if check for
pthread_self failed.
* configure.ac (AO_NO_PTHREADS): Define if not have_pthreads.

11 years agoBetter document configure THREADDLLIBS variable
Ivan Maidanski [Sun, 26 May 2013 09:01:27 +0000 (13:01 +0400)]
Better document configure THREADDLLIBS variable

* configure.ac (THREADDLLIBS, have_pthreads): Add comments.

11 years agoUpdate AUTHORS
Ivan Maidanski [Sun, 26 May 2013 08:11:34 +0000 (12:11 +0400)]
Update AUTHORS

11 years agoEnable build using toolchain without pthreads
Gilles Talis [Sun, 26 May 2013 08:08:18 +0000 (12:08 +0400)]
Enable build using toolchain without pthreads

* src/atomic_ops.c: Include pthread.h only if not AO_NO_PTHREADS (new
macro).
* src/atomic_ops.c (AO_pt_lock): Define only unless AO_NO_PTHREADS.
* tests/test_atomic.c (main): Skip test_atomic_pthreads if both
AO_NO_PTHREADS and AO_USE_PTHREAD_DEFS are defined (preventing test
link failure if AO_NO_PTHREADS passed via CFLAGS).

11 years agoAdd comment about double-wide load/store on x86_64 (GCC)
Ivan Maidanski [Mon, 8 Apr 2013 19:52:44 +0000 (23:52 +0400)]
Add comment about double-wide load/store on x86_64 (GCC)

* src/atomic_ops/sysdeps/gcc/x86.h: Add comment about AO_double_load
and AO_double_store implementation in 64-bit mode; remove the
corresponding TODO item.

11 years agoFix generalized store_release_write for double-wide type on x64 (GCC)
Ivan Maidanski [Mon, 8 Apr 2013 18:33:25 +0000 (22:33 +0400)]
Fix generalized store_release_write for double-wide type on x64 (GCC)

* src/atomic_ops/generalize-small.template
(AO_XSIZE_store_release_write): Move store-write-based definition down
to follow AO_XSIZE_store_write one (since AO_double_store is currently
defined via CAS for gcc/x64).
* src/atomic_ops/generalize-small.h: Regenerate.

11 years agoUpdate AUTHORS
Ivan Maidanski [Wed, 3 Apr 2013 03:59:15 +0000 (07:59 +0400)]
Update AUTHORS

11 years agoFix AM_CONFIG_HEADER in configure for autoconf-2.69-1
Manuel Serrano [Wed, 3 Apr 2013 03:58:27 +0000 (07:58 +0400)]
Fix AM_CONFIG_HEADER in configure for autoconf-2.69-1

* configure.ac (AM_CONFIG_HEADER): Replace obsolete macro with with
AC_CONFIG_HEADERS one.

11 years agoGeneralize double_load/store for x86_64 (GCC)
Ivan Maidanski [Fri, 29 Mar 2013 04:55:13 +0000 (08:55 +0400)]
Generalize double_load/store for x86_64 (GCC)

* src/atomic_ops.h (AO_GENERALIZE_TWICE): Define in case of missing
double-wide load or store primitives while double-wide CAS is present
(required for x86-64, at least).

11 years agoFix fetch_compare_and_swap asm constraints in gcc/x86.h
Ivan Maidanski [Fri, 29 Mar 2013 04:00:42 +0000 (08:00 +0400)]
Fix fetch_compare_and_swap asm constraints in gcc/x86.h

* src/atomic_ops/sysdeps/gcc/x86.h (AO_fetch_compare_and_swap_full):
Use same asm constraints for old_val and new_val as in
AO_compare_and_swap_full.

11 years agoReformat asm instructions of sunc/x86.h
Ivan Maidanski [Fri, 29 Mar 2013 03:45:03 +0000 (07:45 +0400)]
Reformat asm instructions of sunc/x86.h

* src/atomic_ops/sysdeps/sunc/x86.h (AO_fetch_and_add_full,
AO_char_fetch_and_add_full, AO_short_fetch_and_add_full, AO_and_full,
AO_or_full, AO_xor_full, AO_compare_and_swap_full): Reformat code.

11 years agoFix asm constraints of primitives in sunc/x86.h
Ivan Maidanski [Fri, 29 Mar 2013 03:31:06 +0000 (07:31 +0400)]
Fix asm constraints of primitives in sunc/x86.h

* src/atomic_ops/sysdeps/sunc/x86.h (AO_fetch_and_add_full,
AO_char_fetch_and_add_full, AO_short_fetch_and_add_full, AO_and_full,
AO_or_full, AO_xor_full, AO_test_and_set_full,
AO_compare_and_swap_full, AO_compare_double_and_swap_double_full,
AO_int_fetch_and_add_full): Use "+m" asm constraint for *addr instead
of "=m" (because the value pointed by addr is read and written by the
code).
* src/atomic_ops/sysdeps/sunc/x86.h (AO_fetch_compare_and_swap_full):
Use same asm constraints and parameters order as in
AO_compare_and_swap_full.

11 years agoMerge branch 'add-aarch64-support'
Ivan Maidanski [Fri, 15 Mar 2013 20:23:26 +0000 (00:23 +0400)]
Merge branch 'add-aarch64-support'

11 years agoFix asm constraint of CAS memory operand for gcc/alpha
Ivan Maidanski [Wed, 13 Mar 2013 18:46:24 +0000 (22:46 +0400)]
Fix asm constraint of CAS memory operand for gcc/alpha

* src/atomic_ops/sysdeps/gcc/alpha.h (AO_compare_and_swap): Use "+m"
asm constraint for *addr instead of "=m" (because the value pointed by
addr is read and written by the code).

11 years agoFix asm constraint of fetch_and_add, test_and_set, fetch_CAS for MIPS (gcc)
Ivan Maidanski [Wed, 13 Mar 2013 18:41:58 +0000 (22:41 +0400)]
Fix asm constraint of fetch_and_add, test_and_set, fetch_CAS for MIPS (gcc)

* src/atomic_ops/sysdeps/gcc/mips.h (AO_fetch_and_add,
AO_test_and_set, AO_fetch_compare_and_swap): Use "+m" asm constraint
for *addr instead of "=m" (because the value pointed by addr is read
and written by the code).

11 years agoFix asm constraint of compare_and_swap for clang-3.1/mips
Ivan Maidanski [Tue, 12 Mar 2013 18:29:33 +0000 (22:29 +0400)]
Fix asm constraint of compare_and_swap for clang-3.1/mips

* src/atomic_ops/sysdeps/gcc/mips.h (AO_compare_and_swap): Use "+m"
asm constraint for *addr instead of "+R" (the letter is unsupported
by clang3.1 resulting in "invalid output constraint in asm" error).

11 years agoAlways use 'mfence' for nop_full if target CPU supports SSE2 (gcc/x86)
Ivan Maidanski [Sat, 9 Mar 2013 16:28:00 +0000 (20:28 +0400)]
Always use 'mfence' for nop_full if target CPU supports SSE2 (gcc/x86)

* src/atomic_ops/sysdeps/gcc/x86.h (AO_USE_PENTIUM4_INSTRS): Define
if __SSE2__ is defined; update comment (and remove TODO item).

11 years agoFix assembly comment prefix and identify memory clobbers for AArch64
Yvan Roux [Sat, 9 Mar 2013 13:00:43 +0000 (17:00 +0400)]
Fix assembly comment prefix and identify memory clobbers for AArch64

* src/atomic_ops/sysdeps/gcc/aarch64.h: Revert comments beginning
marker to '//' (since '@' is not supported for A64 assembler).
* src/atomic_ops/sysdeps/gcc/aarch64.h (AO_double_load): Add comment
about the need for STXP instruction; remove TODO item.
* src/atomic_ops/sysdeps/gcc/aarch64.h (AO_double_store): Add comment
about absence of "cc" in clobber lists; remove TODO item.
* src/atomic_ops/sysdeps/gcc/aarch64.h (AO_double_load,
AO_double_load_acquire, AO_double_store, AO_double_store_release,
AO_double_compare_and_swap, AO_double_compare_and_swap_acquire,
AO_double_compare_and_swap_release): Use Q constraint (instead of "r")
for 'addr' argument to instruct the compiler about memory clobbers.

11 years agoUse AO_EXPECT_FALSE for AArch64 double_load/store
Ivan Maidanski [Mon, 4 Mar 2013 21:02:19 +0000 (01:02 +0400)]
Use AO_EXPECT_FALSE for AArch64 double_load/store

* src/atomic_ops/sysdeps/gcc/aarch64.h (AO_HAVE_DOUBLE_PTR_STORAGE):
Do not check (since defined in standard_ao_double_t.h for AArch64).
* src/atomic_ops/sysdeps/gcc/aarch64.h (AO_double_load): Add TODO
items.
* src/atomic_ops/sysdeps/gcc/aarch64.h (AO_double_load,
AO_double_load_acquire, AO_double_store, AO_double_store_release):
Use AO_EXPECT_FALSE.

11 years agoWorkaround missing built-in double-wide primitives for AArch64 in gcc-4.7
Yvan Roux [Mon, 4 Mar 2013 20:25:33 +0000 (00:25 +0400)]
Workaround missing built-in double-wide primitives for AArch64 in gcc-4.7

* src/atomic_ops/sysdeps/gcc/aarch64.h (AO_double_load,
AO_double_load_acquire, AO_double_store, AO_double_store_release,
AO_double_compare_and_swap, AO_double_compare_and_swap_acquire,
AO_double_compare_and_swap_release): Define using inline assembly
(because GCC 4.7-2013.01 has no support of 16-byte atomic operations).
* src/atomic_ops/sysdeps/gcc/generic.h (AO_double_load,
AO_double_load_acquire, AO_double_store, AO_double_store_release,
AO_double_compare_and_swap): Do not define if the corresponding
AO_HAVE_double_X macro is defined.

11 years agogcc/x86.h: Add TODO items
Ivan Maidanski [Thu, 28 Feb 2013 19:02:07 +0000 (23:02 +0400)]
gcc/x86.h: Add TODO items

11 years agoMerge remote-tracking branch 'origin/master' into add-aarch64-support
Ivan Maidanski [Thu, 28 Feb 2013 18:40:01 +0000 (22:40 +0400)]
Merge remote-tracking branch 'origin/master' into add-aarch64-support

11 years agoMinimize gcc/generic-arithm template by factoring out barriers
Ivan Maidanski [Thu, 28 Feb 2013 18:38:25 +0000 (22:38 +0400)]
Minimize gcc/generic-arithm template by factoring out barriers
(code refactoring)

* src/Makefile.am (atomic_ops/sysdeps/gcc/generic-arithm.h): Iterate
over XBAR/XGCCBAR (in addition to XSIZE/XCTYPE).
* src/atomic_ops/sysdeps/gcc/generic-arithm.template: Parametrize all
primitives with XBAR (replacing AO none/acquire/release/full barriers)
and with XGCCBAR (replacing GCC atomic RELAXED/ACQUIRE/RELEASE/SEQ_CST
barriers, respectively).
* src/atomic_ops/sysdeps/gcc/generic-arithm.h: Regenerate.

11 years agoImplement char/short/int-wide primitives using GCC built-in atomic/sync
Ivan Maidanski [Thu, 28 Feb 2013 17:55:48 +0000 (21:55 +0400)]
Implement char/short/int-wide primitives using GCC built-in atomic/sync

* src/Makefile.am (EXTRA_DIST): Add gcc/generic-arithm.template,
gcc/generic-small.template entries.
* src/Makefile.am (nobase_private_HEADERS): Move gcc/generic-arithm.h,
atomic_ops/sysdeps/gcc/generic-small.h to BUILT_SOURCES.
* src/Makefile.am (atomic_ops/sysdeps/gcc/generic-arithm.h,
atomic_ops/sysdeps/gcc/generic-small.h): New rules (to generate
AO_char/short/int_X primitives included from gcc/generic.h file.
* src/atomic_ops/sysdeps/gcc/generic-arithm.template: New template
file (based on code moved from generic-arithm.h).
* src/atomic_ops/sysdeps/gcc/generic-small.template: New template file
(based on code moved from generic-small.h).
* src/atomic_ops/sysdeps/gcc/generic-arithm.h: Regenerate.
* src/atomic_ops/sysdeps/gcc/generic-small.h: Likewise.

11 years agoMove gcc-generic AO_t-wide primitives to generic-small/arithm headers
Ivan Maidanski [Thu, 28 Feb 2013 17:17:48 +0000 (21:17 +0400)]
Move gcc-generic AO_t-wide primitives to generic-small/arithm headers
(code refactoring)

* src/atomic_ops/sysdeps/gcc/generic-small.h: New file.
* src/atomic_ops/sysdeps/gcc/generic-arithm.h: Likewise.
* src/atomic_ops/sysdeps/gcc/generic.h: Include generic-small.h file.
* src/atomic_ops/sysdeps/gcc/generic.h (AO_load, AO_load_acquire,
AO_store, AO_store_release, AO_fetch_compare_and_swap,
AO_compare_and_swap): Move to generic-small.h file.
* src/atomic_ops/sysdeps/gcc/generic.h: Include generic-arithm.h file
unless AO_PREFER_GENERALIZED.
* src/atomic_ops/sysdeps/gcc/generic.h (AO_fetch_and_add,
AO_fetch_and_add_acquire, AO_fetch_and_add_release,
AO_fetch_and_add_full, AO_and, AO_and_acquire, AO_and_release,
AO_and_full, AO_or, AO_or_acquire, AO_or_release, AO_or_full, AO_xor,
AO_xor_acquire, AO_xor_release, AO_xor_full): Move to generic-arithm.h
file.
* src/Makefile.am (nobase_private_HEADERS): Add gcc/generic-arithm.h,
gcc/generic-small.h entries.

11 years agoDefine nop_write as 'dmb st' for AArch64
Ivan Maidanski [Thu, 28 Feb 2013 15:46:58 +0000 (19:46 +0400)]
Define nop_write as 'dmb st' for AArch64

* src/atomic_ops/sysdeps/gcc/aarch64.h (AO_nop_write): Define via asm
(dmb st) statement unless AO_UNIPROCESSOR (because it seems there is
no equivalent definition using compiler __atomic_thread_fence).
* src/atomic_ops/sysdeps/gcc/generic.h (AO_nop_write): Do not define
if already is.

11 years agoFix AO_double_t definition for AArch64
Ivan Maidanski [Thu, 28 Feb 2013 15:35:01 +0000 (19:35 +0400)]
Fix AO_double_t definition for AArch64

* src/atomic_ops/sysdeps/standard_ao_double_t.h (double_ptr_storage):
Define explicitly for AArch64 (use __int128 instead of long long).

11 years agoFix double_compare_and_swap compile-time error in gcc/generic.h
Yvan Roux [Thu, 28 Feb 2013 14:55:27 +0000 (18:55 +0400)]
Fix double_compare_and_swap compile-time error in gcc/generic.h

* src/atomic_ops/sysdeps/gcc/generic.h (AO_double_compare_and_swap):
Fix access to old_val value.

11 years agoRemove improper comment for AO_XSIZE_load_read
Ivan Maidanski [Thu, 28 Feb 2013 04:46:00 +0000 (08:46 +0400)]
Remove improper comment for AO_XSIZE_load_read

* src/atomic_ops/generalize-small.template (AO_XSIZE_load_read):
Remove improper comment (because nop barrier type matches that of
load primitive).
* src/atomic_ops/generalize-small.template (AO_XSIZE_store_write):
Reorder AO_HAVE_nop_write and AO_HAVE_XSIZE_store checking (to match
that for other primitives in this file).
* src/atomic_ops/generalize-small.h: Regenerate.

11 years agoImplement AO_and/or/xor efficiently for ARM
Ivan Maidanski [Thu, 14 Feb 2013 16:34:05 +0000 (20:34 +0400)]
Implement AO_and/or/xor efficiently for ARM

* src/atomic_ops/sysdeps/gcc/arm.h (AO_and, AO_or, AO_xor): Implement
directly using LDREX/STREX (enabled only if not AO_PREFER_GENERALIZED).

11 years agoAdd compile-time assertion for size of 'standard' AO_double_t
Ivan Maidanski [Thu, 14 Feb 2013 15:37:25 +0000 (19:37 +0400)]
Add compile-time assertion for size of 'standard' AO_double_t

* src/atomic_ops/sysdeps/standard_ao_double_t.h
(AO_double_t_size_static_assert): Add compile-time assertion for
AO_double_t size.

11 years agoFix (remove) invalid include of read_ordered.h for ARM
Ivan Maidanski [Thu, 14 Feb 2013 10:08:47 +0000 (14:08 +0400)]
Fix (remove) invalid include of read_ordered.h for ARM
(fix commit 2df9c1e partially)

* src/atomic_ops/sysdeps/gcc/arm.h: Do not include read_ordered.h
(because load_acquire should contain a DMB instruction in a multi-core
case, new load_acquire/read primitives implementation is generalized
using nop_full/read which either contain a DMB instruction, or is just
a compiler barrier for uniprocessor).
* src/atomic_ops/sysdeps/armcc/arm_v6.h: Likewise.
* src/atomic_ops/sysdeps/msftc/arm.h: Likewise.

11 years agoRevert "Fix read_ordered.h inclusion for ARM"
Ivan Maidanski [Thu, 14 Feb 2013 09:59:38 +0000 (10:59 +0100)]
Revert "Fix read_ordered.h inclusion for ARM"
(because it makes load_acquire/read incorrect for multi-core ARM)

This reverts commit fcc838be49c98486c26738764f895d34de0716be.