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

26 Commits

Author SHA1 Message Date
Andrey Semashev
8a6de6d93d Use a more unique string for type_traits config check.
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.
2025-06-19 04:20:15 +03:00
Andrey Semashev
8080f4c434 Change searched-lib to lib in the Jamfile.
Apparently, searched-lib was not supposed to be used in libraries,
and the simple lib target is the preferred way to declare external
libraries.

https://github.com/bfgroup/b2/issues/431#issuecomment-2985057673
2025-06-18 20:08:04 +03:00
Andrey Semashev
f3b61da9c0 Move cxx11_hdr_ratio requirement to from tests the library.
We no longer include <ratio> in tests, but we do include it in the
library headers.
2025-06-18 19:44:17 +03:00
Andrey Semashev
cbe50fe500 Restore compatibility with older gcc versions.
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.
2025-06-18 19:09:03 +03:00
Andrey Semashev
c408cc0e5d Shorter and more consistent output of the pthread_cond_clockwait check. 2025-06-14 20:33:03 +03:00
Andrey Semashev
5991e99381 Added timed wait operations to lock pool.
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.
2025-06-08 04:37:51 +03:00
Andrey Semashev
bafa2665aa Require more C++11 support from the compiler.
We are going to use more C++11 features unconditionally, so add more
requirements in the build files. Don't straight require cxx11 in the
Jamfile as this eliminates all versions of MSVC from the builds.

Also remove older compilers that don't support enough of C++11 from CI.
2025-06-08 04:35:46 +03:00
Andrey Semashev
9ee34b2199 Define _WIN32_WINNT=0x0A00 on MinGW-w64.
Windows SDK headers in MinGW-w64 define _WIN32_WINNT to _WIN32_WINNT_WS03
by default, which prevents Boost.WinAPI from applying its own default.
This disables the WaitOnAddress API that is now required by Boost.Atomic.

Define _WIN32_WINNT to 0x0A00 ourselves on this platform (which is
the highest supported value anyway) to avoid breaking downstream libraries.

Refs https://github.com/boostorg/atomic/issues/73.
2025-05-31 02:04:34 +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
René Ferdinand Rivera Morell
0ed0a5db0c Add support for modular build structure. (#69)
* Make the library modular usable.

* Switch to library requirements instead of source. As source puts extra source in install targets.

* Add missing NO_LIB usage requirements.

* Add requires-b2 check to top-level build file.

* Update dependencies.

* Bump B2 require to 5.2

* Update copyright dates.

* Move inter-lib dependencies to a project variable and into the build targets.

* Split b2 dependencies into public and private.

* Be explicit about the kind of public dependencies and make the winapi be conditional on windows target-os.
2024-10-10 18:31:25 +03:00
Alexander Grund
12b2a55f17 Add C++11 requirements to Jamfile 2023-09-11 12:50:44 +02:00
Andrey Semashev
a172675470 Added source directories to include directories.
This fixes compilation on systems where the compiler does not resolve
includes relative to the current source file directory.

Fixes https://github.com/boostorg/atomic/issues/56.
Closes https://github.com/boostorg/atomic/pull/57.
2022-03-07 01:21:19 +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
a40aa9ba6c Implemented SSE2 and SSE4.1 versions of address lookup algorithms. 2020-09-07 16:57:22 +03:00
Andrey Semashev
06dcdf26c6 Added a configure check to test if synchronization.lib exists.
We need to explicitly link with synchronization.lib when the
WaitOnAddress API is enabled at compile time for ARM targets. Since
this library is only available on newer Windows SDKs, we have to perform
a configure check for whether it is available.
2020-06-21 19:07:28 +03:00
Andrey Semashev
d5dc8f185a Added support for build-time configuration of the lock pool size.
The user may define BOOST_ATOMIC_LOCK_POOL_SIZE_LOG2 macro to specify
binary logarithm of the size of the internal lock pool. The macro
only has effect when building Boost.Atomic.
2020-06-03 01:48:48 +03:00
Andrey Semashev
b9fadc852a Added Windows backend for waiting/notifying operations.
The backend uses runtime detection of availability of Windows API
for futex-like operations (only available since Windows 8).
2020-06-03 01:48:48 +03:00
Andrey Semashev
76e25f36a3 Added generic implementation of C++20 waiting/notifying operations.
The generic implementation is based on the lock pool. A list of condition
variables (or waiting futexes) is added per lock. Basically, the lock
pool serves as a global hash table, where each lock represents
a bucket and each wait state is an element. Every wait operation
allocates a wait state keyed on the pointer to the atomic object. Notify
operations look up the wait state by the atomic pointer and notify
the condition variable/futex. The corresponding lock needs to be acquired
to protect the wait state list during all wait/notify operations.

Backends not involving the lock pool are going to be added later.

The implementation of wait operation extends the C++20 definition in that
it returns the newly loaded value instead of void. This allows the caller
to avoid loading the value himself.

The waiting/notifying operations are not address-free. Address-free variants
will be added later.

Added tests for the new operations and refactored existing tests for atomic
operations. Added docs for the new operations.
2020-06-03 01:39:20 +03:00
Andrey Semashev
0e5e52efad Improve lock pool implementation.
Increased lock pool size to 64 entries and improve pool efficiency:

- Shift off lower pointer bits that are zero due to object alignment.
- Mix higher pointer bits to account for alignment typically imposed by
  malloc/new implementations.
- Use bit masking to select a lock from pool, given that the pool size
  is a power of 2 now.

Also, extracted (u)intptr_t definition to a common header to avoid code
duplication.
2020-03-09 20:01:49 +03:00
Andrey Semashev
2b1dff067e Hidden visibility is now used by default in the superproject. 2018-09-30 22:23:11 +03:00
Andrey Semashev
640f1796b0 Use Boost.Build feature to select hidden visibility. 2018-08-20 14:59:57 +03:00
Andrey Semashev
056588ab42 Switched to hidden visibility when building Boost.Atomic library. 2018-08-17 11:17:23 +03: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
6dc50f685c Merged recent changes from trunk.
[SVN r85604]
2013-09-08 13:55:41 +00:00
Andrey Semashev
b5da965c5b Boost.Atomic and Boost.Lockfree merged from trunk.
[SVN r81976]
2012-12-15 18:28:27 +00:00