--- a/llvm/lib/Support/CrashRecoveryContext.cpp
+++ b/llvm/lib/Support/CrashRecoveryContext.cpp
@@ -438,13 +438,13 @@ void CrashRecoveryContext::HandleExit(int RetCode) {
 
 // FIXME: Portability.
 static void setThreadBackgroundPriority() {
-#ifdef __APPLE__
+#if defined(__APPLE__) && defined(PRIO_DARWIN_THREAD) && defined(PRIO_DARWIN_BG)
   setpriority(PRIO_DARWIN_THREAD, 0, PRIO_DARWIN_BG);
 #endif
 }
 
 static bool hasThreadBackgroundPriority() {
-#ifdef __APPLE__
+#if defined(__APPLE__) && defined(PRIO_DARWIN_THREAD)
   return getpriority(PRIO_DARWIN_THREAD, 0) == 1;
 #else
   return false;

