summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Eliminate 'atomic_thread_fence is unsupported with tsan' gcc-11 warningIvan Maidanski2023-03-311-1/+5
| | | | | | | | | | | | The workaround is to use __atomic_test_and_set instead of __atomic_thread_fence in case of option -fsanitize=thread is passed to gcc (or clang). The old behavior could be turned on by defining AO_USE_ATOMIC_THREAD_FENCE macro. * src/atomic_ops/sysdeps/gcc/generic.h [!AO_UNIPROCESSOR && AO_THREAD_SANITIZER && !AO_USE_ATOMIC_THREAD_FENCE] (AO_nop_read, AO_nop_write, AO_nop_full): Do not define (using __atomic_thread_fence); add comment.
* Bump libatomic_ops version to 7.9.0 (next release development)Ivan Maidanski2023-03-281-2/+2
| | | | | | | | | | * CMakeLists.txt (PACKAGE_VERSION): Bump version to 7.9.0. * .appveyor.yml (version): Likewise. * .travis.yml (env.addons.coverity_scan.project.version): Likewise. * README.md: Likewise. * configure.ac (AC_INIT): Likewise. * src/atomic_ops/ao_version.h (AO_VERSION_MINOR): Likewise. * README.md: Add back the build status indicators for "master" branch.
* [7.8.0]Ivan Maidanski2023-03-262-4/+4
| | | | | | | | | | | | | | | | | | Bump libatomic_ops version to 7.8.0. * CMakeLists.txt (PACKAGE_VERSION): Bump version to 7.8.0. * ChangeLog (7.7.0): Likewise. * README.md: Likewise. * configure.ac (AC_INIT): Likewise. * src/atomic_ops/ao_version.h (AO_VERSION_MINOR): Likewise. * .travis.yml (env.addons.coverity_scan.project.version): Likewise. * .appveyor.yml (version): Change to 7.8.x. * CMakeLists.txt (LIBATOMIC_OPS_VER_INFO, LIBATOMIC_OPS_GPL_VER_INFO): Change to 3:0:2. * src/Makefile.am (LIBATOMIC_OPS_VER_INFO, LIBATOMIC_OPS_GPL_VER_INFO): Likewise. * ChangeLog (7.8.0): Set release date. * README.md: Remove build status indicators for "master" branch.
* Update shared objects version info to be not lower than in ver 7.6.14Ivan Maidanski2022-08-271-1/+1
| | | | | | * CMakeLists.txt (LIBATOMIC_OPS_GPL_VER_INFO): Increment current and age (change version info of libcord.so to 2:3:1). * src/Makefile.am (LIBATOMIC_OPS_GPL_VER_INFO): Likewise.
* Avoid 'cast increases required alignment' warnings in atomic_ops_malloc.cIvan Maidanski2022-08-241-8/+11
| | | | | | | | | | | | * src/atomic_ops_malloc.c [HAVE_MMAP] (AO_malloc_large): Change type of result local variable from char* to void*. * src/atomic_ops_malloc.c [HAVE_MMAP] (AO_free_large): Change type of argument from char* to void*. * src/atomic_ops_malloc.c (add_chunk_as): Cast to AO_t* from void* directly (adjust ofs accordingly); add assertion that sz is multiple of AO_t size. * src/atomic_ops_malloc.c (AO_free): Remove cast to char* in AO_free_large() call.
* Fix AO_compare_and_swap_full asm code for clang on sparcIvan Maidanski2022-08-101-12/+6
| | | | | | | | | | | | | | | | Issue #52 (libatomic_ops). The issue (SIGSEGV in test_malloc) is observed with clang-13, at least. The workaround is to simplify asm code of AO_compare_and_swap_full (moving the comparison of CAS result and old value to C code). * src/atomic_ops/sysdeps/gcc/sparc.h [(!(AO_GNUC_PREREQ(12,0) || AO_CLANG_PREREQ(13,0)) || AO_DISABLE_GCC_ATOMICS) && !AO_NO_SPARC_V9 && !AO_GENERALIZE_ASM_BOOL_CAS] (AO_compare_and_swap_full): Remove ret local variable; remove cmp, be, mov, clr instructions from asm block (to match that of AO_fetch_compare_and_swap_full); remove cc from asm block clobbers; change specifier for old input operand of asm block (from "0" to "r"); return new_val==old instead of ret.
* Use GCC atomic intrinsics for sparcIvan Maidanski2022-08-011-2/+9
| | | | | | | | | | | | | | | | | The intrinsics are used in gcc/sparc.h (unless AO_DISABLE_GCC_ATOMICS) starting from gcc-12 and clang-13. * src/atomic_ops/sysdeps/gcc/sparc.h: Remove TODO item that support is incomplete and about compare-and-swap. * src/atomic_ops/sysdeps/gcc/sparc.h [(AO_GNUC_PREREQ(12,0) || AO_CLANG_PREREQ(13,0)) && !AO_DISABLE_GCC_ATOMICS]: Include generic.h; do not include all_atomic_load_store.h, ordered_except_wr.h, test_and_set_t_is_char.h. * src/atomic_ops/sysdeps/gcc/sparc.h [(AO_GNUC_PREREQ(12,0) || AO_CLANG_PREREQ(13,0)) && !AO_DISABLE_GCC_ATOMICS] (AO_test_and_set_full, AO_compare_and_swap_full, AO_fetch_compare_and_swap_full): Do not define as an asm-based implementation.
* 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-192-14/+24
| | | | | | | | | | | | | | | | 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.
* Remove extra space after comma in MIT-like license termsIvan Maidanski2022-05-0114-14/+14
| | | | | | | | | | | | | | | | | | | | | | (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.
* 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-182-0/+10
| | | | | | | | | | * 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.
* 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).
* 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.
* 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.
* 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).
* 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-142-362/+352
| | | | | | | | | | | | | | * 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.
* 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.
* 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").
* Update copyright year in CMakeLists.txt and src/atomic_ops.hIvan Maidanski2022-01-051-1/+1
| | | | | * CMakeLists.txt: Update copyright year. * src/atomic_ops.h: Likewise.
* Support Elbrus 2000 (gcc/e2k)Ivan Maidanski2022-01-053-0/+31
| | | | | | | | | | 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.
* Explicitly outline symbols exported in AO shared librariesIvan Maidanski2021-11-088-42/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Hide AO_free_list symbolIvan Maidanski2021-11-071-1/+1
| | | | * src/atomic_ops_malloc.c (AO_free_list): Make it static.
* Remove 'lib' prefix for atomic_ops[_gpl].lib in Makefile.msftIvan Maidanski2021-11-071-13/+11
| | | | | | | | | | | | | | | | | | | This is to unify build artifacts naming between the supported build scripts. The documentation and LICENSING.txt are updated accordingly. * LICENSING.txt: Rename libatomic_ops_gpl to atomic_ops_gpl. * README_malloc.txt: Likewise. * README_win32.txt: Likewise. * configure.ac (gpl): Likewise. * src/Makefile.msft (all, libatomic_ops_gpl.lib, test_malloc, test_stack): Likewise. * README_win32.txt: Rename libatomic_ops.lib to atomic_ops.lib. * src/Makefile.msft (all-disable-gpl, libatomic_ops.lib, test_malloc, test_stack): Likewise. * src/Makefile.msft (clean): Remove atomic_ops*.lib instead of libatomic_ops*.lib.
* Build libatomic_ops.lib by Makefile.msft (MS VC)Ivan Maidanski2021-11-071-10/+18
| | | | | | | | | | | | | | | | | | | | | | | | This unifies the build artifacts between the supported build systems. Note that the clients relying on Makefile.msft should now link with libatomic_ops.lib in addition to libatomic_ops_gpl.lib. * README.md (Platform Specific Notes): Updade documentation about Makefile.msft which also builds libatomic_ops.lib now. * README_win32.txt: Likewise. * README_win32.txt: Refine documentation (separate the package build from client code compilation). * src/Makefile.msft (LIB_GPL_OBJS): New variable. * src/Makefile.msft (LIB_OBJS): Move atomic_ops_malloc.obj and atomic_ops_stack.obj to LIB_GPL_OBJS. * src/Makefile.msft (all-disable-gpl, libatomic_ops.lib): New goal (builds only non-GPL code). * src/Makefile.msft (all): Depend on all-disable-gpl. * src/Makefile.msft (libatomic_ops_gpl.lib): Depend and use LIB_GPL_OBJS instead of LIB_OBJS. * src/Makefile.msft (test_malloc, test_stack): Also depend and link with libatomic_ops.lib. * src/Makefile.msft (clean): Delete libatomic_ops*.lib.
* Ensure atomic_ops.c global symbols are always declared as extern 'C'Ivan Maidanski2021-11-062-2/+35
| | | | | | | | | | | | | | * src/atomic_ops.c (AO_pause): Declare as extern "C" if __cplusplus. * 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.c [(!_MSC_VER && !__MINGW32__ && !__BORLANDC__ || AO_USE_NO_SIGNALS) && !AO_NO_PTHREADS] (AO_pt_lock): Likewise. * src/atomic_ops_stack.c [AO_USE_ALMOST_LOCK_FREE] (AO_pause): Likewise. * src/atomic_ops.c (AO_pause): Move declaration up to have it unconditionally.
* New configure option (--disable-gpl) to skip building of libatomic_ops_gplIvan Maidanski2021-11-021-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Move all README and license files to the top folderIvan Maidanski2021-11-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The rationale: all relative links (in README.md) should remain valid after docs installation. * doc/LICENSING.txt: Move to the base folder. * doc/README_details.txt: Likewise. * doc/README_malloc.txt: Likewise. * doc/README_stack.txt: Likewise. * doc/README_win32.txt: Likewise. * Makefile.am (SUBDIRS): Remove doc item. * Makefile.am [ENABLE_DOCS] (dist_doc_DATA): Add comment and items from doc/Makefile.am. * README.md (Overview): Replace reference to doc with the links to the existing README_*.txt files (except for README_win32.txt). * README.md (Installation and Usage): Add link to LICENSING.txt. * README.md (Platform Specific Notes): Add link to README_win32.txt. * README.md (Copyright & Warranty): Adjust link to LICENSING.txt (after moving to the base folder). * configure.ac (AC_CONFIG_FILES): Remove doc/Makefile item. * doc/Makefile.am: Remove file. * src/atomic_ops_malloc.h: Update path to LICENSING.txt in comment.
* Add goal to Makefile.msft to build all tests but not execute themIvan Maidanski2021-10-301-2/+7
| | | | | | | | * src/Makefile.msft (check-deps, check-noautogen-deps): New goal. * src/Makefile.msft (check): Depend on check-deps instead of test_atomic and test_atomic_generalized. * src/Makefile.msft (check-noautogen): Depend on check-noautogen-deps instead of test_malloc and test_stack.
* Always use 'mfence' for nop_full if target CPU supports SSE2 (MS VC/x86)Ivan Maidanski2021-10-291-0/+5
| | | | | * src/atomic_ops/sysdeps/msftc/x86.h [!AO_USE_PENTIUM4_INSTRS && _M_IX86_FP>=2] (AO_USE_PENTIUM4_INSTRS): Define; add comment.
* Define double_compare_and_swap_full if MS VS 2017+ (x86)Ivan Maidanski2021-10-291-3/+6
| | | | | | | | Visual Studio 2017 (15.0) discontinued support of Windows XP. * doc/README_win32.txt: Do not mention AO_ASSUME_VISTA. * src/atomic_ops/sysdeps/msftc/x86.h [!AO_ASSUME_VISTA && _MSC_VER>=1910] (AO_ASSUME_VISTA): Define; add comment.
* Build test object and executable files in tests folder (MS VC)Ivan Maidanski2021-10-271-17/+20
| | | | | | | | | | | | This is to match that of GNU make script. * src/Makefile.msft (test_atomic, test_atomic_generalized, test_malloc, test_stack, check, check-noautogen): Add "..\tests\" prefix to test target. * src/Makefile.msft (test_atomic, test_atomic_generalized, test_malloc, test_stack): Specify object file. * src/Makefile.msft (clean): Delete .exe, .obj files in tests folder; do not delete .exe files in src folder.
* Support test_atomic with MS build w/o the need to run GNU make firstIvan Maidanski2021-10-271-7/+2
| | | | | | | * .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 test_and_set for MS VC if char is unsignedIvan Maidanski2021-10-261-8/+11
| | | | | | | | | | | | | | | (fix of commit eb83b6186) Also, "truncation from AO_BYTE_TS_val to CHAR" compiler warning is eliminated. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>=1800 && (!_M_ARM || _M_ARM>=6)] (AO_test_and_set_full): Cast AO_TS_SET to AO_TS_t (before passing to the argument of char type); apply &0xff to the result instead of cast to unsigned char; add comment. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>=1800 && (_M_ARM>=6 || _M_ARM64)] (AO_test_and_set, AO_test_and_set_acquire, AO_test_and_set_release): Likewise.
* Enforce most strict level of compiler warnings (MS VC)Ivan Maidanski2021-10-241-2/+2
| | | | | * Makefile.msft (CFLAGS): Replace -W3 to -W4. * Makefile.msft (atomic_ops_malloc.obj): Add /wd4127 option.
* Fix 'AO_malloc redefinition' MS VC warning caused by attributes mismatchIvan Maidanski2021-10-241-0/+1
| | | | | | | (fix of commit 1835cad76) * src/atomic_ops_malloc.c (AO_malloc): Add AO_ATTR_MALLOC and AO_ATTR_ALLOC_SIZE (to match that in atomic_ops_malloc.h).
* Implement and/or/xor for AO_t, short and int types (MS VC)Ivan Maidanski2021-10-241-0/+348
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER >= 1800 && !AO_PREFER_GENERALIZED] (_InterlockedAnd16, _InterlockedOr16, _InterlockedXor16, _InterlockedAnd, _InterlockedOr, _InterlockedXor): Specify as intrinsic. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER >= 1800 && !AO_PREFER_GENERALIZED && !AO_T_IS_INT] (_InterlockedAnd64, _InterlockedOr64, _InterlockedXor64): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER >= 1800 && !AO_PREFER_GENERALIZED && (_M_ARM || _M_ARM64)] (_InterlockedAnd16_acq, _InterlockedAnd16_nf, _InterlockedAnd16_rel, _InterlockedOr16_acq, _InterlockedOr16_nf, _InterlockedOr16_rel, _InterlockedXor16_acq, _InterlockedXor16_nf, _InterlockedXor16_rel, _InterlockedAnd_acq, _InterlockedAnd_nf, _InterlockedAnd_rel, _InterlockedOr_acq, _InterlockedOr_nf, _InterlockedOr_rel, _InterlockedXor_acq, _InterlockedXor_nf, _InterlockedXor_rel): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER >= 1800 && !AO_PREFER_GENERALIZED && (_M_ARM || _M_ARM64) && !AO_T_IS_INT] (_InterlockedAnd64_acq, _InterlockedAnd64_nf, _InterlockedAnd64_rel, _InterlockedOr64_acq, _InterlockedOr64_nf, _InterlockedOr64_rel, _InterlockedXor64_acq, _InterlockedXor64_nf, _InterlockedXor64_rel): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER >= 1800 && !AO_PREFER_GENERALIZED] (AO_short_and_full, AO_short_or_full, AO_short_xor_full, AO_and_full, AO_or_full, AO_xor_full): Implement. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER >= 1800 && !AO_PREFER_GENERALIZED && !AO_T_IS_INT] (AO_int_and_full, AO_int_or_full, AO_int_xor_full): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER >= 1800 && !AO_PREFER_GENERALIZED && (_M_ARM || _M_ARM64)] (AO_short_and, AO_short_or, AO_short_xor, AO_short_and_acquire, AO_short_or_acquire, AO_short_xor_acquire, AO_short_and_release, AO_short_or_release, AO_short_xor_release, AO_and, AO_or, AO_xor, AO_and_acquire, AO_or_acquire, AO_xor_acquire, AO_and_release, AO_or_release, AO_xor_release): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER >= 1800 && !AO_PREFER_GENERALIZED && (_M_ARM || _M_ARM64) && !AO_T_IS_INT] (AO_int_and, AO_int_or, AO_int_xor, AO_int_and_acquire, AO_int_or_acquire, AO_int_xor_acquire, AO_int_and_release, AO_int_or_release, AO_int_xor_release): Likewise.
* Implement nf/acq/rel variants of primitives on Windows RT (MS VC)Ivan Maidanski2021-10-241-0/+524
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>=1800 && !AO_PREFER_GENERALIZED && (_M_ARM || _M_ARM64)] (_InterlockedAnd8_acq, _InterlockedAnd8_nf, _InterlockedAnd8_rel, _InterlockedOr8_acq, _InterlockedOr8_nf, _InterlockedOr8_rel, _InterlockedXor8_acq, _InterlockedXor8_nf, _InterlockedXor8_rel, _InterlockedDecrement16_acq, _InterlockedDecrement16_nf, _InterlockedDecrement16_rel, _InterlockedIncrement16_acq, _InterlockedIncrement16_nf, _InterlockedIncrement16_rel, _InterlockedExchangeAdd_acq, _InterlockedExchangeAdd_nf, _InterlockedExchangeAdd_rel, _InterlockedDecrement_acq, _InterlockedDecrement_nf, _InterlockedDecrement_rel, _InterlockedIncrement_acq, _InterlockedIncrement_nf, _InterlockedIncrement_rel): Specify as intrinsic. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>=1800 && !AO_PREFER_GENERALIZED && (_M_ARM || _M_ARM64) && !AO_T_IS_INT] (_InterlockedExchangeAdd64_acq, _InterlockedExchangeAdd64_nf, _InterlockedExchangeAdd64_rel, _InterlockedDecrement64_acq, _InterlockedDecrement64_nf, _InterlockedDecrement64_rel, _InterlockedIncrement64_acq, _InterlockedIncrement64_nf, _InterlockedIncrement64_rel): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>=1800 (_M_ARM || _M_ARM64)] (_InterlockedCompareExchange_acq, _InterlockedCompareExchange_nf, _InterlockedCompareExchange_rel, _InterlockedCompareExchange16_acq, _InterlockedCompareExchange16_nf, _InterlockedCompareExchange16_rel, _InterlockedCompareExchange8_acq, _InterlockedCompareExchange8_nf, _InterlockedCompareExchange8_rel): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>=1800 (_M_ARM || _M_ARM64) && !AO_T_IS_INT] (_InterlockedCompareExchange64_acq, _InterlockedCompareExchange64_nf, _InterlockedCompareExchange64_rel): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>=1800 && !AO_PREFER_GENERALIZED && !_M_ARM && _M_ARM64] (_InterlockedExchangeAdd16_acq, _InterlockedExchangeAdd16_nf, _InterlockedExchangeAdd16_rel, _InterlockedExchangeAdd8_acq, _InterlockedExchangeAdd8_nf, _InterlockedExchangeAdd8_rel): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>=1800 && && !AO_PREFER_GENERALIZED && (_M_ARM || _M_ARM64)] (AO_char_and, AO_char_or, AO_char_xor, AO_char_and_acquire, AO_char_or_acquire, AO_char_xor_acquire, AO_char_and_release, AO_char_or_release, AO_char_xor_release, AO_short_fetch_and_add1, AO_short_fetch_and_sub1, AO_short_fetch_and_add1_acquire, AO_short_fetch_and_sub1_acquire, AO_short_fetch_and_add1_release, AO_short_fetch_and_sub1_release, AO_fetch_and_add, AO_fetch_and_add1, AO_fetch_and_sub1, AO_fetch_and_add_acquire, AO_fetch_and_add1_acquire, AO_fetch_and_sub1_acquire, AO_fetch_and_add_release, AO_fetch_and_add1_release, AO_fetch_and_sub1_release): Implement. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>=1800 && !AO_PREFER_GENERALIZED && (_M_ARM || _M_ARM64) && !AO_T_IS_INT] (AO_int_fetch_and_add, AO_int_fetch_and_add1, AO_int_fetch_and_sub1, AO_int_fetch_and_add_acquire, AO_int_fetch_and_add1_acquire, AO_int_fetch_and_sub1_acquire, AO_int_fetch_and_add_release, AO_int_fetch_and_add1_release, AO_int_fetch_and_sub1_release): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>=1800 (_M_ARM || _M_ARM64)] (AO_fetch_compare_and_swap, AO_fetch_compare_and_swap_acquire, AO_fetch_compare_and_swap_release, AO_short_fetch_compare_and_swap, AO_short_fetch_compare_and_swap_acquire, AO_short_fetch_compare_and_swap_release, AO_char_fetch_compare_and_swap, AO_char_fetch_compare_and_swap_acquire, AO_char_fetch_compare_and_swap_release): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>=1800 (_M_ARM || _M_ARM64) && !AO_T_IS_INT] (AO_int_fetch_compare_and_swap, AO_int_fetch_compare_and_swap_acquire, AO_int_fetch_compare_and_swap_release): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>=1800 && !AO_PREFER_GENERALIZED && !_M_ARM && _M_ARM64] (AO_char_fetch_and_add, AO_short_fetch_and_add, AO_char_fetch_and_add_acquire, AO_short_fetch_and_add_acquire, AO_char_fetch_and_add_release, AO_short_fetch_and_add_release): Likewise.
* Implement AO_test_and_set using InterlockedExchange8 (MS VC)Ivan Maidanski2021-10-245-30/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/atomic_ops/sysdeps/msftc/arm.h: Include test_and_set_t_is_ao_t.h after include common32_defs.h and only unless AO_HAVE_test_and_set_full. * src/atomic_ops/sysdeps/msftc/arm64.h: Likewise. * src/atomic_ops/sysdeps/msftc/x86_64.h [!AO_ASM_X64_AVAILABLE]: Likewise. * src/atomic_ops/sysdeps/msftc/arm.h [_M_ARM>=6]: Remove comment. * src/atomic_ops/sysdeps/msftc/arm.h [_M_ARM<6]: Remove TODO item. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>=1800 && (!_M_ARM || _M_ARM>=6)]: Include test_and_set_t_is_char.h. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>=1800 && (!_M_ARM || _M_ARM>=6)] (_InterlockedExchange8): Specify as intrinsic. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>=1800 && (_M_ARM>=6 || _M_ARM64)] (_InterlockedExchange8_acq, _InterlockedExchange8_nf, _InterlockedExchange8_rel): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>=1800 && (!_M_ARM || _M_ARM>=6)] (AO_test_and_set_full): Implement. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>=1800 && (_M_ARM>=6 || _M_ARM64)] (AO_test_and_set, AO_test_and_set_acquire, AO_test_and_set_release): Likewise. * src/atomic_ops/sysdeps/msftc/x86.h: Include test_and_set_t_is_char.h after include common32_defs.h and only unless AO_HAVE_test_and_set_full. * src/atomic_ops/sysdeps/msftc/x86_64.h [AO_ASM_X64_AVAILABLE]: Likewise.