From 3b5602453a6104a24ff33d5c384c6b7fa416d8b2 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Mon, 16 Sep 2024 08:51:28 +0800 Subject: [PATCH] mongoc-log.c: fix build for macOS without pthread_threadid_np --- src/libmongoc/src/mongoc/mongoc-log.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git src/libmongoc/src/mongoc/mongoc-log.c src/libmongoc/src/mongoc/mongoc-log.c index 2ea2c35bb..a04fc4d4d 100644 --- src/libmongoc/src/mongoc/mongoc-log.c +++ src/libmongoc/src/mongoc/mongoc-log.c @@ -21,6 +21,7 @@ #include #elif defined(__APPLE__) #include +#include #elif defined(__FreeBSD__) #include #elif defined(__NetBSD__) @@ -198,7 +199,17 @@ mongoc_log_default_handler (mongoc_log_level_t log_level, const char *log_domain pid = (int) _lwp_self (); #elif defined(__APPLE__) uint64_t tid; +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060 || defined(__ppc__) + tid = pthread_mach_thread_np(pthread_self()); +#elif MAC_OS_X_VERSION_MIN_REQUIRED < 1060 + if (&pthread_threadid_np != NULL) { + pthread_threadid_np (0, &tid); + } else { + tid = pthread_mach_thread_np(pthread_self()); + } +#else pthread_threadid_np (0, &tid); +#endif pid = (int) tid; #else pid = (int) getpid ();