Skip to content

Commit

Permalink
Added BOOST_ATOMIC_NO_DARWIN_ULOCK macro.
Browse files Browse the repository at this point in the history
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 #55.
  • Loading branch information
Lastique committed Mar 4, 2022
1 parent 8915f67 commit 08a055e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
7 changes: 5 additions & 2 deletions doc/atomic.qbk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[/
/ Copyright (c) 2009 Helge Bahmann
/ Copyright (c) 2014, 2017, 2018, 2020, 2021 Andrey Semashev
/ Copyright (c) 2014, 2017, 2018, 2020-2022 Andrey Semashev
/
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -11,7 +11,7 @@
[authors [Bahmann, Helge][Semashev, Andrey]]
[copyright 2011 Helge Bahmann]
[copyright 2012 Tim Blechmann]
[copyright 2013, 2017, 2018, 2020, 2021 Andrey Semashev]
[copyright 2013, 2017, 2018, 2020-2022 Andrey Semashev]
[id atomic]
[dirname atomic]
[purpose Atomic operations]
Expand Down Expand Up @@ -386,6 +386,9 @@ The following macros affect library behavior:
[[`BOOST_ATOMIC_NO_FLOATING_POINT`] [When defined, support for floating point operations is disabled.
Floating point types shall be treated similar to trivially copyable structs and no capability macros
will be defined.]]
[[`BOOST_ATOMIC_NO_DARWIN_ULOCK`] [Affects compilation on Darwin systems (Mac OS, iOS, tvOS, watchOS).
When defined, disables use of `ulock` API to implement waiting and notifying operations. This may
be useful to comply with Apple App Store requirements.]]
[[`BOOST_ATOMIC_FORCE_FALLBACK`] [When defined, all operations are implemented with locks.
This is mostly used for testing and should not be used in real world projects.]]
[[`BOOST_ATOMIC_DYN_LINK` and `BOOST_ALL_DYN_LINK`] [Control library linking. If defined,
Expand Down
1 change: 1 addition & 0 deletions doc/changelog.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[heading Boost 1.79]

* Fixed compilation for Universal Windows Platform (UWP). ([github_issue 54])
* Added `BOOST_ATOMIC_NO_DARWIN_ULOCK` configuration macro. The macto affects compilation on Darwin systems and disables `ulock`-based implementation of waiting and notifying operations. This may be useful to comply with Apple App Store requirements. ([github_issue 55])

[heading Boost 1.78]

Expand Down
17 changes: 9 additions & 8 deletions include/boost/atomic/detail/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@
((defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 407)) ||\
(defined(BOOST_CLANG) && ((__clang_major__ * 100 + __clang_minor__) >= 302))) &&\
(\
(__GCC_ATOMIC_BOOL_LOCK_FREE + 0) == 2 ||\
(__GCC_ATOMIC_CHAR_LOCK_FREE + 0) == 2 ||\
(__GCC_ATOMIC_SHORT_LOCK_FREE + 0) == 2 ||\
(__GCC_ATOMIC_INT_LOCK_FREE + 0) == 2 ||\
(__GCC_ATOMIC_LONG_LOCK_FREE + 0) == 2 ||\
(__GCC_ATOMIC_LLONG_LOCK_FREE + 0) == 2\
(__GCC_ATOMIC_BOOL_LOCK_FREE == 2) ||\
(__GCC_ATOMIC_CHAR_LOCK_FREE == 2) ||\
(__GCC_ATOMIC_SHORT_LOCK_FREE == 2) ||\
(__GCC_ATOMIC_INT_LOCK_FREE == 2) ||\
(__GCC_ATOMIC_LONG_LOCK_FREE == 2) ||\
(__GCC_ATOMIC_LLONG_LOCK_FREE == 2)\
)

#define BOOST_ATOMIC_DETAIL_CORE_BACKEND gcc_atomic
Expand Down Expand Up @@ -153,10 +153,11 @@
#if defined(BOOST_ATOMIC_DETAIL_HAS_FUTEX)
#define BOOST_ATOMIC_DETAIL_WAIT_BACKEND futex
#elif defined(__APPLE__)
#if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200) || \
#if !defined(BOOST_ATOMIC_NO_DARWIN_ULOCK) && (\
(defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200) || \
(defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 100000) || \
(defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 100000) || \
(defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 30000)
(defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 30000))
// Darwin 16+ supports ulock API
#define BOOST_ATOMIC_DETAIL_WAIT_BACKEND darwin_ulock
#endif // __ENVIRONMENT_*_VERSION_MIN_REQUIRED__
Expand Down

0 comments on commit 08a055e

Please sign in to comment.