From bf9d2eadb783b1b2f03c2b4cd1faaa065b1d5aa8 Mon Sep 17 00:00:00 2001 From: David Worsham Date: Thu, 16 Jul 2020 12:43:53 -0700 Subject: [PATCH] fuchsia: Allow setting thread-name (#19792) --- fml/thread.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fml/thread.cc b/fml/thread.cc index b6a4802b487..5834a36fa6d 100644 --- a/fml/thread.cc +++ b/fml/thread.cc @@ -10,6 +10,8 @@ #if defined(OS_WIN) #include +#elif defined(OS_FUCHSIA) +#include #else #include #endif @@ -70,11 +72,11 @@ void Thread::SetCurrentThreadName(const std::string& name) { if (name == "") { return; } -#if OS_MACOSX +#if defined(OS_MACOSX) pthread_setname_np(name.c_str()); -#elif OS_LINUX || OS_ANDROID +#elif defined(OS_LINUX) || defined(OS_ANDROID) pthread_setname_np(pthread_self(), name.c_str()); -#elif OS_WIN +#elif defined(OS_WIN) THREADNAME_INFO info; info.dwType = 0x1000; info.szName = name.c_str(); @@ -85,6 +87,8 @@ void Thread::SetCurrentThreadName(const std::string& name) { reinterpret_cast(&info)); } __except (EXCEPTION_CONTINUE_EXECUTION) { } +#elif defined(OS_FUCHSIA) + zx::thread::self()->set_property(ZX_PROP_NAME, name.c_str(), name.size()); #else FML_DLOG(INFO) << "Could not set the thread name to '" << name << "' on this platform.";