summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix ifndef in msftc/arm64.hIvan Maidanski2021-10-211-1/+1
| | | | | | (fix of commit 1f8f5af84) * src/atomic_ops/sysdeps/msftc/arm64.h: Fix typo in #ifndef.
* Support double-wide CAS on armv7+ (MS VC)Ivan Maidanski2021-10-201-4/+60
| | | | | | | | | | | | | | | * src/atomic_ops/sysdeps/msftc/arm.h [_M_ARM>=6]: Remove TODO about double-wide operations support. * src/atomic_ops/sysdeps/msftc/arm.h [_M_ARM>=7 && !AO_NO_DOUBLE_CAS]: Include standard_ao_double_t.h. * src/atomic_ops/sysdeps/msftc/arm.h [_M_ARM>=7 && !AO_NO_DOUBLE_CAS] (_InterlockedCompareExchange64, _InterlockedCompareExchange64_acq, _InterlockedCompareExchange64_nf, _InterlockedCompareExchange64_rel): Specify as intrinsic. * src/atomic_ops/sysdeps/msftc/arm.h [_M_ARM>=7 && !AO_NO_DOUBLE_CAS] (AO_double_compare_and_swap, AO_double_compare_and_swap_acquire, AO_double_compare_and_swap_release, AO_double_compare_and_swap_full): Implement (similar to that in msftc/x86.h).
* Support double-wide CAS on UWP/arm64 (MS VC)Ivan Maidanski2021-10-205-4/+121
| | | | | | | | | | | | | | | Also, do not include msftc/x86_64.h if target is arm64 (i.e., new internal header is created - msftc/arm64.h). * src/Makefile.am (nobase_private_HEADERS): Add msftc/aarch64.h. * src/atomic_ops.h [(_MSC_VER || __DMC__ || __BORLANDC__ || __WATCOMC__ && __NT__) && _M_ARM64]: Include msftc/aarch64.h instead of msftc/x86_64.h. * src/atomic_ops/sysdeps/msftc/arm64.h: New file. * src/atomic_ops/sysdeps/msftc/x86_64.h: Include ordered_except_wr.h unconditionally (again). * src/atomic_ops/sysdeps/standard_ao_double_t.h [_M_ARM64 && _MSC_VER] (double_ptr_storage): Define; add comment.
* Do not assume 'ordered except earlier write' for UWP/arm64Ivan Maidanski2021-10-201-1/+2
| | | | | | | (fix of commit e078c7bb7) * src/atomic_ops/sysdeps/msftc/x86_64.h: Do not include ordered_except_wr.h if _M_ARM64.
* Force AO_USE_INTERLOCKED_INTRINSICS in msftc/x86_64.hIvan Maidanski2021-10-202-1/+4
| | | | | | | | | | (fix of commit 9831779d8) * src/atomic_ops/sysdeps/msftc/common32_defs.h: Mention 64-bit architectures in comment. * src/atomic_ops/sysdeps/msftc/x86_64.h [!AO_USE_INTERLOCKED_INTRINSICS] (AO_USE_INTERLOCKED_INTRINSICS): Define (before include common32_defs.h).
* Move all non-double intrinsic-based primitives to msftc/common32_defs.hIvan Maidanski2021-10-194-254/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * src/atomic_ops/sysdeps/msftc/arm.h: Include common32_defs.h (and define AO_ASSUME_WINDOWS98) after include test_and_set_t_is_ao_t.h and all_aligned_atomic_load_store.h. * src/atomic_ops/sysdeps/msftc/arm.h (AO_T_IS_INT): Define before include common32_defs.h. * src/atomic_ops/sysdeps/msftc/x86.h (AO_T_IS_INT): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER<=1400]: Add comment about WIN32_LEAN_AND_MEAN. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>=1800 || _MSC_VER>1400 && !_M_ARM] (_InterlockedAnd8, _InterlockedOr8, _InterlockedXor8): Do not declare via pragma if _MSC_VER>=1800 and AO_PREFER_GENERALIZED. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>=1800 || _MSC_VER>1400 && !_M_ARM] (AO_char_and_full, AO_char_or_full, AO_char_xor_full): Do not define if _MSC_VER>=1800 and AO_PREFER_GENERALIZED. * src/atomic_ops/sysdeps/msftc/common32_defs.h [(!AO_PREFER_GENERALIZED || !AO_ASSUME_WINDOWS98) && !AO_T_IS_INT] (_InterlockedIncrement64, _InterlockedDecrement64, _InterlockedExchangeAdd64): Add pragma intrinsic. * src/atomic_ops/sysdeps/msftc/common32_defs.h [!AO_T_IS_INT] (_InterlockedCompareExchange64): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [(!AO_PREFER_GENERALIZED || !AO_ASSUME_WINDOWS98) && !AO_T_IS_INT] (AO_fetch_and_add_full, AO_fetch_and_add1_full, AO_fetch_and_sub1_full): Use 64-bit intrinsic. * src/atomic_ops/sysdeps/msftc/common32_defs.h [AO_ASSUME_WINDOWS98 && !AO_T_IS_INT] (AO_fetch_compare_and_swap_full): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [!AO_T_IS_INT && !AO_PREFER_GENERALIZED] (AO_int_fetch_and_add_full, AO_int_fetch_and_add1_full, AO_int_fetch_and_sub1_full): Implement (move it from x86_64.h). * src/atomic_ops/sysdeps/msftc/common32_defs.h [AO_ASSUME_WINDOWS98 && !AO_T_IS_INT] (AO_int_fetch_compare_and_swap_full): Likewise. * src/atomic_ops/sysdeps/msftc/x86_64.h [!AO_ASSUME_WINDOWS98] (AO_ASSUME_WINDOWS98): Define. * src/atomic_ops/sysdeps/msftc/x86_64.h: Include common32_defs.h; do not include intrin.h (directly). * src/atomic_ops/sysdeps/msftc/x86_64.h (_InterlockedIncrement, _InterlockedIncrement64, _InterlockedDecrement, _InterlockedDecrement64, _InterlockedExchangeAdd, _InterlockedExchangeAdd64, _InterlockedCompareExchange, _InterlockedCompareExchange64, _InterlockedAnd8, _InterlockedCompareExchange16, _InterlockedOr8, _InterlockedXor8, _InterlockedIncrement16, _InterlockedDecrement16, _InterlockedCompareExchange8, _InterlockedExchangeAdd16, _InterlockedExchangeAdd8): Remove pragma. * src/atomic_ops/sysdeps/msftc/x86_64.h [AO_PREFER_GENERALIZED] (AO_fetch_and_add_full, AO_fetch_and_add1_full, AO_fetch_and_sub1_full, AO_int_fetch_and_add_full, AO_int_fetch_and_add1_full, AO_int_fetch_and_sub1_full): Remove implementation. * src/atomic_ops/sysdeps/msftc/x86_64.h (AO_fetch_compare_and_swap_full, AO_int_fetch_compare_and_swap_full): Likewise. * src/atomic_ops/sysdeps/msftc/x86_64.h [_MSC_VER>1400] (AO_char_and_full, AO_char_or_full, AO_char_xor_full, AO_short_fetch_compare_and_swap_full): Likewise. * src/atomic_ops/sysdeps/msftc/x86_64.h [_MSC_VER>1400 && AO_PREFER_GENERALIZED] (AO_short_fetch_and_add1_full, AO_short_fetch_and_sub1_full): Likewise. * src/atomic_ops/sysdeps/msftc/x86_64.h [_MSC_VER>=1800] (AO_char_fetch_compare_and_swap_full): Likewise. * src/atomic_ops/sysdeps/msftc/x86_64.h [_MSC_VER>=1800 && AO_PREFER_GENERALIZED] (AO_char_fetch_and_add_full, AO_short_fetch_and_add_full): Likewise. * src/atomic_ops/sysdeps/msftc/x86_64.h [AO_CMPXCHG16B_AVAILABLE]: Remove misleading comment; reformat code.
* Declare argument of AO_load_next with const in atomic_ops_stackIvan Maidanski2021-09-101-1/+1
| | | | | | | (refactoring) * src/atomic_ops_stack.c [AO_THREAD_SANITIZER] (AO_load_next): Add const to argument.
* Fix 'ISO C does not allow __alignof__' compiler warning on m68k and s390Ivan Maidanski2021-09-101-1/+1
| | | | | | | | | | | | (fix of commit 81242ce88) gcc-6.5/m68k and gcc-6.5/s390 (and earlier) produce a pedantic warning if __alignof__ keyword is used (unless -std=c11). Such behavior is not observed in gcc-7.5 or later. * src/atomic_ops.h [__STDC_VERSION__<201112L && !LINT2] (AO_ALIGNOF_SUPPORTED): Do not define unless AO_GNUC_PREREQ(7,5) (instead of AO_GNUC_PREREQ(4,3)).
* Fix size of local variable passed to cas[x] (gcc/sparc)George Koehler2021-06-111-1/+1
| | | | | | | | | Use the same type for input and output inline asm operands in AO_compare_and_swap_full(). * src/atomic_ops/sysdeps/gcc/sparc.h [!AO_NO_SPARC_V9 && !AO_GENERALIZE_ASM_BOOL_CAS] (AO_compare_and_swap_full): Change type of ret local variable from char to AO_t.
* Allow to generalize bool-CAS for sparc (gcc)Ivan Maidanski2021-06-111-1/+5
| | | | | * src/atomic_ops/sysdeps/gcc/sparc.h [!AO_NO_SPARC_V9] (AO_compare_and_swap_full): Do not define if AO_GENERALIZE_ASM_BOOL_CAS.
* Implement fetch-CAS for sparc (gcc)George Koehler2021-06-111-1/+15
| | | | | * src/atomic_ops/sysdeps/gcc/sparc.h [!AO_NO_SPARC_V9] (AO_fetch_compare_and_swap_full): Implement; remove TODO.
* Use __alignof__ instead of sizeof in atomic variable alignment assertionsIvan Maidanski2021-01-1415-16/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/atomic_ops.h [(AO_GNUC_PREREQ(4,3)||__STDC_VERSION__>=201112L) && !LINT2] (AO_ALIGNOF_SUPPORTED): Define (means __alignof__ is supported). * src/atomic_ops.h (AO_ASSERT_ADDR_ALIGNED): New internal macro (depending on AO_ALIGNOF_SUPPORTED). * src/atomic_ops.h: Update copyright year. * src/atomic_ops/sysdeps/all_aligned_atomic_load_store.h [AO_ALIGNOF_SUPPORTED] (AO_ACCESS_CHECK_ALIGNED): Define (regardless of __m68k__). * src/atomic_ops/sysdeps/loadstore/atomic_load.template (AO_XSIZE_load): Replace assert((addr&(sizeof(*addr)-1))==0) with AO_ASSERT_ADDR_ALIGNED(addr). * src/atomic_ops/sysdeps/loadstore/atomic_store.template (AO_XSIZE_store): Likewise. * src/atomic_ops/sysdeps/loadstore/double_atomic_load_store.h (AO_double_load, AO_double_store): Likewise. * src/atomic_ops/sysdeps/msftc/x86.h [AO_ASSUME_VISTA] (AO_double_compare_and_swap_full): Likewise. * src/atomic_ops/sysdeps/msftc/x86_64.h [AO_CMPXCHG16B_AVAILABLE && _MSC_VER>=1500] (AO_compare_double_and_swap_double_full): Likewise. * src/atomic_ops/sysdeps/loadstore/atomic_load.h: Regenerate. * src/atomic_ops/sysdeps/loadstore/atomic_store.h: Likewise. * src/atomic_ops/sysdeps/loadstore/char_atomic_load.h: Likewise. * src/atomic_ops/sysdeps/loadstore/char_atomic_store.h: Likewise. * src/atomic_ops/sysdeps/loadstore/int_atomic_load.h: Likewise. * src/atomic_ops/sysdeps/loadstore/int_atomic_store.h: Likewise. * src/atomic_ops/sysdeps/loadstore/short_atomic_load.h: Likewise. * src/atomic_ops/sysdeps/loadstore/short_atomic_store.h: Likewise.
* Workaround assertion violation in AO_load/store on m68kIvan Maidanski2021-01-121-1/+8
| | | | | | | Issue #48 (libatomic_ops). * src/atomic_ops/sysdeps/all_aligned_atomic_load_store.h (AO_ACCESS_CHECK_ALIGNED): Do not define if __m68k__; add comment.
* Decorate aligned attribute with double underscores in gcc/m68k.hIvan Maidanski2021-01-111-1/+1
| | | | | * src/atomic_ops/sysdeps/gcc/m68k.h (AO_t): Use __aligned__ instead of aligned.
* Fix link fail caused by missing GCC char/short atomic primitives on riscv64Ivan Maidanski2020-06-193-6/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #46 (libatomic_ops). gcc/riscv requires the client to add -latomic (or -pthread) flag if char- or short-width compare-and-swap or an arithmetic primitive is used. To avoid such a requirement, the corresponding AO primitives are not provided for now unless AO_PREFER_BUILTIN_ATOMICS is defined. * src/atomic_ops/sysdeps/gcc/generic-arithm.h: Regenerate. * src/atomic_ops/sysdeps/gcc/generic-arithm.template (AO_XSIZE_fetch_and_add_XBAR): Do not define if AO_NO_XSIZE_ARITHM. * src/atomic_ops/sysdeps/gcc/generic-arithm.template [!AO_SKIPATOMIC_ANY_and_ANY] (AO_XSIZE_and_XBAR): Likewise. * src/atomic_ops/sysdeps/gcc/generic-arithm.template [!AO_SKIPATOMIC_ANY_or_ANY] (AO_XSIZE_or_XBAR): Likewise. * src/atomic_ops/sysdeps/gcc/generic-arithm.template [!AO_SKIPATOMIC_ANY_xor_ANY] (AO_XSIZE_xor_XBAR): Likewise. * src/atomic_ops/sysdeps/gcc/riscv.h (AO_GCC_FORCE_HAVE_CAS): Define only if __clang__ or AO_PREFER_BUILTIN_ATOMICS; update comment. * src/atomic_ops/sysdeps/gcc/riscv.h [!__clang__ && !AO_PREFER_BUILTIN_ATOMICS && !__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1] (AO_NO_char_ARITHM): Define macro; add comment. * src/atomic_ops/sysdeps/gcc/riscv.h [!__clang__ && !AO_PREFER_BUILTIN_ATOMICS && !__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2] (AO_NO_short_ARITHM): Likewise. * src/atomic_ops/sysdeps/gcc/riscv.h (AO_NO_char_ARITHM, AO_NO_short_ARITHM): Undefine after include generic.h.
* Use GCC atomic intrinsics for s390x (clang 8.0+)Ivan Maidanski2020-04-071-3/+3
| | | | | | | | | | | | * src/atomic_ops/sysdeps/gcc/s390.h [AO_CLANG_PREREQ(8,0) && __s390x__ && !AO_DISABLE_GCC_ATOMICS]: Include generic.h. * src/atomic_ops/sysdeps/gcc/s390.h [!(AO_CLANG_PREREQ(8,0) && __s390x__ && !AO_DISABLE_GCC_ATOMICS)]: Do not include ordered_except_wr.h, all_aligned_atomic_load_store.h, test_and_set_t_is_ao_t.h. * src/atomic_ops/sysdeps/gcc/s390.h [!(AO_CLANG_PREREQ(8,0) && __s390x__ && !AO_DISABLE_GCC_ATOMICS)] (AO_compare_and_swap_full, AO_fetch_compare_and_swap_full): Do not define.
* Use GCC atomic intrinsics for s390x (GCC 5.4+)Ivan Maidanski2020-04-011-0/+11
| | | | | | | | | | | * src/atomic_ops/sysdeps/gcc/s390.h [AO_GNUC_PREREQ(5,4) && __s390x__ && !AO_DISABLE_GCC_ATOMICS]: Include generic.h. * src/atomic_ops/sysdeps/gcc/s390.h [!(AO_GNUC_PREREQ(5,4) && __s390x__ && !AO_DISABLE_GCC_ATOMICS)]: Do not include ordered_except_wr.h, all_aligned_atomic_load_store.h, test_and_set_t_is_ao_t.h. * src/atomic_ops/sysdeps/gcc/s390.h [!(AO_GNUC_PREREQ(5,4) && __s390x__ && !AO_DISABLE_GCC_ATOMICS)] (AO_compare_and_swap_full, AO_fetch_compare_and_swap_full): Do not define.
* Remove comments that gcc/powerpc.h and gcc/s390.h are untestedIvan Maidanski2020-03-312-3/+2
| | | | | | | | | * src/atomic_ops/sysdeps/gcc/powerpc.h [AO_DISABLE_GCC_ATOMICS && !AO_PREFER_GENERALIZED] (AO_test_and_set): Remove comment that the function is untested. * src/atomic_ops/sysdeps/gcc/s390.h: Remove comment that the all functions are untested; replace FIXME with TODO for test_and_set_t_is_ao_t.h.
* Replace x86 setz instruction by asm flag output operand (gcc)Frederic Recoules2020-03-111-5/+33
| | | | | | | | | | | | | | | | | | | If the compiler support flag outputs, then we can get rid of setz instruction. * src/atomic_ops/sysdeps/gcc/x86.h [AO_DISABLE_GCC_ATOMICS && !AO_GENERALIZE_ASM_BOOL_CAS && !AO_USE_SYNC_CAS_BUILTIN] (AO_compare_and_swap_full): If __GCC_ASM_FLAG_OUTPUTS__ is defined, then define dummy local variable and store cmpxchg result to it, fill in "result" varaible using @ccz asm specification, do not use asm setz instruction. * src/atomic_ops/sysdeps/gcc/x86.h [AO_GCC_ATOMIC_TEST_AND_SET && !AO_SKIPATOMIC_double_compare_and_swap_ANY] (AO_compare_double_and_swap_double_full): If __GCC_ASM_FLAG_OUTPUTS__ is defined, then do not define dummy local variable, fill in "result" variable using @ccz asm specification, do not use asm setz instruction, specify that old_val2 and old_val1 are modified by cmpxchg8/16b instruction.
* Turn off compare_double_and_swap_double_full PIC hack for GCC 5+ (x86)Frederic Recoules2020-03-111-2/+6
| | | | | | | | | | | Reuse of the PIC hard register, instead of using a fixed register, is implemented in Clang and GCC 5.1+, at least. * src/atomic_ops/sysdeps/gcc/x86.h [!(AO_GCC_ATOMIC_TEST_AND_SET && !AO_SKIPATOMIC_double_compare_and_swap_ANY) && !__x86_64__ && (!AO_USE_SYNC_CAS_BUILTIN || AO_GCC_ATOMIC_TEST_AND_SET) && __PIC__] (AO_compare_double_and_swap_double_full): Use non-PIC implementation if GCC version >= 5.1 or Clang version >= 4.
* Refactor gcc x86 memory constraintsFrederic Recoules2020-03-111-57/+73
| | | | | | | | | | | | | | | | * src/atomic_ops/sysdeps/gcc/x86.h [AO_DISABLE_GCC_ATOMICS] (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_char_and_full, AO_char_or_full, AO_char_xor_full, AO_short_and_full, AO_short_or_full, AO_short_xor_full, AO_test_and_set_full, AO_compare_and_swap_full, AO_fetch_compare_and_swap_full, AO_short_fetch_compare_and_swap_full, AO_int_fetch_compare_and_swap_full, AO_int_fetch_and_add_full, AO_int_and_full, AO_int_or_full, AO_int_xor_full): Merge "=m" output and "m" input entries into "+m" in-output one. * src/atomic_ops/sysdeps/gcc/x86.h [!(AO_GCC_ATOMIC_TEST_AND_SET && !AO_SKIPATOMIC_double_compare_and_swap_ANY)] (AO_compare_double_and_swap_double_full): Likewise.
* Fix gcc/sunc x86 AO_compare_double_and_swap_double missing side effectFrederic Recoules2020-03-112-8/+15
| | | | | | | | | | | | | | (fix of commits 1dc2fb3, 929954a) Bind E/RDX to a dummy output since cmpxchg8/16b clobbers it. * src/atomic_ops/sysdeps/gcc/x86.h [!(AO_GCC_ATOMIC_TEST_AND_SET && !AO_SKIPATOMIC_double_compare_and_swap_ANY)] (AO_compare_double_and_swap_double_full): Declare dummy local variable; specify "=d"(dummy) for asm code. * src/atomic_ops/sysdeps/sunc/x86.h [__i386 && !AO_NO_CMPXCHG8B || !__i386 && AO_CMPXCHG16B_AVAILABLE] (AO_compare_double_and_swap_double_full): Likewise.
* Fix 'AO_*_TS_T is not defined' compiler warnings (GCC-8)Max Horn2019-01-032-12/+14
| | | | | | | * src/atomic_ops.h [!AO_HAVE_CLEAR]: Replace "AO_AO_TS_T" with "defined(AO_AO_TS_T)" and AO_CHAR_TS_T" with "defined(AO_CHAR_TS_T)", respectively, in the "if" preprocessor directives. * src/atomic_ops/generalize.h: Likewise.
* Eliminate 'my_chunk_ptr-AO_initial_heap out of bounds' cppcheck warningIvan Maidanski2018-12-191-2/+2
| | | | | | * src/atomic_ops_malloc.c (get_chunk): Replace p1-p2>limit expression with (AO_t)p1>(AO_t)(p2+limit), where p1>=p2 and p2+limit does not overflow.
* Workaround 'argument to function assert is always 1' cppcheck warningsIvan Maidanski2018-12-191-1/+3
| | | | | | | | | | * src/atomic_ops_malloc.c (get_chunk): Skip assertion about my_chunk_ptr value alignment if CPPCHECK. * tests/test_malloc.c (DEFAULT_NTHREADS): Add comment about the maximum value. * tests/test_malloc.c (main): Remove assertion of nthreads value which is set to DEFAULT_NTHREADS (ideally there should be a static_assert). * tests/test_stack.c (main): Likewise.
* Undo incorrect fix of typos regarding 'an' articleIvan Maidanski2018-12-116-11/+13
| | | | | | | | | | | | | | | | | | | | | | (revert part of commit cbde60d) * src/atomic_ops/sysdeps/icc/ia64.h (AO_char_load_acquire): Fix typo ("an ld.acq") in comment. * src/atomic_ops/sysdeps/loadstore/acquire_release_volatile.template (AO_XSIZE_load_acquire): Likewise. * src/atomic_ops/sysdeps/icc/ia64.h (AO_short_load_acquire, AO_int_load_acquire): Add comment (similar to that of AO_char_load_acquire). * src/atomic_ops/sysdeps/loadstore/acquire_release_volatile.template (AO_XSIZE_store_release): Fix typo ("an st.rel") in comment. * src/atomic_ops/sysdeps/loadstore/acquire_release_volatile.h: Regenerate. * src/atomic_ops/sysdeps/loadstore/char_acquire_release_volatile.h: Likewise. * src/atomic_ops/sysdeps/loadstore/int_acquire_release_volatile.h: Likewise. * src/atomic_ops/sysdeps/loadstore/short_acquire_release_volatile.h: Likewise.
* Undefine AO_ARM_HAVE_* private macros after their usageIvan Maidanski2018-12-061-0/+5
| | | | | | | | (fix of commit 9b7cecba) * src/atomic_ops/sysdeps/gcc/arm.h (AO_ARM_HAVE_DMB, AO_ARM_HAVE_LDREX, AO_ARM_HAVE_LDREXBH, AO_ARM_HAVE_LDREXD, AO_ARM_HAVE_SWP): Undefine at the end of the file.
* Use standalone private macro to guard against AO_GCC_BARRIER redefinitionIvan Maidanski2018-12-065-5/+10
| | | | | | | | | | | | | | | | | (code refactoring) * src/atomic_ops/sysdeps/loadstore/acquire_release_volatile.h: Regenerate. * src/atomic_ops/sysdeps/loadstore/char_acquire_release_volatile.h: Likewise. * src/atomic_ops/sysdeps/loadstore/int_acquire_release_volatile.h: Likewise. * src/atomic_ops/sysdeps/loadstore/short_acquire_release_volatile.h: Likewise. * src/atomic_ops/sysdeps/loadstore/acquire_release_volatile.template (AO_GCC_BARRIER): Define only if AO_HAVE_GCC_BARRIER is undefined. * src/atomic_ops/sysdeps/loadstore/acquire_release_volatile.template [!AO_HAVE_GCC_BARRIER] (AO_HAVE_GCC_BARRIER): Define macro.
* Use GCC atomic primitives for aarch64-ilp32 double-wide operationsIvan Maidanski2018-10-261-4/+7
| | | | | | | | | | | | | | | | Issue #38 (libatomic_ops). Both gcc and clang have correct support of 64-bit atomic primitives on AArch64, so need to use inline assembly. * src/atomic_ops/sysdeps/gcc/aarch64.h [!__clang__] (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 __ILP32__ (unless AO_AARCH64_ASM_LOAD_STORE_CAS). * src/atomic_ops/sysdeps/gcc/aarch64.h [!__clang__ || AO_CLANG_PREREQ(3,9)] (AO_GCC_HAVE_double_SYNC_CAS): Do not define if __ILP32__; update gcc version in comment.
* Support UWP/arm64 targetTautvydas Zilys2018-10-261-1/+1
| | | | * src/atomic_ops.h [_MSC_VER && _M_ARM64]: Include msftc/x86_64.h.
* Fix 'Cannot implement CAS_full on this architecture' build error (nios2)Ivan Maidanski2018-10-251-1/+4
| | | | | * src/atomic_ops.h [__GNUC__ && !AO_USE_PTHREAD_DEFS && !__INTEL_COMPILER && __nios2__] (AO_CAN_EMUL_CAS): Define macro.
* Support ILP32 in AArch64 assembly routines (GCC)Frank Schaefer2018-10-241-16/+68
| | | | | | | | | | | | | | | Issue #38 (libatomic_ops). * src/atomic_ops/sysdeps/gcc/aarch64.h [(!__clang__ || AO_AARCH64_ASM_LOAD_STORE_CAS) && !AO_PREFER_GENERALIZED && __ILP32__] (AO_double_load, AO_double_load_acquire, AO_double_store, AO_double_store_release): Specify the size ("w") of arguments of the aarch64 instructions. * src/atomic_ops/sysdeps/gcc/aarch64.h [(!__clang__ || AO_AARCH64_ASM_LOAD_STORE_CAS) && __ILP32__] (AO_double_compare_and_swap, AO_double_compare_and_swap_acquire, AO_double_compare_and_swap_release, AO_double_compare_and_swap_full): Likewise.
* Workaround 'condition my_chunk_ptr is always false' cppcheck false positiveIvan Maidanski2018-10-191-6/+6
| | | | | * src/atomic_ops_malloc.c (get_chunk): Move get_mmaped() call into the for loop; replace return statement inside the loop with break.
* Fix typos in arm_v6.h, ia64.h, acquire_release_volatile.templateIvan Maidanski2018-09-137-15/+13
| | | | | | | | | | | | | | | | | | | | | | * src/atomic_ops/sysdeps/armcc/arm_v6.h [!AO_UNIPROCESSOR] (AO_nop_full): Fix typo ("a data memory barrier") in comment. * src/atomic_ops/sysdeps/icc/ia64.h (AO_char_load_acquire): Fix typo ("a ld.acq instruction") in comment. * src/atomic_ops/sysdeps/loadstore/acquire_release_volatile.template (AO_XSIZE_load_acquire): Likewise. * src/atomic_ops/sysdeps/icc/ia64.h (AO_short_load_acquire, AO_int_load_acquire): Remove comment duplicating that in AO_char_load_acquire. * src/atomic_ops/sysdeps/loadstore/acquire_release_volatile.template (AO_XSIZE_store_release): Fix typo ("a st.rel instruction") in comment. * src/atomic_ops/sysdeps/loadstore/acquire_release_volatile.h: Regenerate. * src/atomic_ops/sysdeps/loadstore/char_acquire_release_volatile.h: Likewise. * src/atomic_ops/sysdeps/loadstore/int_acquire_release_volatile.h: Likewise. * src/atomic_ops/sysdeps/loadstore/short_acquire_release_volatile.h: Likewise.
* Eliminate 'redundant blank line at start/end of block' CodeFactor warningIvan Maidanski2018-09-032-6/+0
| | | | | | | | | | | | | (code refactoring) * src/atomic_ops/sysdeps/armcc/arm_v6.h (AO_test_and_set): Remove redundant blank line at the start of a code block. * src/atomic_ops/sysdeps/hpc/ia64.h (AO_fetch_compare_and_swap_release, AO_char_fetch_compare_and_swap_acquire, AO_char_fetch_compare_and_swap_release, AO_short_fetch_compare_and_swap_acquire, AO_short_fetch_compare_and_swap_release): Remove redundant blank line at the end of a code block.
* Update copyright information in README and some header filesIvan Maidanski2018-07-2610-5/+10
| | | | | | | | | | | | | | | | * README.md (Copyright & Warranty): Add copyrights from the source code files. * src/atomic_ops.h: Update header copyright (add Ivan Maidanski). * src/atomic_ops/ao_version.h: Likewise. * src/atomic_ops/sysdeps/gcc/aarch64.h: Likewise. * src/atomic_ops/sysdeps/gcc/arm.h: Likewise. * src/atomic_ops/sysdeps/gcc/generic.h: Likewise. * src/atomic_ops/sysdeps/gcc/x86.h: Likewise. * src/atomic_ops/sysdeps/loadstore/double_atomic_load_store.h: Likewise. * src/atomic_ops/sysdeps/msftc/arm.h: Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h: Likewise. * src/atomic_ops/sysdeps/sunc/x86.h: Likewise.
* Fix 'undefined reference to __atomic_load/store/cas_16' error (gcc-7/x64)Ivan Maidanski2018-03-291-1/+9
| | | | | | | | | | Issue #34 (libatomic_ops). * src/atomic_ops/sysdeps/gcc/x86.h [!AO_DISABLE_GCC_ATOMICS && !__APPLE_CC__ && !__clang__ && AO_GNUC_PREREQ(7, 0) && !AO_PREFER_BUILTIN_ATOMICS && !AO_THREAD_SANITIZER && !__MINGW32__] (AO_SKIPATOMIC_double_compare_and_swap_ANY, AO_SKIPATOMIC_DOUBLE_LOAD_STORE_ANY): Define macro; add comment.
* Support MIPS rel6YunQiang Su2018-03-161-3/+12
| | | | | | | | | | | | | Don't set mips2/3 for mips r6. MIPS release 6 changes the encoding of some instructions, including ll/sc. Setting mips2/3 here produces the binary with the old encoding (not compatible with mips r6). This patch has no effect if gcc 4.9+ or clang 3.5+ unless AO_DISABLE_GCC_ATOMICS is defined manually in CFLAGS. * src/atomic_ops/sysdeps/gcc/mips.h [AO_DISABLE_GCC_ATOMICS && __mips_isa_rev>=6] (AO_MIPS_SET_ISA): Define to empty string (instead of ".set mips2" or ".set mips3").
* Enable CAS for byte and short on RISC-VIvan Maidanski2018-02-213-1/+26
| | | | | | | | | | | | | | | | Issue #31 (libatomic_ops). At least for gcc-7.2.0 does not define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 and __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 macros but, nonetheless, all the provided CAS operations are lock-free (except for double-word). * src/Makefile.am (nobase_private_HEADERS): Add gcc/riscv.h entry. * src/atomic_ops.h [__GNUC__ && !AO_USE_PTHREAD_DEFS && !__INTEL_COMPILER && __riscv]: Include gcc/riscv.h file. * src/atomic_ops/sysdeps/gcc/riscv.h: New file (include generic.h). * src/atomic_ops/sysdeps/gcc/riscv.h (AO_GCC_FORCE_HAVE_CAS): Define before include generic.h (and undefined at the end of file); add comment about double-word operations.
* Remove gcc/nios2.h and gcc/riscv.h files, include gcc/generic.h directlyIvan Maidanski2018-02-194-68/+19
| | | | | | | | | | | | | | (code refactoring) * src/Makefile.am (nobase_private_HEADERS): Remove nios2.h, riscv.h entries. * src/atomic_ops.h [__GNUC__ && !AO_USE_PTHREAD_DEFS && !__INTEL_COMPILER]: Use #elif instead of #endif - #if pairs. * src/atomic_ops.h [__GNUC__ && !AO_USE_PTHREAD_DEFS && !__INTEL_COMPILER && (__nios2__ || __riscv)]: Do not include gcc/nios2.h and gcc/riscv.h files; gcc/generic.h is included instead. * src/atomic_ops/sysdeps/gcc/nios2.h: Delete file. * src/atomic_ops/sysdeps/gcc/riscv.h: Likewise.
* Add RISC-V supportShea Levy2018-02-193-0/+16
| | | | | | | | Issue #31 (libatomic_ops). * src/Makefile.am (nobase_private_HEADERS): Add riscv.h entry. * src/atomic_ops.h [__riscv]: Include riscv.h file. * src/atomic_ops/sysdeps/gcc/riscv.h: New file (just include generic.h).
* Convert atomic_ops_malloc.c to valid C++ codeIvan Maidanski2018-02-141-3/+4
| | | | | | | | | Explicit pointer casts are added where necessary. * src/atomic_ops_malloc.c [HAVE_MMAP] (get_mmaped): Cast result of mmap() to char* (when assigned to "result" local variable). * src/atomic_ops_malloc.c (AO_free): Cast AO_free_large() argument to char*.
* Fix public headers inclusion from clients C++ codeIvan Maidanski2018-02-097-1/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | Put declarations of exported variables and non-inline functions into extern "C" blocks. * src/atomic_ops/sysdeps/emul_cas.h [__cplusplus] (AO_fetch_compare_and_swap_emulation, AO_compare_double_and_swap_double_emulation, AO_store_full_emulation): Wrap the prototypes (but not included headers). * src/atomic_ops/sysdeps/gcc/x86.h [AO_WEAK_DOUBLE_CAS_EMULATION && __cplusplus] (AO_compare_double_and_swap_double_emulation): Likewise. * src/atomic_ops/sysdeps/generic_pthread.h [__cplusplus] (AO_pt_lock): Likewise. * src/atomic_ops/sysdeps/sunc/sparc.h [__cplusplus] (AO_test_and_set_full): Likewise. * src/atomic_ops_malloc.h [__cplusplus] (AO_free, AO_malloc, AO_malloc_enable_mmap): Likewise. * src/atomic_ops_stack.h [__cplusplus] (AO_stack_push_explicit_aux_release, AO_stack_pop_explicit_aux_acquire, AO_stack_init, AO_stack_push_release, AO_stack_pop_acquire): Likewise. * tests/test_atomic.c [AO_TEST_EMULATION && __cplusplus] (AO_store_full_emulation, AO_fetch_compare_and_swap_emulation, AO_compare_double_and_swap_double_emulation): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER<1400 && __cplusplus]: Adjust comment for the end of extern "C" block.
* Eliminate 'function is never used' cppcheck warning for load_before_casIvan Maidanski2017-12-281-1/+3
| | | | | | | | | (fix commit 441415c8) * src/atomic_ops_stack.c [!AO_USE_ALMOST_LOCK_FREE && AO_THREAD_SANITIZER && !AO_HAVE_compare_and_swap_double && !AO_HAVE_compare_double_and_swap_double] (load_before_cas): Define as macro (not as a static function).
* Update version info of libatomic_ops_gpl.so to match that of v7.6.2Ivan Maidanski2017-12-251-1/+1
| | | | | * src/Makefile.am (LIBATOMIC_OPS_GPL_VER_INFO): Increment revision (bump version info of libatomic_ops_gpl.so to 2:2:1).
* Use dedicated no_sanitize_thread load/store instead of copy_before_casIvan Maidanski2017-12-211-11/+34
| | | | | | | | | | | | | | | | | | | | (fix commits 6ffda1db, 110b0dcc) This is also a workaround for a TSan false positive reported in AO_stack_pop_acquire. * src/atomic_ops_stack.c (AO_copy_before_cas): Remove. * src/atomic_ops_stack.c (store_before_cas): New static function (or defined as a macro). * src/atomic_ops_stack.c [!USE_ALMOST_LOCK_FREE] (load_before_cas): Likewiese. * src/atomic_ops_stack.c (AO_stack_push_explicit_aux_release, AO_stack_push_release): Use store_before_cas instead of AO_copy_before_cas. * src/atomic_ops_stack.c [!USE_ALMOST_LOCK_FREE] (load_before_cas): Add volatile to addr argument if Clang. * src/atomic_ops_stack.c [!USE_ALMOST_LOCK_FREE] (AO_stack_pop_acquire): Use load_before_cas instead of AO_copy_before_cas.
* Workaround TSan false positive in AO_stack_pop_explicit_aux_acquireIvan Maidanski2017-12-212-7/+17
| | | | | | | | | | | | | | | | | | (fix commits c058d9d, 6ffda1db) The TSan-related workaround in AO_malloc is no longer needed. * src/atomic_ops_malloc.c [AO_THREAD_SANITIZER && AO_USE_ALMOST_LOCK_FREE] (AO_malloc): Do not use AO_store (always use *result=log_sz); remove comment. * src/atomic_ops_stack.c [AO_USE_ALMOST_LOCK_FREE && AO_THREAD_SANITIZER] (AO_load_next): New static function (with AO_ATTR_NO_SANITIZE_THREAD attribute); add comments. * src/atomic_ops_stack.c [AO_USE_ALMOST_LOCK_FREE && !AO_THREAD_SANITIZER] (AO_load_next): Define to AO_load. * src/atomic_ops_stack.c [AO_USE_ALMOST_LOCK_FREE] (AO_stack_pop_explicit_aux_acquire): Replace AO_load(first_ptr) with AO_load_next(first_ptr).
* New macro to select stack implementation based on CAS-doubleIvan Maidanski2017-12-211-5/+4
| | | | | | | | | | The macro is AO_STACK_PREFER_CAS_DOUBLE. This is only for testing. * src/atomic_ops_stack.c [!USE_ALMOST_LOCK_FREE && AO_HAVE_compare_double_and_swap_double && AO_STACK_PREFER_CAS_DOUBLE && AO_HAVE_compare_and_swap_double] (AO_stack_pop_acquire, AO_stack_pop_acquire): Use implementation based compare_and_swap_double instead of compare_double_and_swap_double); remove #error directive.
* Eliminate GCC-5 ASan global-buffer-overflow false positive for AO_stack_blIvan Maidanski2017-12-201-3/+3
| | | | | | * src/atomic_ops_stack.c [AO_USE_ALMOST_LOCK_FREE] (AO_stack_push_explicit_aux_release): Replace a->AO_stack_bl+i with &a->AO_stack_bl[i] (including the case of i==0).
* Mark unallocated/freed memory as inaccessible using ASan functionalityIvan Maidanski2017-12-201-0/+17
| | | | | | | | | | | | | | | Note: to disable it, AO_NO_MALLOC_POISON should be defined by client. * src/atomic_ops_malloc.c [AO_ADDRESS_SANITIZER && !AO_NO_MALLOC_POISON] (__asan_poison_memory_region, __asan_unpoison_memory_region): Prototype. * src/atomic_ops_malloc.c (ASAN_POISON_MEMORY_REGION, ASAN_UNPOISON_MEMORY_REGION): New macro. * src/atomic_ops_malloc.c (add_chunk_as): Call ASAN_POISON_MEMORY_REGION() for each pushed region. * src/atomic_ops_malloc.c (AO_malloc): Call ASAN_UNPOISON_MEMORY_REGION() for the returned memory region. * src/atomic_ops_malloc.c (AO_free): Call ASAN_POISON_MEMORY_REGION() before pushing the freed region to AO_free_list.