From 0917b8bd56401f43683061111d91a7cf0b194491 Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Fri, 5 May 2017 12:03:21 -0700 Subject: [PATCH] Fix getCurrentThreadName() on OSX Summary: OSX was sad. Now it should be happy. Reviewed By: mzlee Differential Revision: D5011751 fbshipit-source-id: 77f22ff461036d8530d8f650396d8e12503448e7 --- folly/ThreadName.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/folly/ThreadName.cpp b/folly/ThreadName.cpp index 97db551f..22ead209 100644 --- a/folly/ThreadName.cpp +++ b/folly/ThreadName.cpp @@ -60,25 +60,16 @@ bool canSetOtherThreadName() { static constexpr size_t kMaxThreadNameLength = 16; Optional getCurrentThreadName() { -#if !FOLLY_HAVE_PTHREAD - return Optional(); -#else -#if FOLLY_HAS_PTHREAD_SETNAME_NP_THREAD_NAME +#if FOLLY_HAS_PTHREAD_SETNAME_NP_THREAD_NAME || \ + FOLLY_HAS_PTHREAD_SETNAME_NP_NAME std::array buf; if (pthread_getname_np(pthread_self(), buf.data(), buf.size()) != 0) { return Optional(); } return make_optional(std::string(buf.data())); -#elif FOLLY_HAS_PTHREAD_SETNAME_NP_NAME - std::array buf; - if (pthread_getname_np(buf.data(), buf.size()) != 0) { - return Optional(); - } - return make_optional(std::string(buf.data())); #else return Optional(); #endif -#endif } bool setThreadName(std::thread::id tid, StringPiece name) { -- 2.34.1