Skip to content

Commit 8bcf799

Browse files
authored
Fix have pthread_getname for some system (llvm#110854)
I'm on a system that has have_pthread_getname_np defined but set to 0. The correct behavior here is not to use the function, but presently the macros will attempt to use a non-existing function. This previously worked before https://github.com/llvm/llvm-project/pull/106486/files
1 parent ea62db0 commit 8bcf799

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/lib/Support/Unix/Threading.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,14 @@ void llvm::get_thread_name(SmallVectorImpl<char> &Name) {
237237
char Buffer[len] = {'\0'}; // FIXME: working around MSan false positive.
238238
if (0 == ::pthread_getname_np(::pthread_self(), Buffer, len))
239239
Name.append(Buffer, Buffer + strlen(Buffer));
240-
#elif defined(HAVE_PTHREAD_GET_NAME_NP)
240+
#elif defined(HAVE_PTHREAD_GET_NAME_NP) && HAVE_PTHREAD_GET_NAME_NP
241241
constexpr uint32_t len = get_max_thread_name_length_impl();
242242
char buf[len];
243243
::pthread_get_name_np(::pthread_self(), buf, len);
244244

245245
Name.append(buf, buf + strlen(buf));
246246

247-
#elif defined(HAVE_PTHREAD_GETNAME_NP)
247+
#elif defined(HAVE_PTHREAD_GETNAME_NP) && HAVE_PTHREAD_GETNAME_NP
248248
constexpr uint32_t len = get_max_thread_name_length_impl();
249249
char buf[len];
250250
::pthread_getname_np(::pthread_self(), buf, len);

0 commit comments

Comments
 (0)