Commit Graph

61 Commits

Author SHA1 Message Date
Andrey Semashev
b2594ecbc0 Disable all pointer arithmetic tests on UBSAN. 2019-10-13 10:34:58 +03:00
Andrey Semashev
0d8ea24351 Added a workaround for clang UBSAN failures.
Clang UBSAN considers an UB subtracting from a null pointer, which is
required for one of the tests. Disable that test when UBSAN is enabled.
2019-10-13 01:33:43 +03:00
Andrey Semashev
e8ccfce2dc Added check for BOOST_NO_ALIGNMENT for float128 tests.
Atomic storage can be implemented without int128 support but when
explicit alignment specification is supported.
2019-10-13 01:24:53 +03:00
Andrey Semashev
c043562511 Disable floating point tests when BOOST_ATOMIC_NO_FLOATING_POINT is defined.
Also check that int128 is available for float128 tests. Int128 is used
as the storage for atomic variables.
2019-10-12 21:58:56 +03:00
Andrey Semashev
4c2fc16ab1 Work around signed overflow on min value negation.
This should fix UBSAN failures.
2019-10-12 21:20:33 +03:00
Andrey Semashev
0e810ea02f Updated license URLs to use https. 2019-01-02 15:32:10 +03:00
Mike Dev
04ddfdeb19 [CMake] Add test for cmake file 2019-01-02 15:29:35 +03:00
Andrey Semashev
406228d493 Made initializing constructor of atomic<> implicit.
This is an attempt to make boost::atomic<> interface closer to the standard. It
makes a difference in C++17 as it mandates copy elision, which makes this code
possible:

  boost::atomic<int> a = 10;

It also makes is_convertible<T, boost::atomic<T>> return true, which has
implications on the standard library components, such as std::pair.

This removes the workaround for gcc 4.7, which complains that
operator=(value_arg_type) is considered ambiguous with operator=(atomic const&)
in assignment expressions, even though conversion to atomic<> is less preferred
than conversion to value_arg_type. We try to work around the problem from the
operator= side.

Added a new compile test to check that the initializing constructor is implicit.
2018-02-20 01:39:52 +03:00
Andrey Semashev
b990132e85 Added casts to silence MSVC warnings about lost FP precision of constants. 2018-02-18 13:57:32 +03:00
Andrey Semashev
e081674ce9 Use FP numbers in FP tests. 2018-02-14 03:19:09 +03:00
Andrey Semashev
2a6b6ca8a7 Removed unnecessary includes to reduce dependencies. 2018-02-13 19:36:00 +03:00
Andrey Semashev
edef50f042 Added support for atomic floating point operations.
The support includes:

- The standard fetch_add/fetch_sub operations.
- Extra operations: (fetch_/opaque_)negate, (opaque_)add/sub.
- Extra capability macros: BOOST_ATOMIC_FLOAT/DOUBLE/LONG_DOUBLE_LOCK_FREE.

The atomic operations are currently implemented on top of the integer-based
backends and thus are mostly CAS-based. The CAS operations perform binary
comparisons, and as such have different behavior wrt. special FP values like
NaN and signed zero than normal C++.

The support for floating point types is optional and can be disabled by
defining BOOST_ATOMIC_NO_FLOATING_POINT. This can be useful if on a certain
platform parameters of the floating point types cannot be deduced from the
compiler-defined or system macros (in which case the compilation fails).

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0020r6.html
2018-02-13 03:36:35 +03:00
Andrey Semashev
92c57ac1e4 Added atomic operations that return the result of the operation.
These operations are useful for two reasons. First, they are needed by
atomic<> interface as the pre-increment/decrement and add/subtract operators
need to perform the corresponding arithmetics and return the actual result while
not exhibiting UB in case of overflow. This means that the operation must be
performed on the unsigned storage type in the backend. Second, the (op)_and_test
operations on ARM and PowerPC can be implemented in a more generic way on top of
the operations that return the result. And since we have those operations
internally, why not expose them to users.

Added tests and docs for the new operations. Also, added docs for the recently
added scoped names of the memory_order enum values.

Also, added a specialized "emulated" backend for the extra operations. This
backend makes better use of the fact that the operations are lock-protected
by avoiding any CAS-based loops.
2018-02-11 00:56:23 +03:00
Andrey Semashev
9fd085c59f Added negate_and_test and complement_and_test ops.
As the names suggest, the methods perform the corresponding operation and test
if the result is not zero.

Also, for the emulated fetch_complement, take care of integral promotion, which
could mess up the storage bits that were not part of the value on backends
where the storage is larger than the value. This could in turn break CAS on
the atomic value as it compares the whole storage.
2018-02-04 00:13:27 +03:00
Andrey Semashev
b24cea0af1 Changed the result of (op)_and_test operations to the opposite.
This makes the result of (op)_and_test more consistent with other
methods such as test_and_set and bit_test_and_set, as well as the
methods used in the C++ standard library.

This is a breaking change. The users are able to define
BOOST_ATOMIC_HIGHLIGHT_OP_AND_TEST macro to generate warnings on each
use of the changed functions. This will help users to port from Boost
1.66 to newer Boost releases.

More info at:

https://github.com/boostorg/atomic/issues/11
http://boost.2283326.n4.nabble.com/atomic-op-and-test-naming-
tc4701445.html
2018-01-28 20:50:12 +03:00
Andrey Semashev
573732ea4a Added a workaround for libstdc++ not specializing numeric_limits for __int128 in strict mode. 2017-07-29 18:13:27 +03:00
Andrey Semashev
a980d1c3ba Attempt to work around absent opereator<< for __int128 in some libstdc++ versions. 2017-07-20 23:46:54 +03:00
Andrey Semashev
c172831e5d Added a workaround for gcc on PPC not providing operator<< for __int128. 2017-07-17 01:15:04 +03:00
Andrey Semashev
5b28e12f1d Fixed tests to accommodate MSVC bugs and improved diagnostics.
Fixed incorrect calculation of the min distance limit for arithmetic tests.

Moved some of the arithmetic tests to a separate function because
otherwise MSVC-10 for x64 generated broken code (the code would use
garbage values in registers to pass arguments to
add_and_test/sub_and_test).

Added output operators and employed newer test macros that output compared
values in case of test failure.
2017-07-11 23:00:52 +03:00
Andrey Semashev
3622ce85c7 Updated test to avoid signed overflows when add_and_test/sub_and_test is
called on pointer types.
2017-07-11 23:00:52 +03:00
Andrey Semashev
65d0d557f1 Fixed a test constant, added a few more checks. 2017-07-11 23:00:52 +03:00
Andrey Semashev
158a114325 Corrected test constants. 2017-07-11 23:00:52 +03:00
Andrey Semashev
add6f5640c Added tests for the new operations. 2017-07-11 23:00:52 +03:00
Andrey Semashev
ca151bedb4 Fixed warnings about left-shifting negative signed integers. 2017-05-22 15:21:22 +03:00
Andrey Semashev
11c785768c Updated to reflect changes from P0558R1 accepted into C++17.
1. Expose value_type and difference_type (where present) to user's code.

2. Prohibit arithmetic operations on pointers to non-object types. In
   particular, arithmetic operations such as fetch_add/fetch_sub will no longer
   compile for pointers to cv void, pointers to functions and pointers to
   non-static class members.

Also, use C++11 <type_traits> when possible instead of Boost.TypeTraits to
reduce dependencies. Cleaned up value_arg_type internal type usage for more
efficient argument passing.
2017-04-01 18:29:26 +03:00
Andrey Semashev
2b6ef06b57 Added preliminary support for MSVC for ARM64 target. 2017-01-07 21:27:09 +03:00
Andrey Semashev
5b30e196a6 Added is_always_lock_free static constant from C++17. 2016-10-13 15:59:22 +03:00
Andrey Semashev
9be3389f06 Updated test to refrect improved support for Oracle Studio and SPARC. 2016-09-17 13:30:26 +03:00
Andrey Semashev
6bb5b17108 Silenced MSVC warnings about 'this' being used in the constructor initialization list. 2015-08-22 20:47:56 +03:00
Andrey Semashev
ff91811c1a Fixes #10994. Fixed compilation with gcc 4.4 when cmpxchg16b is used. 2015-08-17 23:27:37 +03:00
Andrey Semashev
b1bb36c5b3 Only use intptr_t when available. Only test integer overflows/underflows for unsigned integers (the behavior is undefined for signed ints anyway). This should silence compiler warnings as well. 2015-08-17 22:25:19 +03:00
Andrey Semashev
4162cb109f Corrected memory ordering of loads. Relaxed loads do not synchronize-with seq_cst stores, which allowed the test to fail. Also removed unnecessary loads that did not contribute to the test robustness and could have reduced it by issuing extra memory fences. 2015-08-14 15:03:35 +03:00
Andrey Semashev
7b1d722d94 Ported tests to core/lightweight_test.hpp.
Boost.Test was dropped due to instability and long-standing differences between develop and master branches. We don't use most of its features anyway.
2015-01-25 18:50:58 +03:00
Jürgen Hunold
30f72c8d25 Add explicit dependency on Boost.Test 2015-01-14 16:13:41 +01:00
Andrey Semashev
4dee330229 Added support for types with non-trivial default constructors. 2014-07-07 22:40:41 +04:00
Andrey Semashev
313497c6ae Added Windows version specification to fix compilation with MSVC. The code targets for Windows 2000. 2014-06-09 01:18:38 +04:00
Andrey Semashev
0c9b1b3806 Reworked platform selection, fixed Windows backend.
Platform selection now works in two stages. First compiler is tested for
the supported configuration. If that fails, OS is tested. Lastly, if
nothing succeeded, emulation backend is selected.
2014-06-09 01:07:26 +04:00
Andrey Semashev
97ae84a474 Adjusted the workaround for ldrexd/strexd instruction problem with register pairs allocation. The problem only affects ARMv6k in Thumb mode, so enable these instructions for ARM mode. Also don't base the decision on the compiler version, it is probably not relevant. Updated lockfree test to reflect the recent changes related to ARM backends. 2014-05-23 21:02:07 +04:00
Andrey Semashev
76b78f2491 #9985. Added ebx saves and restores in asm blocks to avoid frame pointer clobbering, when frame pointer omission is disabled. 2014-05-17 21:58:59 +04:00
Andrey Semashev
17cf91d8c9 Working on the library rewrite. Implemented gcc-x86 and gcc-sync
backends.
2014-05-04 00:14:24 +04:00
Andrey Semashev
625c3c3a2e Compilation fixes. Added public headers for atomic_flag and atomic. 2014-04-20 17:26:42 +04:00
Andrey Semashev
20747acd08 Corrected includes. 2014-01-27 11:30:04 +04:00
Andrey Semashev
1bda03c997 Attempt to fix tests on MSVC
[SVN r85574]
2013-09-05 17:01:50 +00:00
Andrey Semashev
3869ce33cf Added tests for int128 atomicity.
[SVN r84804]
2013-06-16 14:01:04 +00:00
Andrey Semashev
55e8b16a12 Fixed compilation with gcc 4.4. Optimized code for gcc older than 4.7 and also added support for 128-bit atomic ops. Completed transition to defaulted and deleted functions.
[SVN r84801]
2013-06-16 13:40:11 +00:00
Andrey Semashev
9cab8a9ebf Added a generic atomic<> implementation based on the new __atomic intrinsics available in gcc 4.7 and clang 3.2. The new implementation adds support for 128-bit atomic. Other implementations updated to employ new macros in Boost.Config for defaulted and deleted functions (this is not complete yet). Fixed padding for the lock pool. Initializing constructor for atomic<> made explicit to avoid ambiguities of different overloads of operator=.
[SVN r84800]
2013-06-15 20:43:48 +00:00
Andrey Semashev
179e72cfd1 Code cleanup.
[SVN r84700]
2013-06-08 18:22:36 +00:00
Andrey Semashev
5b0186dc7d Added implementation of 64-bit atomic operations on 32-bit Windows. Pointer specializations of 64-bit CAS-based atomic implementation extracted to a separate header, since these specializations are not needed on 32-bit platforms.
[SVN r84695]
2013-06-08 17:36:38 +00:00
Tim Blechmann
18b97cbe7a atomic: Optimization for 64 bit loads and stores for 32 bit x86 on gcc
fixes #8574

[SVN r84288]
2013-05-15 06:12:46 +00:00
Tim Blechmann
96b44933f0 atomic: provide additive functionality for atomic<void*>
fixes #8501

[SVN r84190]
2013-05-08 04:45:38 +00:00