This avoids the potential clash with another library that could make
a similar check for <type_traits> but require a different set of
type traits. b2 seems to use the string as part of the key in the
config cache, so if the two different config checks have a matching
description string it is unknown which check result is cached and used.
Using a relative path is more explicit and should avoid a potential
name clash in case if there appears a different b2 module with the same
name in a different search location.
Added a missing import-search directive to config/Jamfile so that
atomic-arch-config.jam is found when configure-time checks are invoked
from tests. This allows us to enable the type_traits check for tests.
Added is_trivially_copyable and is_trivially_default_constructible type
traits that rely on the non-standard type traits available in libstdc++
from gcc 4.8 and 4.9.
Rather than requiring cxx11_hdr_type_traits in the library and test
requirements, use a more limited test that checks only the type traits
we use in Boost.Atomic.
Similarly, downgrade the requirement of C++ unrestricted unions to
unions with members that have non-trivial default constructors.
Remove the requirements of alignas and alignof, since those are not
mandatory for now.
Closes https://github.com/boostorg/atomic/issues/74.
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.
Occasionally, notify_one_test fails because the second thread receives
value2 instead of value3, even though the wakeup delay check passes.
This typically happens on one of the VM runners, so it is possible
there is some weird timing issue, when the thread gets woken up spuriously,
before the atomic value is updated, but the recorded wait time ends
up just above the expected waiting duration. Just retry the test
in this case.
Also use seq_cst in wait tests consistently instead of release on
stores and seq_cst on waits.
Replaced C++11 emulation macros with proper keywords, replaced typedefs
with using-style type aliases, removed type traits shims that are no
longer needed.
ARM64EC is similar to ARM64 in that the binary will run natively on
ARM64 CPUs and therefore supports all ARM64 intrinsics. The difference
is that it also supports AMD64 intrinsics (and therefore defines _M_AMD64
and _M_X64), which will be emulated by an implicitly linked library.
ARM64EC also changes ABI compared to ARM64, but it doesn't affect
Boost.Atomic.
Changed predefined macro checks in order to use msvc_arm backend for
ARM64EC instead of msvc_x86. The benefit is that msvc_arm uses memory
order-aware intrinsics instead of the full-fence ones on x86. The
downside is that 128-bit atomics won't be available (for now).
Also define BOOST_ATOMIC_DETAIL_INT_FP_ENDIAN_MATCH for ARM/ARM64
on Windows.
The macro is not documented in MSDN and it's not entirely clear when
it is defined (and, in particular, whether _M_ARM is also defined at
the same time). Remove it for now, until there appears demand for
it and a knowledgeable user who knows what it means and when it is
defined.
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 uses std::chrono::steady_clock universally in tests where monotonic
clock is needed. On Windows, hopefully this will resolve the time mismatches
between wakeups and externally measures times. Given that we use absolute
timeouts for sleeps, hopefully, this will also not reintroduce problems
that were originally worked around by test_clock.
Since the default constructor may be non-trivial and throwing, we have
to suppress it in the memcpy-based implementation of bitwise_cast. Since
the type must be trivially copyable, initializing the object using memcpy
is a valid way of creating it, so there is no UB.
This is necessary for all atomic operations that involve bitwise_cast
internally to remain noexcept, as specified in the C++ standard.
Also removed remove_cv shim since we now require type_traits and the
shim is no longer used.
Added a configure test for pthread_cond_clockwait presence. If it is
available, use it for timed waits with absolute timeouts on POSIX platforms.
Futex-based implementation has been improvved to use proper atomic operations
to access m_cond, which is needed to avoid races between the futex syscall and
our notifying operations. Also, check if m_cond has changed whil looping in
the waiting operations.