Ivan Maidanski [Sun, 23 Jun 2019 08:48:02 +0000 (11:48 +0300)]
Travis CI: Update to Xenial image
Xenial is used by default on Travis as of now.
This commit contains the following changes
* number of make parallel jobs is reduced to 8 when building cppcheck
* clang-5.0 is replaced with clang
* sudo:required is removed (for sanitized builds)
Ivan Maidanski [Wed, 13 Mar 2019 20:48:29 +0000 (23:48 +0300)]
Refine and reformat description of size prefix in README_details
* doc/README_details.txt (OPERATIONS): Refine information about the
size prefix.
* doc/README_details.txt (ORDERING CONSTRAINTS): Likewise.
* doc/README_details.txt (OPERATIONS): Put information about
AO_test_and_set after the section describing size prefix.
Ivan Maidanski [Wed, 13 Mar 2019 19:01:43 +0000 (22:01 +0300)]
Document CAS operations better in README_details
* doc/README_details.txt: Mention that CAS operation has a "fetch"
variant; mention that all provided CAS operations are strong (i.e.
cannot fail spuriously).
Ivan Maidanski [Wed, 13 Mar 2019 08:34:22 +0000 (11:34 +0300)]
Remove outdated notes in README_details
* doc/README_details.txt: Remove notes that work is in progress;
mention that many operation have size variants, not few; remove note
that no good reason to provide operations on standard int types.
Ivan Maidanski [Tue, 12 Mar 2019 17:57:56 +0000 (20:57 +0300)]
Update README_win32 to match Makefile.msft
* doc/README_win32.txt: Update info about MS build tools (remove
"currently"); specify that "check" goal should be passed to nmake to
build and run the tests; remove an outdated note that warnings about
the types of the "Interlocked" functions may be printed.
Ivan Maidanski [Tue, 26 Feb 2019 08:40:21 +0000 (11:40 +0300)]
Fix 'duplicate symbol' error for test_malloc/stack with static libs (OS X)
If configured with --enable-static (the default behavior), libtool
passes libatomic_ops.a to gcc twice (with a relative path and with
an absolute one) when linking test_malloc and test_stack because
the latter ones use also depend on libatomic_ops_gpl.a which, in turn,
depends on libatomic_ops.a. Double specification of libatomic_ops.a
confuses ld tool of MacOS 10.14.
The workaround is to omit libatomic_ops.la in *_LDADD specification
for test_malloc and test_stack at least when the shared libraries are
not requested.
* configure.ac (ENABLE_SHARED): New AM_CONDITIONAL.
* tests/Makefile.am (test_stack_LDADD, test_malloc_LDADD): Do not add
libatomic_ops.la unless ENABLE_SHARED; add comment.
Max Horn [Wed, 2 Jan 2019 14:47:21 +0000 (15:47 +0100)]
Fix 'AO_*_TS_T is not defined' compiler warnings (GCC-8)
* 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.
Ivan Maidanski [Wed, 19 Dec 2018 09:12:34 +0000 (12:12 +0300)]
Workaround 'argument to function assert is always 1' cppcheck warnings
* 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.
Ivan Maidanski [Wed, 5 Dec 2018 21:51:51 +0000 (00:51 +0300)]
Undefine AO_ARM_HAVE_* private macros after their usage
(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.
Ivan Maidanski [Sat, 10 Nov 2018 06:24:16 +0000 (09:24 +0300)]
Eliminate 'casting signed to bigger unsigned int' CSA warning (test_stack)
* tests/test_stack.c (run_one_test): Change type of index, i local
variables from int to unsigned.
* tests/test_stack.c [VERBOSE] (run_one_test): Change type of j local
variable from int to unsigned; update print format specifier
accordingly.
* tests/test_stack.c (main): Change type of i local variable from int
to unsigned.
Ivan Maidanski [Fri, 26 Oct 2018 18:33:46 +0000 (21:33 +0300)]
Use GCC atomic primitives for aarch64-ilp32 double-wide operations
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.
Ivan Maidanski [Mon, 3 Sep 2018 20:21:18 +0000 (23:21 +0300)]
Eliminate 'redundant blank line at start/end of block' CodeFactor warning
(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.
Ivan Maidanski [Fri, 18 May 2018 17:46:38 +0000 (20:46 +0300)]
Fix comments style in configure.ac and Makefile.am
(code refactoring)
Do not allow the comments that are meaningless in the auto-generated
configure and Makefile.in to be put to these files.
* Makefile.am (check-nolink): Change comment style from "#" to "##".
* configure.ac: Add the copyright and disclaimer.
* configure.ac: Change comment style from "#" to "dnl" for the comments
that are meaningless in auto-generated configure file.
YunQiang Su [Fri, 16 Mar 2018 06:58:22 +0000 (09:58 +0300)]
Support MIPS rel6
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").
Ivan Maidanski [Wed, 21 Feb 2018 07:58:33 +0000 (10:58 +0300)]
Enable CAS for byte and short on RISC-V
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.
Ivan Maidanski [Wed, 14 Feb 2018 06:54:29 +0000 (09:54 +0300)]
Convert atomic_ops_malloc.c to valid C++ code
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*.
Ivan Maidanski [Thu, 8 Feb 2018 22:12:27 +0000 (01:12 +0300)]
Convert tests to valid C++ code
* tests/test_malloc.c (cons, dummy_test, run_one_test): Add explicit
cast of void* pointer (returned by malloc) to the type of the variable
the pointer is assigned to.
* tests/test_stack.c (add_elements): Likewise.
Ivan Maidanski [Thu, 21 Dec 2017 07:49:27 +0000 (10:49 +0300)]
Use dedicated no_sanitize_thread load/store instead of copy_before_cas
(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.
Ivan Maidanski [Wed, 20 Dec 2017 07:31:07 +0000 (10:31 +0300)]
Fill in allocated memory with values depending on thread id (test_malloc)
* tests/test_malloc.c (run_one_test): Define new local variables a, b
(with the values depending on arg); replace 'a' and 'b' with a and b,
respectively; reformat the code; return NULL instead of arg; remove
the comment (the workaround is no longer needed).
Ivan Maidanski [Wed, 20 Dec 2017 07:22:20 +0000 (10:22 +0300)]
Eliminate GCC-5 ASan global-buffer-overflow false positive for AO_stack_bl
* 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).
Ivan Maidanski [Wed, 20 Dec 2017 07:11:54 +0000 (10:11 +0300)]
Mark unallocated/freed memory as inaccessible using ASan functionality
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.