]> granicus.if.org Git - clang/commitdiff
libclang: make darwin pthread hacks conditional on LLVM_ENABLE_THREADS
authorAlp Toker <alp@nuanti.com>
Sun, 6 Jul 2014 06:24:00 +0000 (06:24 +0000)
committerAlp Toker <alp@nuanti.com>
Sun, 6 Jul 2014 06:24:00 +0000 (06:24 +0000)
Although these aren't strictly related to LLVM's core threading, it's
reasonable to avoid pthread usage in clang when building with
LLVM_ENABLE_THREADS disabled.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212395 91177308-0d34-0410-b5e6-96231b3b80d8

tools/libclang/CIndex.cpp

index 57ebb8a1e7466a611fcfef3c7641aab94b8cf1c1..0e5ef315031413acc961e770b53cb19bad0476e9 100644 (file)
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
 
-#ifdef __APPLE__
+#if LLVM_ENABLE_THREADS != 0 && defined(__APPLE__)
+#define USE_DARWIN_THREADS
+#endif
+
+#ifdef USE_DARWIN_THREADS
 #include <pthread.h>
 #endif
 
@@ -6799,8 +6803,7 @@ void clang::setThreadBackgroundPriority() {
   if (getenv("LIBCLANG_BGPRIO_DISABLE"))
     return;
 
-  // FIXME: Move to llvm/Support and make it cross-platform.
-#ifdef __APPLE__
+#ifdef USE_DARWIN_THREADS
   setpriority(PRIO_DARWIN_THREAD, 0, PRIO_DARWIN_BG);
 #endif
 }
@@ -7014,8 +7017,8 @@ cxindex::Logger::~Logger() {
   raw_ostream &OS = llvm::errs();
   OS << "[libclang:" << Name << ':';
 
-  // FIXME: Portability.
-#ifdef __APPLE__
+#ifdef USE_DARWIN_THREADS
+  // TODO: Portability.
   mach_port_t tid = pthread_mach_thread_np(pthread_self());
   OS << tid << ':';
 #endif