This is a Boost.Atomic extension over std::atomic.
Bitwise operations can be useful if the enumeration is used to implement
a bit mask or a set of flags. Without these operations, users have to
manually perform conversions between the enum type and the underlying
type, which can be tedious.
There are caveats with enums with non-fixed underlying type, but the
convenience outweighs the potential pitfalls.
Although smt_pause matches the equivalent global function on Solaris and
some BSD systems both in name and behavior, this naming clash may cause
confusion and ambiguities in users' code that imports boost::atomics
namespace into their scope and calls smt_pause unqualified. Better
avoid these issues and pick a different name.
Add a simple test for thread_pause, which only tests that the operation
compiles and executes.
Also include the recently added headers in the global atomic.hpp.
The smt_pause() operation may be useful in spin loops to release CPU
resources for use in simpling threads on SMT-capable CPUs.
Compared to the previous pause() implementation, added support for
PowerPC and Solaris and use isb instruction on AArch64, which seems
to be used in various open source projects instead of yield.
This makes WaitOnAddress/WakeByAddressSingle/WakeByAddressAll a mandatory
requirement. Thus, runtime detection of these APIs is now removed.
Also, linking with synchronization lib on Windows is now mandatory. The
library provides WaitOnAddress & co. which are now mandatory.
Since recent OpenBSD versions have removed syscall(2) interface, use
futex(2) wrapper that was also added along with the SYS_futex syscall.
Closes https://github.com/boostorg/atomic/pull/68.
As a result of dependent libraries dropping support for C++03, Boost.Atomic
is no longer able to support C++03 and now requires C++11 as a minimum.
Drop C++03 compilers from the CI and update docs accordingly. No code changes
at this time.
On FreeBSD and OpenBSD 32-bit x86 targets are configured to use 53-bit precision
for long double type. The value still uses 80 bits of storage, but the lowest
11 bits of mantissa are zero.
While at it, also added support for 24-bit precision, which can be configured
in x87. Though the platforms where this configuration is used by default are
not known.
Also, when possible, use predefined macros by gcc and compatible compilers and
avoid including standard library header for defining floating point limit macros.
Related to https://github.com/boostorg/atomic/issues/14.
Boost libraries that deprecate C++03 support (namely, Boost.Chrono) are not
used in Boost.Atomic implementation, but they are used in tests (indirectly
through Boost.Thread), which means it will become impossible to test
Boost.Atomic when the support is removed.
For seq_cst we must issue a memory fence, so in this case use
cmpxchg8b/cmpxchg16b.
Also, optimized 32-bit x86 code path to make the compiler pass the value
to and from the xmm register instead of hardcoding it in asm blocks.
When gcc predefined macros are not defined, use Boost.Predef (which also
checks macros defined in the system endian.h header) to detect endianness.
This may help with gcc impostor compilers that do not define built-in
endianness macros.
Closes https://github.com/boostorg/atomic/issues/59.
The new macro disables ulock-based implementation of waiting and notifying
operations on Darwin systems. This may be useful to comply with Apple
App Store requirements.
Closes https://github.com/boostorg/atomic/issues/55.
UWP does not support APIs related to dynamic symbol binding and dlls.
Disable runtime detection of WaitOnAddress & co. for that target. These
APIs should be enabled at compile time on Windows 8.
Fixes https://github.com/boostorg/atomic/issues/54.
This is in line with the C++20 change that requires the default constructor
of std::atomic to value initialize the atomic object.
Also, use is_nothrow_default_constructible to properly deduce noexceptness
of the default constructors of atomics.
This allows to mark bitwise_cast constexpr when the conditions to use
bit_cast are met:
- both source and target types have the same size, and
- the source type has no padding bits.
The latter is checked using has_unique_object_representations trait, which
we also implement using intrinsics when not available in the standard
library.
This allows atomic constructors to become constexpr for structs and floating
point types with no padding and whose size matches the atomic storage size.
Use __builtin_clear_padding and __builtin_zero_non_value_bits that were
introduced in gcc 11 and MSVC 19.27 to clear the padding bits in atomic
types. The intrinsics are used in bitwise_cast and atomic reference
constructors.
Also, separated atomic impl specializations for enums to allow using
static_cast to convert values to storage. This in turn allows to
relax compiler requirements to mark atomic constructors constexpr.
Updated docs and added tests for structs with padding and constexpr
atomic constructors.
When targeting Windows 8, the always_has_native_wait_notify static constant
would be set to false even though the native implementation of waiting
and notifying operations through WaitOnAddress would always be used.
To fix this, moved direct WaitOnAddress & co. usage to public header. This
also requires users to link with synchronization.lib, which is done
automatically on compilers that support auto-linking.
The compiled library still implements runtime detection of WaitOnAddress,
even when building for Windows 8 and later. This allows user's code to
be later compiled for Windows 7 and older and still work. This code is
not used when user's code targets Windows 8 or later.
As part of this refactoring, renamed has_synchronization test and
related CMake variable to better communicate that we're testing for
a library.