From 0f71064f49a10ce4006901115d405e79041530a8 Mon Sep 17 00:00:00 2001
From: barracuda156 <vital.had@gmail.com>
Date: Tue, 4 Jun 2024 07:34:24 +0800
Subject: [PATCH] threads.c: fix for pthread_threadid_np on macOS

---
 src/ddsrt/src/threads/posix/threads.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git src/ddsrt/src/threads/posix/threads.c src/ddsrt/src/threads/posix/threads.c
index f61a4f6e..684468f5 100644
--- src/ddsrt/src/threads/posix/threads.c
+++ src/ddsrt/src/threads/posix/threads.c
@@ -49,6 +49,7 @@ typedef struct {
 #include <mach/task.h>
 #include <mach/task_info.h>
 #include <mach/vm_map.h>
+#include <AvailabilityMacros.h>
 #elif defined(__sun)
 #define MAXTHREADNAMESIZE (31)
 #elif defined(__FreeBSD__)
@@ -455,9 +456,9 @@ ddsrt_gettid(void)
 #elif defined(__FreeBSD__) && (__FreeBSD__ >= 9)
   /* FreeBSD >= 9.0 */
   tid = pthread_getthreadid_np();
-#elif defined(__APPLE__) && !(defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
-                                      __MAC_OS_X_VERSION_MIN_REQUIRED < 1060)
-  /* macOS >= 10.6 */
+#elif defined(__APPLE__) && !defined(__POWERPC__) && \
+  !(defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED < 1060)
+  /* macOS >= 10.6, but for ppc this symbol is unavailable */
   pthread_threadid_np(NULL, &tid);
 #elif defined(__VXWORKS__)
   tid = taskIdSelf();
