2
0
mirror of https://github.com/boostorg/atomic.git synced 2026-01-19 04:02:09 +00:00

36 Commits

Author SHA1 Message Date
Andrey Semashev
8491f958de Added a release note for the thread_pause fix on Apple PowerPC. 2025-12-13 19:15:49 +03:00
Andrey Semashev
ff2574cd03 Enable bitwise operations for enumerations.
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.
2025-06-13 00:24:13 +03:00
Andrey Semashev
1fa02d93f0 Removed BOOST_ATOMIC_NO_ATOMIC_FLAG_INIT macro definition.
Since the library now requires C++11, BOOST_ATOMIC_FLAG_INIT is always
supported.
2025-06-12 00:54:03 +03:00
Andrey Semashev
d03f8f7564 Deprecate support for Windows CE.
This platform has long been untested (if it ever was) and practically
unmaintained. The support will be removed in a future release.
2025-06-11 01:57:25 +03:00
Andrey Semashev
03eb376616 Renamed smt_pause to thread_pause.
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.
2025-06-08 23:19:36 +03:00
Andrey Semashev
d3940538d3 Expose pause() as smt_pause().
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.
2025-06-08 20:08:57 +03:00
Andrey Semashev
280f16ea1f Added docs for timed waiting operations. 2025-06-08 15:58:18 +03:00
Andrey Semashev
1f51e2b9f7 Corrected changelog. 2025-05-31 20:16:34 +03:00
Andrey Semashev
17ad17242b Fixed a typo. 2025-05-30 14:41:24 +03:00
Andrey Semashev
140bb01b17 Added a note for MinGW-w64 users regarding Windows 10. 2025-05-30 13:59:15 +03:00
Andrey Semashev
411f6f65ab Removed support for Windows versions prior to Windows 10.
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.
2025-05-29 18:06:10 +03:00
Andrey Semashev
1935a34fa6 Corrected changelog. 2025-05-25 18:33:08 +03:00
Andrey Semashev
e288a8c7b6 Added a changelog entry for TSAN instrumentation. 2025-05-23 11:56:29 +03:00
Andrey Semashev
5e2e016668 Fixed pointer arithmetics in wait state initialization on reallocation.
Fixes https://github.com/boostorg/atomic/issues/72.
2024-11-21 20:06:41 +03:00
Andrey Semashev
6ee31382b2 Use futex function wrapper on OpenBSD.
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.
2024-05-19 03:23:49 +03:00
Andrey Semashev
b91d55150f Added a changelog entry for pause on RISC-V. 2024-01-15 14:46:39 +03:00
Andrey Semashev
6ec7f682f8 Added a note about deprecation of Windows versions prior to 10. 2023-10-08 20:49:09 +03:00
Andrey Semashev
4a9078a7b8 Dropping support for C++03 compilers.
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.
2023-09-02 19:31:10 +03:00
Andrey Semashev
f7735b60a6 Added support for x87 extended double with reduced precision.
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.
2023-08-22 13:50:45 +03:00
Andrey Semashev
474e125ab6 Fixed compilation of atomic_ref for const-qualified types.
Fixes https://github.com/boostorg/atomic/issues/62.
2023-04-29 15:11:25 +03:00
Andrey Semashev
295afdecd7 Added a note about C++03 deprecation.
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.
2023-03-29 02:27:26 +03:00
Andrey Semashev
c277de6b49 Removed atomic<>::storage() and storage_type.
These public members were deprecated since Boost.Atomic 1.73.
2022-12-22 18:32:09 +03:00
Andrey Semashev
2834450fc3 Only use x86 vector insns for stores with memory orders other than seq_cst.
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.
2022-12-22 14:33:25 +03:00
Andrey Semashev
24a41db3e6 Use AVX instructions for 128-bit loads and stores on x86.
Latest edition of SDM explicitly guarantees that any CPU supporting
AVX guarantees atomicity of aligned 128-bit loads and stores using
movdqa and similar instructions. AMD also confirmed this for their
CPUs here:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104688#c10

And also Zhiaoxin:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104688#c20
2022-12-22 14:29:11 +03:00
Andrey Semashev
963b694313 Added a release note for the fixed compilation with MSVC 14.0. 2022-06-04 20:33:27 +03:00
Andrey Semashev
b1cd90dcec Improved endianness checks portability on ARM, AArch32 and AArch64.
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.
2022-04-26 11:39:16 +03:00
Andrey Semashev
08a055ec27 Added BOOST_ATOMIC_NO_DARWIN_ULOCK macro.
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.
2022-03-04 22:36:40 +03:00
Andrey Semashev
bf08155d16 Fix compilation for UWP.
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.
2021-12-15 02:06:11 +03:00
Andrey Semashev
ead065fc47 Added a release note for VS2015 workaround. 2021-11-15 13:28:12 +03:00
Andrey Semashev
4ae987a617 Added a release note for the added workaround for AIX. 2021-10-28 18:15:08 +03:00
Andrey Semashev
e955004915 Mention bit_cast as a requirement for constexpr atomic ctors. 2021-10-12 23:35:55 +03:00
Andrey Semashev
8a7aaa543d Make atomic default ctors value initialize the contained object.
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.
2021-10-12 20:36:11 +03:00
Andrey Semashev
2211fee1d4 Added bitwise_cast implementation based on bit_cast intrinsics.
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.
2021-10-12 18:55:13 +03:00
Andrey Semashev
746ea2649b Added support for types with padding. Made atomic ctors for enums constexpr.
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.
2021-10-11 18:05:06 +03:00
Andrey Semashev
805e309a29 Fixed discrepancy between always_has_native_wait_notify and caps macros.
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.
2021-10-09 23:40:42 +03:00
Andrey Semashev
ffdccceeb1 Added changelog document. 2021-09-26 23:07:49 +03:00