summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* Refine copyright terms in GPL source filesIvan Maidanski2022-05-197-45/+192
| | | | | | | | | | | | | | | | 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.
* 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.
* New AO_stack_is_lock_free API functionIvan Maidanski2022-02-181-2/+1
| | | | | | | | | | * 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).
* 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).
* 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().
* 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.
* 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.
* 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.
* Explicitly outline symbols exported in AO shared librariesIvan Maidanski2021-11-081-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AO_DLL macro is defined by configure if building shared libraries; AO_DLL controls the definition of AO_API. (In case of a static build, AO_API is always defined to "extern".) * configure.ac [$enable_shared && !$enable_static] (CFLAGS): Perpend -DAO_DLL. * src/atomic_ops.c [!AO_BUILD] (AO_BUILD): Define before include atomic_ops.h. * src/atomic_ops.c (AO_pause): Add AO_API specifier. * src/atomic_ops.c [!_MSC_VER && !__MINGW32__ && !__BORLANDC__ || AO_USE_NO_SIGNALS] (AO_fetch_compare_and_swap_emulation, AO_compare_double_and_swap_double_emulation, AO_store_full_emulation): Likewise. * src/atomic_ops/sysdeps/emul_cas.h (AO_fetch_compare_and_swap_emulation, AO_compare_double_and_swap_double_emulation, AO_store_full_emulation): Likewise. * src/atomic_ops/sysdeps/generic_pthread.h (AO_pt_lock): Likewise. * src/atomic_ops_malloc.c (AO_malloc_enable_mmap, AO_malloc, AO_free): Likewise. * src/atomic_ops_malloc.h (AO_free, AO_malloc, AO_malloc_enable_mmap): Likewise. * src/atomic_ops_stack.c [AO_USE_ALMOST_LOCK_FREE] (AO_pause, AO_stack_push_explicit_aux_release, AO_stack_pop_explicit_aux_acquire): Likewise. * src/atomic_ops_stack.c (AO_stack_push_release, AO_stack_pop_acquire): Likewise. * src/atomic_ops_stack.h [AO_USE_ALMOST_LOCK_FREE] (AO_stack_push_explicit_aux_release, AO_stack_pop_explicit_aux_acquire): Likewise. * src/atomic_ops_stack.h (AO_stack_push_release, AO_stack_pop_acquire): Likewise. * tests/test_atomic.c [(!_MSC_VER && !__MINGW32__ && !__BORLANDC__ || AO_USE_NO_SIGNALS || AO_USE_WIN32_PTHREADS) && AO_TEST_EMULATION] (AO_store_full_emulation, AO_fetch_compare_and_swap_emulation): Likewise. * tests/test_atomic.c [(!_MSC_VER && !__MINGW32__ && !__BORLANDC__ || AO_USE_NO_SIGNALS || AO_USE_WIN32_PTHREADS) && AO_TEST_EMULATION && AO_HAVE_double_t] (AO_compare_double_and_swap_double_emulation): Likewise. * src/atomic_ops.c [(!_MSC_VER && !__MINGW32__ && !__BORLANDC__ || AO_USE_NO_SIGNALS) && !AO_NO_PTHREADS] (AO_pt_lock): Add declaration but with AO_API; move the definition out of extern C. * src/atomic_ops.h [!AO_API] (AO_API): Define (depending on AO_BUILD and AO_DLL). * src/atomic_ops_malloc.c [!AO_BUILD] (AO_BUILD): Define before include atomic_ops_malloc.h. * src/atomic_ops_stack.c [!AO_BUILD] (AO_BUILD): Define before include atomic_ops_stack.h.
* New configure option (--disable-gpl) to skip building of libatomic_ops_gplIvan Maidanski2021-11-021-9/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Makefile.am [ENABLE_DOCS] (dist_doc_DATA): Do not add COPYING, README_malloc.txt, README_stack.txt items unless ENABLE_GPL. * README.md (Installation and Usage): Add note that libatomic_ops_gpl.a is not built if --disable-gpl option is given to configure. * configure.ac (gpl): New AC_ARG_ENABLE. * configure.ac (ENABLE_GPL): New AM_CONDITIONAL. * src/Makefile.am (include_HEADERS): Do not add atomic_ops_malloc.h and atomic_ops_stack.h items unless ENABLE_GPL. * src/Makefile.am (lib_LTLIBRARIES): Do not add libatomic_ops_gpl.la unless ENABLE_GPL. * src/Makefile.am (libatomic_ops_gpl_la_SOURCES, libatomic_ops_gpl_la_LDFLAGS, libatomic_ops_gpl_la_LIBADD): Do not define unless ENABLE_GPL. * tests/Makefile.am (test_stack_SOURCES, test_stack_LDADD, test_malloc_SOURCES, test_malloc_LDADD): Likewise. * tests/Makefile.am [ENABLE_SHARED] (test_malloc_LDADD, test_stack_LDADD): Likewise. * tests/Makefile.am (TESTS): Do not add test_malloc$(EXEEXT) and test_stack$(EXEEXT) items unless ENABLE_GPL. * tests/Makefile.am (TEST_OBJS): Do not add test_malloc.o, test_stack.o items unless ENABLE_GPL. * tests/Makefile.am (check_PROGRAMS): Do not add test_malloc and test_stack items unless ENABLE_GPL. * tests/Makefile.am (check-gpl-without-test-driver): New PHONY goal. * tests/Makefile.am (check-without-test-driver): Depend also on check-gpl-without-test-driver; do not run test_stack and test_malloc directly.
* Support test_atomic with MS build w/o the need to run GNU make firstIvan Maidanski2021-10-271-0/+5265
| | | | | | | * .gitignore: Remove test_atomic_include.h. * src/Makefile.msft: Update usage comment (recommend to build "check" goal instead of "check-noautogen"). * tests/test_atomic_include.h: Regenerate (new file).
* Fix 'duplicate symbol' error for test_malloc/stack with static libs (OS X)Ivan Maidanski2019-02-261-4/+9
| | | | | | | | | | | | | | | | | 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.
* Workaround 'argument to function assert is always 1' cppcheck warningsIvan Maidanski2018-12-192-3/+1
| | | | | | | | | | * 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.
* Eliminate 'casting signed to bigger unsigned int' CSA warning (test_stack)Ivan Maidanski2018-11-101-10/+10
| | | | | | | | | | * 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.
* Convert tests to valid C++ codeIvan Maidanski2018-02-092-4/+4
| | | | | | | * 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.
* Fix public headers inclusion from clients C++ codeIvan Maidanski2018-02-091-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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 'using argument that points at uninitialized var' cppcheck errorIvan Maidanski2018-01-311-1/+1
| | | | | | * tests/list_atomic.template [AO_HAVE_test_and_setXX] (XSIZE_list_atomicXX): Initialize ts local variable (to AO_TS_INITIALIZER).
* Fix 'AO_pt_lock undefined' error if cross-compiling manually (MinGW)Ivan Maidanski2018-01-161-1/+2
| | | | | * tests/test_atomic.c [AO_USE_PTHREAD_DEFS] (main): Skip the test if __MINGW32__ (even if AO_NO_PTHREADS is not defined).
* Prevent too long run of test_atomic_generalized (especially with TSan)Ivan Maidanski2017-12-211-1/+1
| | | | | * tests/test_atomic.c [AO_PREFER_GENERALIZED] (NITERS): Set to a smaller value (the same one as for AO_USE_PTHREAD_DEFS).
* Fill in allocated memory with values depending on thread id (test_malloc)Ivan Maidanski2017-12-201-7/+7
| | | | | | | * 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).
* Do not test CHUNK_SIZE allocation if no mmap() available (test_malloc)Ivan Maidanski2017-12-191-1/+3
| | | | | | | (fix commit 29d91db) * tests/test_malloc.c (main): Do not call AO_malloc(CHUNK_SIZE) unless HAVE_MMAP.
* New macro (DONT_USE_MMAP) to support testing as if mmap() is unavailableIvan Maidanski2017-12-191-0/+4
| | | | | | * src/atomic_ops_malloc.c [DONT_USE_MMAP] (HAVE_MMAP): Undefine (after including config.h). * tests/test_malloc.c [DONT_USE_MMAP] (HAVE_MMAP): Likewise.
* Increase the default number of threads to 16 in test_malloc/stackIvan Maidanski2017-12-072-2/+2
| | | | | | | * tests/test_malloc.c [!DEFAULT_NTHREADS && HAVE_MMAP] (DEFAULT_NTHREADS): Change the value from 10 to 16. * tests/test_stack.c [!DEFAULT_NTHREADS] (DEFAULT_NTHREADS): Change the value from 4 to 16.
* Allow to alter DEFAULT/MAX_NTHREADS values in test_malloc/stackIvan Maidanski2017-12-073-12/+20
| | | | | | | | | | | | | | | (code refactoring) * tests/run_parallel.h [!MAX_NTHREADS] (MAX_NTHREADS): Define (move from test_malloc.c). * tests/run_parallel.h [USE_PTHREADS || USE_VXTHREADS || USE_WINTHREADS] (run_parallel): Replace 100 with MAX_NTHREADS. * tests/test_malloc.c (main): Add assertion that DEFAULT_NTHREADS is not greater than MAX_NTHREADS. * tests/test_stack.c (main): Likewise. * tests/test_stack.c [!DEFAULT_NTHREADS] (DEFAULT_NTHREADS): Define (to 4). * tests/test_stack.c (main): Use DEFAULT_NTHREADS (instead of 4).
* Test smallest allocation of large type (test_malloc)Ivan Maidanski2017-12-051-0/+12
| | | | | | | | | | * src/atomic_ops_malloc.c (AO_malloc_large): Add assertion that the stored size is greater than LOG_MAX_SIZE. * src/atomic_ops_malloc.c (AO_malloc): Add assertions for log_size. * tests/test_malloc.c (LOG_MAX_SIZE, CHUNK_SIZE): New macro (copied from atomic_ops_malloc.c). * tests/test_malloc.c (main): Call AO_free(0), AO_malloc(0), AO_malloc(CHUNK_SIZE-sizeof(AO_t)+1); add comment.
* Fix memory leak in test_mallocIvan Maidanski2017-12-031-0/+10
| | | | | * tests/test_malloc.c (free_list): New function definition. * tests/test_malloc.c (run_one_test): Call free_list(x) on return.
* Eliminate data race in cons() of test_mallocIvan Maidanski2017-11-281-7/+7
| | | | | | | | | | | | | (fix commit c058d9d) The data race has not affected the functionality of the test but this commit allows to avoid no_sanitize attribute for the function. * tests/test_malloc.c (cons): Remove AO_ATTR_NO_SANITIZE_THREAD attribute; Do not reset extra (use "%" operator to get my_extra value). * tests/test_malloc.c [AO_HAVE_fetch_and_add1] (cons): Change type of extra to AO_t, add volatile qualifier; use AO_fetch_and_add1 instead of "++" operator to update extra.
* Place no_sanitize attributes in a GCC-compliant wayIvan Maidanski2017-11-192-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (fix commits 9020c5db, c058d9dc) Now the attributes precede the function prototypes (the format is: <attribute> void f(void) <body>). * src/atomic_ops/generalize-arithm.template (AO_XSIZE_fetch_and_add_full, AO_XSIZE_fetch_and_add_acquire, AO_XSIZE_fetch_and_add_release, AO_XSIZE_fetch_and_add, AO_XSIZE_and_full, AO_XSIZE_or_full, AO_XSIZE_xor_full): Move AO_ATTR_NO_SANITIZE_THREAD attribute to the beginning of the function prototype (to be right before AO_INLINE). * src/atomic_ops/generalize-small.template (AO_XSIZE_load_read, AO_XSIZE_load_full, AO_XSIZE_load_acquire, AO_XSIZE_load, AO_XSIZE_store_write, AO_XSIZE_store, AO_XSIZE_store_release, AO_XSIZE_store_full): Likewise. * src/atomic_ops_stack.c [AO_USE_ALMOST_LOCK_FREE] (AO_stack_push_explicit_aux_release): Likewise. * src/atomic_ops_stack.c [!USE_ALMOST_LOCK_FREE] (AO_stack_push_release, AO_stack_pop_acquire): Likewise. * tests/test_atomic.c [AO_HAVE_test_and_set_acquire] (do_junk): Likewise. * tests/test_malloc.c (cons): Likewise. * src/atomic_ops/generalize-small.template (AO_XSIZE_store_write, AO_XSIZE_store, AO_XSIZE_store_release, AO_XSIZE_store_full): Move AO_ATTR_NO_SANITIZE_MEMORY attribute to the beginning of the function prototype. * src/atomic_ops/generalize-arithm.h: Regenerate. * src/atomic_ops/generalize-small.h: Likewise.
* Workaround Thread Sanitizer (TSan) false positive warningsIvan Maidanski2017-09-222-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/atomic_ops.h [__has_feature && __has_feature(thread_sanitizer)] (AO_THREAD_SANITIZER): New internal macro. * src/atomic_ops.h [!AO_ATTR_NO_SANITIZE_THREAD] (AO_ATTR_NO_SANITIZE_THREAD): Likewise. * src/atomic_ops/generalize-arithm.h: Regenerate. * src/atomic_ops/generalize-small.h: Likewise. * src/atomic_ops/generalize-arithm.template (AO_XSIZE_fetch_and_add_full, AO_XSIZE_fetch_and_add_acquire, AO_XSIZE_fetch_and_add_release, AO_XSIZE_fetch_and_add, AO_XSIZE_and_full, AO_XSIZE_or_full, AO_XSIZE_xor_full): Add AO_ATTR_NO_SANITIZE_THREAD attribute. * src/atomic_ops/generalize-small.template (AO_XSIZE_load_read, AO_XSIZE_load_full, AO_XSIZE_load_acquire, AO_XSIZE_load, AO_XSIZE_store_write, AO_XSIZE_store, AO_XSIZE_store_release, AO_XSIZE_store_full: Likewise. * src/atomic_ops_stack.c [AO_USE_ALMOST_LOCK_FREE] (AO_stack_push_explicit_aux_release): Likewise. * src/atomic_ops_stack.c [AO_HAVE_compare_double_and_swap_double] (AO_stack_push_release, AO_stack_pop_acquire): Likewise. * tests/test_malloc.c (cons): Likewise. * src/atomic_ops/sysdeps/gcc/x86.h [AO_GCC_ATOMIC_TEST_AND_SET && __clang__ && __x86_64__ && !__ILP32__ && AO_THREAD_SANITIZER] (AO_SKIPATOMIC_double_compare_and_swap_ANY, AO_SKIPATOMIC_double_load, AO_SKIPATOMIC_double_load_acquire, AO_SKIPATOMIC_double_store, AO_SKIPATOMIC_double_store_release): Define; update comment. * src/atomic_ops_malloc.c [AO_THREAD_SANITIZER] (AO_malloc, AO_free): Use AO_store/load to write/read log_sz value in object header. * tests/test_atomic.c (do_junk): New function (declared with AO_ATTR_NO_SANITIZE_THREAD attribute); multiply junk value by two different constant values. * tests/test_atomic.c (test_and_set_thr): Call do_junk() instead of operating on junk global variable directly.
* Workaround 'unused result' code defects in list_atomic.templateIvan Maidanski2017-07-241-7/+11
| | | | | | | | | | | | | | | | | | | | | * tests/list_atomic.template: Include stdlib.h (needed for exit() prototype). * tests/list_atomic.template [AO_HAVE_XSIZE_loadXX] (XSIZE_list_atomicXX): Cast AO_XSIZE_loadXX() result to void. * tests/list_atomic.template [AO_HAVE_XSIZE_fetch_and_addXX]: Cast AO_XSIZE_fetch_and_addXX() result to void. * tests/list_atomic.template [AO_HAVE_XSIZE_fetch_and_add1XX] (XSIZE_list_atomicXX): Cast AO_XSIZE_fetch_and_add1XX() result to void. * tests/list_atomic.template [AO_HAVE_XSIZE_fetch_and_sub1XX] (XSIZE_list_atomicXX): Cast AO_XSIZE_fetch_and_sub1XX() result to void. * tests/list_atomic.template [AO_HAVE_test_and_setXX] (XSIZE_list_atomicXX): Cast AO_test_and_setXX() result to void. * tests/list_atomic.template [AO_HAVE_XSIZE_compare_and_swapXX] (XSIZE_list_atomicXX): Call exit(1) if AO_XSIZE_compare_and_swapXX failed. * tests/list_atomic.template [AO_HAVE_XSIZE_fetch_compare_and_swapXX] (XSIZE_list_atomicXX): Call exit(1) if AO_XSIZE_fetch_compare_and_swapXX failed.
* Avoid misleading 'AO_t undefined' error if wrong atomic_ops.h includedIvan Maidanski2017-06-091-0/+4
| | | | | | | | This change might be useful e.g. in case of compilation by Hexagon SDK which has own atomic_ops.h file (not related to libatomic_ops). * tests/run_parallel.h [!CPPCHECK]: Issue #error if AO_ATOMIC_OPS_H is not defined after #include atomic_ops.h.
* Workaround 'value of abort unknown' cppcheck info messageIvan Maidanski2017-04-242-2/+2
| | | | | | | | | (fix commit 9f4a38e) * src/atomic_ops_malloc.c [_WIN32_WCE || __MINGW32CE__] (abort): Check defined(AO_HAVE_abort) instead of defined(abort). * tests/run_parallel.h [_WIN32_WCE || __MINGW32CE__] (abort): Likewise. * tests/test_stack.c [_WIN32_WCE || __MINGW32CE__] (abort): Likewise.
* Workaround 'uninitialized memory use' code analyzer false warning (tests)Ivan Maidanski2017-04-201-5/+9
| | | | | | | | | | | | * tests/test_atomic_include.template [AO_HAVE_storeXX && LINT2 && AO_PREFER_GENERALIZED] (test_atomicXX): Initialize x local variable (before AO_storeXX which can be defined using CAS); update comment. * tests/test_atomic_include.template [AO_HAVE_short_storeXX && LINT2 && AO_PREFER_GENERALIZED] (test_atomicXX): Initialize s local variable. * tests/test_atomic_include.template [AO_HAVE_char_storeXX && LINT2 && AO_PREFER_GENERALIZED] (test_atomicXX): Initialize b local variable. * tests/test_atomic_include.template [AO_HAVE_int_storeXX && LINT2 && AO_PREFER_GENERALIZED] (test_atomicXX): Initialize zz local variable.
* Workaround 'obsolescent ftime called' cppcheck style warning (POSIX)Ivan Maidanski2017-03-091-1/+2
| | | | | | * tests/test_stack.c [!NO_TIMES && (USE_WINTHREADS || AO_USE_WIN32_PTHREADS)] (get_msecs): Use gettimeofday-based implementation if CPPCHECK.
* Fix missing .exe for test filenames in Makefile (MinGW)Ivan Maidanski2017-03-021-11/+14
| | | | | | | | | | | (fix commits ad82960, 13a17dd, ecd43ca) * tests/Makefile.am (TESTS, check-without-test-driver): Add $(EXEEXT) suffix to each item (test). * tests/Makefile.am (TEST_OBJS): Reorder items (to match the that of TESTS). * tests/Makefile.am (check_PROGRAMS): Specify all items explicitly (so that to have all items without the suffix as before this change).
* Fix 'unknown attribute no_sanitize' compiler warning (clang prior to v3.8)Ivan Maidanski2017-02-201-0/+12
| | | | | | | | | | | | | | | | | | | * src/atomic_ops.h [!AO_ATTR_NO_SANITIZE_MEMORY && AO_MEMORY_SANITIZER] (AO_ATTR_NO_SANITIZE_MEMORY): Do not define to no_sanitize attribute unless clang-3.8+ (or not clang). * tests/test_atomic_include.template [AO_HAVE_storeXX && AO_MEMORY_SANITIZER && AO_PREFER_GENERALIZED] (test_atomicXX): Initialize x local variable (before AO_storeXX which can be defined using CAS); add comment. * tests/test_atomic_include.template [AO_HAVE_short_storeXX && AO_MEMORY_SANITIZER && AO_PREFER_GENERALIZED] (test_atomicXX): Initialize s local variable. * tests/test_atomic_include.template [AO_HAVE_char_storeXX && AO_MEMORY_SANITIZER && AO_PREFER_GENERALIZED] (test_atomicXX): Initialize b local variable. * tests/test_atomic_include.template [AO_HAVE_int_storeXX && AO_MEMORY_SANITIZER && AO_PREFER_GENERALIZED] (test_atomicXX): Initialize zz local variable.
* Add Makefile target to run all tests without test-driverIvan Maidanski2017-02-181-0/+10
| | | | | | | | | This could be used to catch errors reported by MemorySanitizer (the traditional "make check" shows the tests with MSan errors as skipped, so it does not lead to a non-zero exit code of make itself). * tests/Makefile.am (check-without-test-driver): New phony target (to compile, link and execute all tests not using test-driver).
* Add Makefile target (check-nolink) to compile all source without linkingIvan Maidanski2017-02-181-0/+6
| | | | | | | | | | | | Note: it is assumed --enable-shared is not passed to configure. * Makefile.am (check-nolink-local): New Makefile phony target (just redirects to "all"). * configure.ac: Define check-nolink by AM_EXTRA_RECURSIVE_TARGETS. * tests/Makefile.am (TEST_OBJS): New variable (with a list of the test .o files). * tests/Makefile.am (check-nolink-local): New Makefile phony target (forces all tests to be compiled but not linked).
* Test store/CAS emulation explicitlyIvan Maidanski2017-02-032-1/+43
| | | | | | | | | | | | | | | | * tests/Makefile.am (test_atomic_generalized_CPPFLAGS): Add -D AO_TEST_EMULATION. * tests/test_atomic.c [(!_MSC_VER && !__MINGW32__ && !__BORLANDC__ || AO_USE_NO_SIGNALS || AO_USE_WIN32_PTHREADS) && AO_TEST_EMULATION] (AO_store_full_emulation, AO_fetch_compare_and_swap_emulation): Declare prototype. * tests/test_atomic.c [(!_MSC_VER && !__MINGW32__ && !__BORLANDC__ || AO_USE_NO_SIGNALS || AO_USE_WIN32_PTHREADS) && AO_TEST_EMULATION && AO_HAVE_double_t] (AO_compare_double_and_swap_double_emulation): Likewise. * tests/test_atomic.c (test_atomic_emulation): New function (or a macro defined to empty if AO_*_emulation primitives are unavailable). * tests/test_atomic.c (main): Call test_atomic_emulation().
* Add test_atomic_generalized to Makefile and Makefile.msftIvan Maidanski2017-01-271-3/+6
| | | | | | | | | | | | | | * src/Makefile.msft (test_atomic_generalized): New target (same as test_atomic but with -D AO_PREFER_GENERALIZED). * src/Makefile.msft (check): Add dependency on test_atomic_generalized; run test_atomic_generalized. * tests/Makefile.am (TESTS): Add test_atomic_generalized. * tests/Makefile.am [HAVE_PTHREAD_H] (TEST): Add test_atomic_pthreads instead of specifying all tests. * tests/Makefile.am (test_atomic_generalized_SOURCES, test_atomic_generalized_LDADD): Define (same as for test_atomic). * tests/Makefile.am (test_atomic_generalized_CPPFLAGS): Define specifying -D AO_PREFER_GENERALIZED.
* Fix test_atomic failure caused unaligned AO_double_t access on x86Ivan Maidanski2017-01-241-2/+2
| | | | | | | | | | | | | The failure is caused by violation of an assertion that checks AO_double_t variable is 8-byte aligned on x86. * doc/README.txt (AO_double_t): Add note about required alignment. * src/atomic_ops/sysdeps/standard_ao_double_t.h (AO_double_t): Add comment about alignment. * src/atomic_ops_stack.h (AO_stack_t): Likewise. * tests/test_atomic_include.template (test_atomicXX): Define old_w, w local variables as static (as otherwise, e.g., they could have 4-byte alignment on x86); add comment.
* Revert "Fix test_atomic fail caused unaligned AO_double_t access (VC/x86)"Ivan Maidanski2017-01-242-3/+3
| | | | | | | | | | This reverts commit 69c4010c1b3d43e2e179421e27379aaa5aeeb6d8. The failure is actually caused by the fact that default alignment of stack on x86 is 4 bytes. So, another solution should be proposed to fix the issue for other compilers (and, potentially, other targets). E.g. do not place AO_double_t volatile variables on stack.
* Fix test_atomic failure caused unaligned AO_double_t access on x86 (VC++)Ivan Maidanski2017-01-202-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Passing an unaligned AO_double_t pointer to AO double-wide primitives results in an undefined behavior of the latter when running on x86 (or violation of the corresponding assertion on the alignment). MS VC++/x86 aligns AO_double_t values on a 4-byte boundary by default. For the proper alignment, __declspec(align(8)) should be applied to variables defined in the client code (which uses double-wide AO primitives). Unfortunately, the attribute cannot be added to AO_double_t definition itself because the compiler does not allow the attribute for function arguments. This patch introduces AO_DOUBLE_ALIGN attribute for use by clients of the double-wide AO primitives (and, thus, AO_stack clients). Matters only Visual Studio compiler for X86. The inner clients (atomic_ops_malloc, test_atomic, test_stack) are updated to use this attribute. * doc/README_win32.txt [x86] (AO_DOUBLE_ALIGN): Document. * src/atomic_ops/sysdeps/generic_pthread.h (AO_DOUBLE_ALIGN): Define (as empty). * src/atomic_ops/sysdeps/standard_ao_double_t.h [!_WIN64 && _WIN32 && !__GNUC__ && _MSC_VER] (AO_DOUBLE_ALIGN): Define as declspec align(8); document it. * src/atomic_ops/sysdeps/standard_ao_double_t.h [!AO_DOUBLE_ALIGN] (AO_DOUBLE_ALIGN): Define as empty (otherwise). * src/atomic_ops_stack.h [AO_USE_ALMOST_LOCK_FREE && !AO_DOUBLE_ALIGN] (AO_DOUBLE_ALIGN): Likewise. * src/atomic_ops_malloc.c (AO_free_list): Use AO_DOUBLE_ALIGN attribute. * tests/test_stack.c (the_list): Likewise. * src/atomic_ops_stack.h [!AO_USE_ALMOST_LOCK_FREE] (AO_stack_t): Document AO_DOUBLE_ALIGN usage (by clients). * tests/test_atomic_include.template (test_atomicXX): Use AO_DOUBLE_ALIGN attribute for old_w and w double-wide local variables (to avoid alignment assertion violation or AO primitives undefined behavior on x86 if the test code is compiled by VC++).