diff options
author | Krzysztof Parzyszek <kparzysz@codeaurora.org> | 2017-03-03 21:53:12 +0000 |
---|---|---|
committer | Krzysztof Parzyszek <kparzysz@codeaurora.org> | 2017-03-03 21:53:12 +0000 |
commit | 6cf254034f05f90c7387913667afd12eceaeb4d9 (patch) | |
tree | 8c96228f69da10357e36cae21c21ced602568d84 /llvm/lib/Support/Unix/Threading.inc | |
parent | 640cee0d2d7f5cd2604abcc580a63a6a60b34030 (diff) | |
download | bcm5719-llvm-6cf254034f05f90c7387913667afd12eceaeb4d9.tar.gz bcm5719-llvm-6cf254034f05f90c7387913667afd12eceaeb4d9.zip |
Detect the existence of pthread_{s,g}etname_np in libpthread on Linux
Older Linux distributions may not have those functions.
llvm-svn: 296915
Diffstat (limited to 'llvm/lib/Support/Unix/Threading.inc')
-rw-r--r-- | llvm/lib/Support/Unix/Threading.inc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc index 2bcf8e5cd5f..6301a674df0 100644 --- a/llvm/lib/Support/Unix/Threading.inc +++ b/llvm/lib/Support/Unix/Threading.inc @@ -115,8 +115,10 @@ void llvm::set_thread_name(const Twine &Name) { StringRef NameStr = Name.toNullTerminatedStringRef(Storage); #if defined(__linux__) #if (defined(__GLIBC__) && defined(_GNU_SOURCE)) || defined(__ANDROID__) +#if HAVE_PTHREAD_SETNAME_NP ::pthread_setname_np(::pthread_self(), NameStr.data()); #endif +#endif #elif defined(__FreeBSD__) ::pthread_set_name_np(::pthread_self(), NameStr.data()); #elif defined(__NetBSD__) @@ -173,10 +175,12 @@ void llvm::get_thread_name(SmallVectorImpl<char> &Name) { Name.append(buf, buf + strlen(buf)); #elif defined(__linux__) #if (defined(__GLIBC__) && defined(_GNU_SOURCE)) || defined(__ANDROID__) +#if HAVE_PTHREAD_GETNAME_NP constexpr int MAXNAMELEN = 16; char Buffer[MAXNAMELEN]; if (0 == ::pthread_getname_np(::pthread_self(), Buffer, MAXNAMELEN)) Name.append(Buffer, Buffer + strlen(Buffer)); #endif #endif +#endif } |