--- src/mongoc/mongoc-log.c.orig 2022-11-07 14:43:57.000000000 +0800 +++ src/mongoc/mongoc-log.c 2023-07-15 05:54:52.000000000 +0800 @@ -31,6 +31,10 @@ #include #include +#if defined(__APPLE__) +#include +#endif + #include "mongoc-log.h" #include "mongoc-log-private.h" #include "mongoc-thread-private.h" @@ -205,7 +209,17 @@ pid = (int) _lwp_self (); #elif defined(__APPLE__) uint64_t tid; +#if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060) || defined(__POWERPC__) + tid = pthread_mach_thread_np (pthread_self()); +#elif MAC_OS_X_VERSION_MIN_REQUIRED < 1060 + if (&pthread_threadid_np) { + 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 ();