From 11677f879d8d18c894a580355fa7d7b26ae0cbe6 Mon Sep 17 00:00:00 2001
From: Iain Sandoe <iain@sandoe.co.uk>
Date: Thu, 15 Nov 2018 01:05:16 +0000
Subject: [PATCH] [llvm,Darwin9] pthread on D9 is missing
 pthread_setname_np.

---
 llvm/lib/Support/Unix/Threading.inc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc
index 2d49ce1ad74..c9aa467ec1b 100644
--- a/llvm/lib/Support/Unix/Threading.inc
+++ b/llvm/lib/Support/Unix/Threading.inc
@@ -108,7 +108,11 @@ static constexpr uint32_t get_max_thread_name_length_impl() {
 #if defined(__NetBSD__)
   return PTHREAD_MAX_NAMELEN_NP;
 #elif defined(__APPLE__)
+#if HAVE_PTHREAD_SETNAME_NP
   return 64;
+#else
+  return 0;
+#endif
 #elif defined(__linux__)
 #if HAVE_PTHREAD_SETNAME_NP
   return 16;
@@ -153,7 +157,7 @@ void llvm::set_thread_name(const Twine &Name) {
 #elif defined(__NetBSD__)
   ::pthread_setname_np(::pthread_self(), "%s",
     const_cast<char *>(NameStr.data()));
-#elif defined(__APPLE__)
+#elif defined(__APPLE__) && defined(HAVE_PTHREAD_SETNAME_NP)
   ::pthread_setname_np(NameStr.data());
 #endif
 }
