@@ -141,12 +141,8 @@ static constexpr uint32_t get_max_thread_name_length_impl() {
141
141
return PTHREAD_MAX_NAMELEN_NP;
142
142
#elif defined(__APPLE__)
143
143
return 64 ;
144
- #elif defined(__linux__)
145
- #if HAVE_PTHREAD_SETNAME_NP
144
+ #elif defined(__linux__) && HAVE_PTHREAD_SETNAME_NP
146
145
return 16 ;
147
- #else
148
- return 0 ;
149
- #endif
150
146
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
151
147
return 16 ;
152
148
#elif defined(__OpenBSD__)
@@ -174,12 +170,8 @@ void llvm::set_thread_name(const Twine &Name) {
174
170
if (get_max_thread_name_length () > 0 )
175
171
NameStr = NameStr.take_back (get_max_thread_name_length () - 1 );
176
172
(void )NameStr;
177
- #if defined(__linux__)
178
- #if (defined(__GLIBC__) && defined(_GNU_SOURCE)) || defined(__ANDROID__)
179
- #if HAVE_PTHREAD_SETNAME_NP
173
+ #if defined(__linux__) && HAVE_PTHREAD_SETNAME_NP
180
174
::pthread_setname_np (::pthread_self(), NameStr.data());
181
- #endif
182
- #endif
183
175
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
184
176
::pthread_set_name_np (::pthread_self(), NameStr.data());
185
177
#elif defined(__NetBSD__)
@@ -241,14 +233,12 @@ void llvm::get_thread_name(SmallVectorImpl<char> &Name) {
241
233
::pthread_get_name_np (::pthread_self(), buf, len);
242
234
243
235
Name.append (buf, buf + strlen (buf));
244
- #elif defined(__linux__)
245
- #if HAVE_PTHREAD_GETNAME_NP
236
+ #elif defined(__linux__) && HAVE_PTHREAD_GETNAME_NP
246
237
constexpr uint32_t len = get_max_thread_name_length_impl ();
247
238
char Buffer[len] = {' \0 ' }; // FIXME: working around MSan false positive.
248
239
if (0 == ::pthread_getname_np (::pthread_self (), Buffer, len))
249
240
Name.append (Buffer, Buffer + strlen (Buffer));
250
241
#endif
251
- #endif
252
242
}
253
243
254
244
SetThreadPriorityResult llvm::set_thread_priority (ThreadPriority Priority) {
0 commit comments