Commit a6306282 authored by Andrew Krieger's avatar Andrew Krieger Committed by Facebook Github Bot

Avoid -Wundef in ThreadName.cpp

Summary:
There's already some ifdef for _WIN32 but it's not consistent.
Also nothing ever sets the define for the supported functions to 0,
so bail on those.

Reviewed By: yfeldblum

Differential Revision: D17559767

fbshipit-source-id: d0eebea980ef4f2b1288bdcc39547453efd3e9be
parent 2e5c9c92
...@@ -31,7 +31,11 @@ namespace folly { ...@@ -31,7 +31,11 @@ namespace folly {
#if __GLIBC_PREREQ(2, 12) #if __GLIBC_PREREQ(2, 12)
// has pthread_setname_np(pthread_t, const char*) (2 params) // has pthread_setname_np(pthread_t, const char*) (2 params)
#define FOLLY_HAS_PTHREAD_SETNAME_NP_THREAD_NAME 1 #define FOLLY_HAS_PTHREAD_SETNAME_NP_THREAD_NAME 1
#else
#define FOLLY_HAS_PTHREAD_SETNAME_NP_THREAD_NAME 0
#endif #endif
#else
#define FOLLY_HAS_PTHREAD_SETNAME_NP_THREAD_NAME 0
#endif #endif
#if defined(__APPLE__) #if defined(__APPLE__)
...@@ -43,12 +47,16 @@ namespace folly { ...@@ -43,12 +47,16 @@ namespace folly {
__IPHONE_OS_VERSION_MIN_REQUIRED >= 30200 __IPHONE_OS_VERSION_MIN_REQUIRED >= 30200
// iOS 3.2+ has pthread_setname_np(const char*) (1 param) // iOS 3.2+ has pthread_setname_np(const char*) (1 param)
#define FOLLY_HAS_PTHREAD_SETNAME_NP_NAME 1 #define FOLLY_HAS_PTHREAD_SETNAME_NP_NAME 1
#else
#define FOLLY_HAS_PTHREAD_SETNAME_NP_NAME 0
#endif #endif
#else
#define FOLLY_HAS_PTHREAD_SETNAME_NP_NAME 0
#endif // defined(__APPLE__) #endif // defined(__APPLE__)
namespace { namespace {
#if FOLLY_HAVE_PTHREAD && !_WIN32 #if FOLLY_HAVE_PTHREAD && !defined(_WIN32)
pthread_t stdTidToPthreadId(std::thread::id tid) { pthread_t stdTidToPthreadId(std::thread::id tid) {
static_assert( static_assert(
std::is_same<pthread_t, std::thread::native_handle_type>::value, std::is_same<pthread_t, std::thread::native_handle_type>::value,
...@@ -70,7 +78,7 @@ pthread_t stdTidToPthreadId(std::thread::id tid) { ...@@ -70,7 +78,7 @@ pthread_t stdTidToPthreadId(std::thread::id tid) {
bool canSetCurrentThreadName() { bool canSetCurrentThreadName() {
#if FOLLY_HAS_PTHREAD_SETNAME_NP_THREAD_NAME || \ #if FOLLY_HAS_PTHREAD_SETNAME_NP_THREAD_NAME || \
FOLLY_HAS_PTHREAD_SETNAME_NP_NAME || _WIN32 FOLLY_HAS_PTHREAD_SETNAME_NP_NAME || defined(_WIN32)
return true; return true;
#else #else
return false; return false;
...@@ -78,7 +86,7 @@ bool canSetCurrentThreadName() { ...@@ -78,7 +86,7 @@ bool canSetCurrentThreadName() {
} }
bool canSetOtherThreadName() { bool canSetOtherThreadName() {
#if FOLLY_HAS_PTHREAD_SETNAME_NP_THREAD_NAME || _WIN32 #if FOLLY_HAS_PTHREAD_SETNAME_NP_THREAD_NAME || defined(_WIN32)
return true; return true;
#else #else
return false; return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment