Skip to content

Commit 7b0e4c6

Browse files
authored
CDRIVER-5719 fix build for macOS without pthread_threadid_np (#1727)
1 parent e5b9cdf commit 7b0e4c6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/libmongoc/src/mongoc/mongoc-log.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <process.h>
2222
#elif defined(__APPLE__)
2323
#include <pthread.h>
24+
#include <AvailabilityMacros.h>
2425
#elif defined(__FreeBSD__)
2526
#include <sys/thr.h>
2627
#elif defined(__NetBSD__)
@@ -197,9 +198,15 @@ mongoc_log_default_handler (mongoc_log_level_t log_level, const char *log_domain
197198
#elif defined(__NetBSD__)
198199
pid = (int) _lwp_self ();
199200
#elif defined(__APPLE__)
201+
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
202+
// libc on macOS < 10.7 does not support `pthread_threadid_np`
203+
mach_port_t tid = pthread_mach_thread_np (pthread_self ());
204+
pid = (int) tid;
205+
#else
200206
uint64_t tid;
201207
pthread_threadid_np (0, &tid);
202208
pid = (int) tid;
209+
#endif
203210
#else
204211
pid = (int) getpid ();
205212
#endif

0 commit comments

Comments
 (0)