From 0a9f133c0448657c6485afb2a856746164298479 Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Sun, 6 Jul 2014 06:24:00 +0000 Subject: [PATCH] libclang: make darwin pthread hacks conditional on LLVM_ENABLE_THREADS 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 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 57ebb8a1e7..0e5ef31503 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -53,7 +53,11 @@ #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 #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 -- 2.40.0