summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Properly place comment about minimal support in tile.hIvan Maidanski2022-07-301-2/+2
| | | | | * src/atomic_ops/sysdeps/gcc/tile.h: Move comment that the support is minimal to AO_DISABLE_GCC_ATOMICS part of code.
* Ensure result of AO_test_and_set is always AO_TS_CLEAR or AO_TS_SETIvan Maidanski2022-07-291-4/+8
| | | | | | | | | | | | | | (fix of commit cbbf8633) According to the GCC manual, __atomic_test_and_set() result type is Bool, thus it is not guaranteed to return AO_TS_SET value. (E.g., the function may return 1 while AO_TS_SET is 255, as observed on sparc64 with gcc-12.) * src/atomic_ops/sysdeps/gcc/generic.h [!AO_PREFER_GENERALIZED] (AO_test_and_set, AO_test_and_set_acquire, AO_test_and_set_release, AO_test_and_set_full): Return AO_TS_SET if __atomic_test_and_set() result is non-zero, AO_TS_CLEAR otherwise.
* Refine copyright terms in GPL source filesIvan Maidanski2022-05-199-59/+216
| | | | | | | | | | | | | | | | The GPL terms are copied from COPYING file. * src/atomic_ops_malloc.c: Refine GPL copyright text in the header comment by copying it as-is from COPYING file (as recommended in "Apply These Terms to Your New Programs" section). * src/atomic_ops_stack.c: Likewise. * tests/list_atomic.template: Likewise. * tests/run_parallel.h: Likewise. * tests/test_atomic.c: Likewise. * tests/test_atomic_include.template: Likewise. * tests/test_malloc.c: Likewise. * tests/test_stack.c: Likewise. * tests/test_atomic_include.h: Regenerate.
* Add FOSSA badge to READMEIvan Maidanski2022-05-191-1/+1
|
* Remove extra space after comma in MIT-like license termsIvan Maidanski2022-05-0116-16/+16
| | | | | | | | | | | | | | | | | | | | | | (reformatting) * LICENSE: Remove an extra space after comma in MIT-like license. * configure.ac: Remove an extra space after comma in license header comment. * src/atomic_ops/sysdeps/armcc/arm_v6.h: Likewise. * src/atomic_ops/sysdeps/gcc/aarch64.h: Likewise. * src/atomic_ops/sysdeps/gcc/alpha.h: Likewise. * src/atomic_ops/sysdeps/gcc/arm.h: Likewise. * src/atomic_ops/sysdeps/gcc/hexagon.h: Likewise. * src/atomic_ops/sysdeps/gcc/m68k.h: Likewise. * src/atomic_ops/sysdeps/gcc/mips.h: Likewise. * src/atomic_ops/sysdeps/gcc/powerpc.h: Likewise. * src/atomic_ops/sysdeps/gcc/riscv.h: Likewise. * src/atomic_ops/sysdeps/gcc/s390.h: Likewise. * src/atomic_ops/sysdeps/gcc/sh.h: Likewise. * src/atomic_ops/sysdeps/gcc/sparc.h: Likewise. * src/atomic_ops/sysdeps/gcc/x86.h: Likewise. * src/atomic_ops/sysdeps/sunc/x86.h: Likewise.
* Fix 'use of undeclared SIG_BLOCK' Clang error if -std=c89 on CygwinIvan Maidanski2022-02-201-1/+2
| | | | | * src/atomic_ops.c [__CYGWIN__ && !AO_USE_NO_SIGNALS && !_GNU_SOURCE] (_GNU_SOURCE): Define macro.
* Avoid AO_stack_t to cross CPU cache line boundaryIvan Maidanski2022-02-201-1/+31
| | | | | | | | | | | | | Issue #45 (libatomic_ops). Enforce proper alignment of AO_stack_t.AO_pa to avoid the structure value to cross the CPU cache line boundary. A workaround for almost-lock-free push/pop test failures on aarch64, at least. * src/atomic_ops_stack.h [!AO_STACK_ATTR_ALLIGNED] (AO_STACK_ATTR_ALLIGNED): Define. * src/atomic_ops_stack.h (AO_stack_t.AO_pa): Add AO_STACK_ATTR_ALLIGNED attribute.
* Repeat black list check on CAS fail in stack_push_explicit_aux_releaseIvan Maidanski2022-02-201-9/+8
| | | | | | | | | | | Also, execute the first read in a loop with an acquire barrier, and place black list checking as close to CAS as possible. * src/atomic_ops_stack.c [AO_USE_ALMOST_LOCK_FREE] (AO_stack_push_explicit_aux_release): Use acquire barrier to read list value (stored to next local variable); read list value and store it to x element before iterating over AO_stack_bl (and, thus, retry iterating over AO_stack_bl if CAS failed).
* Remove redundant assert in AO_stack_pop_explicit_aux_acquireIvan Maidanski2022-02-191-2/+1
| | | | | | * src/atomic_ops_stack.c [AO_USE_ALMOST_LOCK_FREE] (AO_stack_pop_explicit_aux_acquire): Remove assertion about i; replace "First" to "first" in comment.
* Travis CI: Test with NO_TIMESIvan Maidanski2022-02-181-1/+1
|
* Eliminate 'exper_n is declared but not used' compiler warning if NO_TIMESIvan Maidanski2022-02-181-1/+2
| | | | | | | (fix of commit cfd0593f3) * tests/test_stack.c (output_stat): Do not declare exper_n local variable if NO_TIMES; move exper_n to the inner scope.
* Split test_stack main into several functionsIvan Maidanski2022-02-181-106/+122
| | | | | | | | | | (refactoring) * tests/test_stack.c (run_one_experiment, run_all_experiments, output_stat): New functions (move relevant code from main). * tests/test_stack.c (main): Call run_all_experiments and output_stat. * tests/test_stack.c (run_one_experiment): Add assertion that the_list is empty before add_elements() call.
* Rename AO_real_head/next_ptr to AO_stack_head/next_ptrIvan Maidanski2022-02-182-6/+6
| | | | | | | | | | | | | | (fix of commit d29c0910d) * src/atomic_ops_stack.c (AO_real_head_ptr): Rename to AO_stack_head_ptr. * src/atomic_ops_stack.h (AO_real_head_ptr): Likewise. * src/atomic_ops_stack.c (AO_real_next_ptr): Rename to AO_stack_next_ptr. * src/atomic_ops_stack.h (AO_real_next_ptr): Likewise. * src/atomic_ops_stack.h [!AO_REAL_PTR_AS_MACRO] (AO_REAL_NEXT_PTR, AO_REAL_HEAD_PTR): Rename AO_real_head_ptr and AO_real_next_ptr to AO_stack_head_ptr and AO_stack_next_ptr, respectively.
* New AO_stack_is_lock_free API functionIvan Maidanski2022-02-184-4/+14
| | | | | | | | | | * README_stack.txt: Document AO_stack_is_lock_free; update documentation about AO_STACK_IS_LOCK_FREE. * src/atomic_ops_stack.c (AO_stack_is_lock_free): Implement. * src/atomic_ops_stack.h (AO_stack_is_lock_free): New API function declaration. * tests/test_stack.c (main): Use !AO_stack_is_lock_free() instead of AO_USE_ALMOST_LOCK_FREE.
* Eliminate 'le::next is never used' cppcheck warning in test_stackIvan Maidanski2022-02-181-0/+3
| | | | | | | (fix of commit 037938630) * tests/test_stack.c [CPPCHECK] (add_elements): Set le->e.next to 0 before AO_stack_push() call; add comment.
* Avoid breaking strict-aliasing rules in test_stackIvan Maidanski2022-02-171-17/+22
| | | | | | | | | | | | | * tests/test_stack.c (struct le): Add comment. * tests/test_stack.c (list_element): Define as union of AO_t and le. * tests/test_stack.c (add_elements): Update access to le caused by list_element type change; do not cast le to AO_t*. * tests/test_stack.c [VERBOSE_STACK] (print_list): Change type of p local variable from list_element* to AO_t*; update access to le caused by list_element type change. * tests/test_stack.c (check_list): Likewise. * tests/test_stack.c (run_one_test): Change type of t[] and le local variables from list_element* to AO_t*.
* Do not output multiple 'Found duplicate' error messages in test_stackIvan Maidanski2022-02-171-1/+1
| | | | | | | (fix of commit dfc5459a6) * tests/test_stack.c (check_list): Call abort() immediately if a duplicate element is found (instead of incrementing err_cnt).
* Avoid breaking strict-aliasing rules in cons() of test_mallocIvan Maidanski2022-02-171-3/+4
| | | | | | * tests/test_malloc.c (cons): Change type of extras local variable from int* to char*; set every sizeof(int) byte of extras[] to 42 (instead of setting every int value).
* Remove redundant cast to AO_t in lock-free AO_stack_pop_acquireIvan Maidanski2022-02-171-1/+1
| | | | | | | | | (refactoring) * 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): Remove redundant cast of next local variable to AO_t.
* Move gcc-4/alpha workaround outside AO_stack_pop_explicit_aux_acquireIvan Maidanski2022-02-171-12/+9
| | | | | | | | | | | | (refactoring) * src/atomic_ops_stack.c [AO_USE_ALMOST_LOCK_FREE && __alpha__ && __GNUC__==4] (AO_EXPECT_FALSE): Redefine to expr (before AO_stack_push_explicit_aux_release); move comment from AO_stack_pop_explicit_aux_acquire. * src/atomic_ops_stack.c [AO_USE_ALMOST_LOCK_FREE && __alpha__ && __GNUC__==4] (AO_stack_pop_explicit_aux_acquire): Use AO_EXPECT_FALSE (in the same way as for non-alpha case).
* Travis CI: Workaround 'value of AO_API unknown' cppcheck info messagesIvan Maidanski2022-02-171-1/+1
|
* Travis CI: Test almost-lock-free with a bigger AO_BL_SIZEIvan Maidanski2022-02-171-1/+1
|
* Revert "Travis CI: Test with CPPCHECK defined"Ivan Maidanski2022-02-161-1/+1
| | | | | | This reverts commit e56aa138b8fb8320d12ae22209f5e07c08ecc6c0. The reason: CPPCHECK is not intended to be used in runnable tests.
* Travis CI: Test with CPPCHECK definedIvan Maidanski2022-02-151-1/+1
|
* Travis CI: Output contents of test_stack.logIvan Maidanski2022-02-151-0/+1
|
* Fix sizeof passed to memset in AO_stack_initIvan Maidanski2022-02-151-1/+1
| | | | | | | (fix of commit e477b79ef) * src/atomic_ops_stack.c (AO_stack_init): Pass sizeof(AO_stack_t) to memset() instead of sizeof pointer; remove redundant cast of list.
* Travis CI: Test with custom N_EXPERIMENTSIvan Maidanski2022-02-151-0/+5
|
* Use builtin_expect in AO_stack_push_explicit_aux_releaseIvan Maidanski2022-02-151-2/+2
| | | | | | * src/atomic_ops_stack.c [AO_USE_ALMOST_LOCK_FREE] (AO_stack_push_explicit_aux_release): Use AO_EXPECT_FALSE() in comparison of entries and x_bits.
* Fix code indentation in main of test_stack.cIvan Maidanski2022-02-151-4/+5
| | | | | * tests/test_stack.c (main): Adjust indentation for ifdef VERBOSE_STACK and for "for" statement (for statistic output).
* Do not expose AO_REAL_HEAD/NEXT_PTR implementation in header by defaultIvan Maidanski2022-02-152-18/+37
| | | | | | | | | | | | | | | | | | | | | | | | Now AO_REAL_HEAD_PTR() and AO_REAL_NEXT_PTR() macros definition does not depend on whether the implementation is almost or fully lock-free. These macros just call the relevant implementation-dependent API function (AO_real_head_ptr or AO_real_next_ptr, respectively). If needed, the client could define AO_REAL_PTR_AS_MACRO (prior to include atomic_ops_stack.h) to continue using implementation-dependent definition of AO_REAL_HEAD_PTR and AO_REAL_NEXT_PTR macros. * src/atomic_ops_stack.c [!AO_REAL_PTR_AS_MACRO] (AO_REAL_PTR_AS_MACRO): Define (before include atomic_ops_stack.h). * src/atomic_ops_stack.c (AO_real_head_ptr, AO_real_next_ptr): Implement. * src/atomic_ops_stack.h [AO_USE_ALMOST_LOCK_FREE] (AO_stack_push_explicit_aux_release): Rename argument. * src/atomic_ops_stack.h [!AO_REAL_PTR_AS_MACRO] (AO_REAL_NEXT_PTR, AO_REAL_HEAD_PTR): Redirect to AO_real_next_ptr/AO_real_head_ptr(). * src/atomic_ops_stack.h (AO_stack_init): Move declaration down (to be after AO_stack_pop). * src/atomic_ops_stack.h (AO_real_head_ptr, AO_real_next_ptr): Declare AO_API function.
* Define AO_stack_t uniformlyIvan Maidanski2022-02-152-63/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Now AO_stack_t definition does not depend on whether the implementation is almost or fully lock-free. * src/atomic_ops_stack.c [USE_ALMOST_LOCK_FREE] (AO_stack_push_release, AO_stack_pop_acquire): Update access to list after changing its type to a union. * src/atomic_ops_stack.c [!USE_ALMOST_LOCK_FREE] (version, ptr, AO_stack_pop_acquire, AO_stack_push_release): Likewise. * src/atomic_ops_stack.h (AO_REAL_HEAD_PTR): Likewise. * 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_push_release): Rename version local variable to cversion. * src/atomic_ops_stack.c [!USE_ALMOST_LOCK_FREE] (ptr, version): Undefine (after last use). * src/atomic_ops_stack.h [!AO_HAVE_double_t]: Move include standard_ao_double_t.h upper to be before ifdef USE_ALMOST_LOCK_FREE. * src/atomic_ops_stack.h [!AO_BL_SIZE] (AO_BL_SIZE): Refine comment. * src/atomic_ops_stack.h (AO_BL_SIZE, AO_N_BITS, AO_BIT_MASK): Define even if not USE_ALMOST_LOCK_FREE. * src/atomic_ops_stack.h (AO__stack_ptr_aux): New struct type. * src/atomic_ops_stack.h (AO_stack_t): Change to union; define identically regardless of USE_ALMOST_LOCK_FREE; improve comment. * src/atomic_ops_stack.h (AO_STACK_INITIALIZER): Define identically regardless of USE_ALMOST_LOCK_FREE; add comment.
* Fix a typo in comment of AO_stack_push_explicit_aux_releaseIvan Maidanski2022-02-151-1/+1
| | | | | | * src/atomic_ops_stack.h [AO_USE_ALMOST_LOCK_FREE] (AO_stack_push_explicit_aux_release): Remove extra "an" (after "the") in comment.
* Implement AO_stack_init using memsetIvan Maidanski2022-02-141-19/+5
| | | | | | | * src/atomic_ops_stack.c (AO_stack_init): Collapse 2 definitions into single one; move the definition upper (to be outside of ifdef USE_ALMOST_LOCK_FREE); implement using memset (instead of initializing each field to 0).
* Eliminate 'function is never used' cppcheck warning for AO_stack_initIvan Maidanski2022-02-141-1/+8
| | | | | * tests/test_stack.c [CPPCHECK] (the_list): Define w/o initialization. * tests/test_stack.c [CPPCHECK] (main): Call AO_stack_init().
* Always export stack_init/push_release/pop_acquire from atomic_ops_gplIvan Maidanski2022-02-142-40/+40
| | | | | | | | | | | | | | | | | | Previously AO_stack_init() was declared as inline, and AO_stack_push_release() and AO_stack_pop_acquire() were define as macros in case of USE_ALMOST_LOCK_FREE. Now, these 3 functions are always defined in atomic_ops_stack.c. * src/atomic_ops_stack.c [USE_ALMOST_LOCK_FREE] (AO_stack_init, AO_stack_push_release, AO_stack_pop_acquire): Implement. * src/atomic_ops_stack.c [!USE_ALMOST_LOCK_FREE] (AO_stack_init): Likewise. * src/atomic_ops_stack.h (AO_stack_init): Remove inline function definition; declare as AO_API function instead. * src/atomic_ops_stack.h [USE_ALMOST_LOCK_FREE] (AO_stack_push_release, AO_stack_pop_acquire): Declare as AO_API function instead of macro. * src/atomic_ops_stack.h (AO_stack_push, AO_HAVE_stack_push, AO_stack_pop, AO_HAVE_stack_pop): Define macro unconditionally.
* Reformat atomic_ops_stack.c/h filesIvan Maidanski2022-02-143-363/+353
| | | | | | | | | | | | | | * README_stack.txt: Place quotes properly for "popped". * src/atomic_ops_stack.c [AO_USE_ALMOST_LOCK_FREE] (AO_stack_push_explicit_aux_release, PRECHECK, AO_load_next, AO_stack_pop_explicit_aux_acquire): Reformat comments, adjust code indentation. * src/atomic_ops_stack.c [!AO_USE_ALMOST_LOCK_FREE] (ptr, AO_stack_push_release, AO_stack_pop_acquire): Likewise. * src/atomic_ops_stack.h [AO_USE_ALMOST_LOCK_FREE] (AO_BL_SIZE, AO_stack_push_explicit_aux_release): Likewise. * src/atomic_ops_stack.h: Move copyright to be the first comment in the file.
* Better document test_stack internalsIvan Maidanski2022-02-141-1/+21
| | | | | | | | | | Also, add assertion that no overrun of t[] in run_one_test(). * tests/test_stack.c: Include assert.h. * tests/test_stack.c (add_elements, check_list, run_one_test, main): Add comments. * tests/test_stack.c (run_one_test): Add assertion that index is not greater than MAX_NTHREADS; refine error message when list is empty.
* Remove outdated comment about unsupported Win64 in atomic_ops_stack.hIvan Maidanski2022-02-091-1/+0
| | | | | | | (fix of commit f30c76e28) * src/atomic_ops_stack.h [AO_USE_ALMOST_LOCK_FREE && (__LP64__ || _LP64 || _WIN64)] (AO_N_BITS): Remove outdated comment about Win64.
* Allocate marks[] dynamically and report all found errors in test_stackIvan Maidanski2022-02-091-10/+16
| | | | | | | | * tests/test_stack.c (marks): Remove static variable. * tests/test_stack.c (check_list): Declare err_cnt and marks local variables; allocate marks with calloc() and free it at the end of function; increment err_cnt instead of abort (after fprintf(stderr)); call abort() at the end of function if err_cnt is non-zero.
* Rename fetch_and_add to fetch_then_add in test_stackIvan Maidanski2022-02-081-5/+5
| | | | | | | | | (refactoring) * tests/test_stack.c (fetch_and_add): Rename to fetch_then_add; refine comment. * tests/test_stack.c (run_one_test): Rename fetch_and_add to fetch_then_add.
* Travis CI: Update after VERBOSE macro renamingIvan Maidanski2022-02-081-3/+3
|
* Rename VERBOSE macro to VERBOSE_STACK in test_stackIvan Maidanski2022-02-081-11/+10
| | | | | | (refactoring) * tests/test_stack.c (VERBOSE): Rename to VERBOSE_STACK.
* Print message of almost-lock-free implementation in test_stack if usedIvan Maidanski2022-02-081-1/+4
| | | | | * tests/test_stack.c [AO_USE_ALMOST_LOCK_FREE] (main): Print a message that almost-lock-free implementation is used.
* Avoid code duplication in AO_stack_push_explicit_aux_releaseIvan Maidanski2022-02-081-19/+7
| | | | | | | | (refactoring) * src/atomic_ops_stack.c [AO_USE_ALMOST_LOCK_FREE && AO_BL_SIZE!=2] (AO_stack_push_explicit_aux_release): Remove code duplicated with AO_BL_SIZE==2 case.
* Eliminate '-pedantic is not option that controls warnings' GCC-6.3 messageIvan Maidanski2022-02-081-1/+1
| | | | | | | | | | (fix of commit cd7fd8539) Issue #27 (libatomic_ops). * src/atomic_ops/sysdeps/standard_ao_double_t.h [(__x86_64__ && AO_GCC_ATOMIC_TEST_AND_SET || __aarch64__) && !__ILP32__ && AO_GNUC_PREREQ(6,0)]: Use "-Wpedantic" (instead of "-pedantic").
* Mention MIT near core library licensing terms in LICENSE fileIvan Maidanski2022-01-051-4/+4
| | | | | | * LICENSE: Mention additionally that the low-level (core) part of the library is covered by MIT license (near the licensing terms); wrap a long line properly; update copyright year.
* Update copyright year in CMakeLists.txt and src/atomic_ops.hIvan Maidanski2022-01-052-2/+2
| | | | | * CMakeLists.txt: Update copyright year. * src/atomic_ops.h: Likewise.
* Support Elbrus 2000 (gcc/e2k)Ivan Maidanski2022-01-054-0/+32
| | | | | | | | | | This commit adds support of the clang compiler (in addition to gcc) for E2K architecture. * CMakeLists.txt [install_headers] (FILES): Install also gcc/e2k.h. * src/atomic_ops.h [__GNUC__ && !AO_USE_PTHREAD_DEFS && !__INTEL_COMPILER && __e2k__]: Include gcc/e2k.h. * src/atomic_ops/sysdeps/gcc/e2k.h: New file.
* Revert "Travis CI: Change _FORTIFY_SOURCE level to 3rd one"Ivan Maidanski2021-12-251-3/+3
| | | | | | | This reverts commit 3c086a4529c1b8a4be4796179989f034ab02eba1. Reason: -D_FORTIFY_SOURCE=3 causes '_FORTIFY_SOURCE redefined' warning by gcc-9 (Linux).
* Travis CI: Change _FORTIFY_SOURCE level to 3rd oneIvan Maidanski2021-12-251-3/+3
|