diff options
Diffstat (limited to 'llvm/lib/Support/Unix/Threading.inc')
-rw-r--r-- | llvm/lib/Support/Unix/Threading.inc | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc index 6a67401..037470c 100644 --- a/llvm/lib/Support/Unix/Threading.inc +++ b/llvm/lib/Support/Unix/Threading.inc @@ -98,13 +98,9 @@ void llvm_thread_join_impl(pthread_t Thread) { } } -pthread_t llvm_thread_get_id_impl(pthread_t Thread) { - return Thread; -} +pthread_t llvm_thread_get_id_impl(pthread_t Thread) { return Thread; } -pthread_t llvm_thread_get_current_id_impl() { - return ::pthread_self(); -} +pthread_t llvm_thread_get_current_id_impl() { return ::pthread_self(); } } // namespace llvm @@ -131,7 +127,6 @@ uint64_t llvm::get_threadid() { #endif } - static constexpr uint32_t get_max_thread_name_length_impl() { #if defined(__NetBSD__) return PTHREAD_MAX_NAMELEN_NP; @@ -180,7 +175,7 @@ void llvm::set_thread_name(const Twine &Name) { ::pthread_set_name_np(::pthread_self(), NameStr.data()); #elif defined(__NetBSD__) ::pthread_setname_np(::pthread_self(), "%s", - const_cast<char *>(NameStr.data())); + const_cast<char *>(NameStr.data())); #elif defined(__APPLE__) ::pthread_setname_np(NameStr.data()); #endif @@ -196,8 +191,8 @@ void llvm::get_thread_name(SmallVectorImpl<char> &Name) { struct kinfo_proc *kp = nullptr, *nkp; size_t len = 0; int error; - int ctl[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID | KERN_PROC_INC_THREAD, - (int)pid }; + int ctl[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID | KERN_PROC_INC_THREAD, + (int)pid}; while (1) { error = sysctl(ctl, 4, kp, &len, nullptr, 0); @@ -240,7 +235,7 @@ void llvm::get_thread_name(SmallVectorImpl<char> &Name) { #elif defined(__linux__) #if HAVE_PTHREAD_GETNAME_NP constexpr uint32_t len = get_max_thread_name_length_impl(); - char Buffer[len] = {'\0'}; // FIXME: working around MSan false positive. + char Buffer[len] = {'\0'}; // FIXME: working around MSan false positive. if (0 == ::pthread_getname_np(::pthread_self(), Buffer, len)) Name.append(Buffer, Buffer + strlen(Buffer)); #endif @@ -267,18 +262,22 @@ SetThreadPriorityResult llvm::set_thread_priority(ThreadPriority Priority) { #elif defined(__APPLE__) // https://developer.apple.com/documentation/apple-silicon/tuning-your-code-s-performance-for-apple-silicon // - // Background - Applies to work that isn’t visible to the user and may take significant - // time to complete. Examples include indexing, backing up, or synchronizing data. This - // class emphasizes energy efficiency. + // Background - Applies to work that isn’t visible to the user and may take + // significant time to complete. Examples include indexing, backing up, or + // synchronizing data. This class emphasizes energy efficiency. // - // Utility - Applies to work that takes anywhere from a few seconds to a few minutes to - // complete. Examples include downloading a document or importing data. This class - // offers a balance between responsiveness, performance, and energy efficiency. - const auto qosClass = [&](){ + // Utility - Applies to work that takes anywhere from a few seconds to a few + // minutes to complete. Examples include downloading a document or importing + // data. This class offers a balance between responsiveness, performance, and + // energy efficiency. + const auto qosClass = [&]() { switch (Priority) { - case ThreadPriority::Background: return QOS_CLASS_BACKGROUND; - case ThreadPriority::Low: return QOS_CLASS_UTILITY; - case ThreadPriority::Default: return QOS_CLASS_DEFAULT; + case ThreadPriority::Background: + return QOS_CLASS_BACKGROUND; + case ThreadPriority::Low: + return QOS_CLASS_UTILITY; + case ThreadPriority::Default: + return QOS_CLASS_DEFAULT; } }(); return !pthread_set_qos_class_self_np(qosClass, 0) |