[PATCH] D45359: [cmake] Improve pthread_[gs]etname_np detection code
Pavel Labath via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 18 06:16:54 PDT 2018
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330251: [cmake] Improve pthread_[gs]etname_np detection code (authored by labath, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D45359
Files:
llvm/trunk/cmake/config-ix.cmake
llvm/trunk/lib/Support/Unix/Threading.inc
Index: llvm/trunk/lib/Support/Unix/Threading.inc
===================================================================
--- llvm/trunk/lib/Support/Unix/Threading.inc
+++ llvm/trunk/lib/Support/Unix/Threading.inc
@@ -204,13 +204,11 @@
Name.append(buf, buf + strlen(buf));
#elif defined(__linux__)
-#if (defined(__GLIBC__) && defined(_GNU_SOURCE)) || defined(__ANDROID__)
#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.
if (0 == ::pthread_getname_np(::pthread_self(), Buffer, len))
Name.append(Buffer, Buffer + strlen(Buffer));
#endif
#endif
-#endif
}
Index: llvm/trunk/cmake/config-ix.cmake
===================================================================
--- llvm/trunk/cmake/config-ix.cmake
+++ llvm/trunk/cmake/config-ix.cmake
@@ -252,12 +252,15 @@
# This check requires _GNU_SOURCE
check_symbol_exists(sched_getaffinity sched.h HAVE_SCHED_GETAFFINITY)
check_symbol_exists(CPU_COUNT sched.h HAVE_CPU_COUNT)
-if(HAVE_LIBPTHREAD)
- check_library_exists(pthread pthread_getname_np "" HAVE_PTHREAD_GETNAME_NP)
- check_library_exists(pthread pthread_setname_np "" HAVE_PTHREAD_SETNAME_NP)
-elseif(PTHREAD_IN_LIBC)
- check_library_exists(c pthread_getname_np "" HAVE_PTHREAD_GETNAME_NP)
- check_library_exists(c pthread_setname_np "" HAVE_PTHREAD_SETNAME_NP)
+if (NOT PURE_WINDOWS)
+ if (LLVM_PTHREAD_LIB)
+ list(APPEND CMAKE_REQUIRED_LIBRARIES ${LLVM_PTHREAD_LIB})
+ endif()
+ check_symbol_exists(pthread_getname_np pthread.h HAVE_PTHREAD_GETNAME_NP)
+ check_symbol_exists(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
+ if (LLVM_PTHREAD_LIB)
+ list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ${LLVM_PTHREAD_LIB})
+ endif()
endif()
# available programs checks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45359.142923.patch
Type: text/x-patch
Size: 1820 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180418/d23cdd75/attachment.bin>
More information about the llvm-commits
mailing list