Skip to content

Commit 03e7f2c

Browse files
committed
Fixes #283 ("Regression on macOS: pthread_threadid_np was not declared")
1 parent 1c74a61 commit 03e7f2c

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

doc/interprocess.qbk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6860,6 +6860,9 @@ thank them:
68606860
* Use of FILE_DISPOSITION_POSIX_SEMANTICS semantics on Windows for unlink operations,
68616861
fallbacks to optimized classic approach for older Windows versions and filesystems.
68626862

6863+
* Fixed bugs:
6864+
* [@https://github.com/boostorg/interprocess/issues/283 GitHub #283 (['"Regression on macOS: pthread_threadid_np was not declared"])].
6865+
68636866
[endsect]
68646867

68656868
[section:release_notes_boost_1_92_00 Boost 1.92 Release]

include/boost/interprocess/detail/os_thread_functions.hpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,32 @@
6161
#elif defined(__FreeBSD__)
6262
#include <pthread_np.h>
6363
#elif defined(__APPLE__)
64+
// TargetConditionals.h first: the TARGET_OS_* tests below depend on it.
65+
// Availability.h defines __MAC_OS_X_VERSION_MIN_REQUIRED and
66+
// __IPHONE_OS_VERSION_MIN_REQUIRED (pthread.h pulls it in transitively,
67+
// but don't rely on that).
68+
#include <TargetConditionals.h>
69+
#include <Availability.h>
6470
#include <pthread.h>
71+
72+
// pthread_threadid_np: macOS 10.6+, iOS 3.2+; every tvOS, watchOS and
73+
// visionOS release provides it.
74+
#if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) \
75+
&& __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060) \
76+
|| (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) \
77+
&& __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060) \
78+
|| (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) \
79+
&& __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 30200) \
80+
|| (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) \
81+
&& __IPHONE_OS_VERSION_MIN_REQUIRED >= 30200) \
82+
|| defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) \
83+
|| defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) \
84+
|| (defined(TARGET_OS_TV) && TARGET_OS_TV) \
85+
|| (defined(TARGET_OS_WATCH) && TARGET_OS_WATCH) \
86+
|| (defined(TARGET_OS_VISION) && TARGET_OS_VISION) \
87+
|| (defined(TARGET_OS_XR) && TARGET_OS_XR)
88+
#define BOOST_INTERPROCESS_HAS_PTHREAD_THREADID_NP
89+
#endif //macOS 10.6+, iOS 3.2+; tvOS, watchOS, visionOS
6590
#elif defined(__NetBSD__)
6691
#include <lwp.h>
6792
#elif defined(__OpenBSD__)
@@ -324,7 +349,7 @@ inline OS_systemwide_thread_id_t get_current_systemwide_thread_id()
324349
inline OS_systemwide_thread_id_t get_invalid_systemwide_thread_id()
325350
{ return -1; }
326351

327-
#elif defined(__APPLE__) && !defined(BOOST_INTERPROCESS_USE_PTHREAD_AS_SYSTEMWIDE_THREAD_ID)
352+
#elif defined(BOOST_INTERPROCESS_HAS_PTHREAD_THREADID_NP) && !defined(BOOST_INTERPROCESS_USE_PTHREAD_AS_SYSTEMWIDE_THREAD_ID)
328353

329354
typedef uint64_t OS_systemwide_thread_id_t;
330355

0 commit comments

Comments
 (0)