[libcxx] [llvm] [libc++] Refactor the configuration macros to being always defined (PR #112094)
    Louis Dionne via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Wed Nov  6 05:49:57 PST 2024
    
    
  
ldionne wrote:
Here's what I would suggest:
```c++
#if __has_include(<pthread.h>)
#include <pthread.h>
inline void maybe_set_thread_name(std::thread& t, std::string const& name) {
  if constexpr (std::is_same_v<std::thread::native_handle_type, ::pthread_t>) {
    (void)pthread_setname_np(t.native_handle(), name.c_str());
  }
}
#else
inline void maybe_set_thread_name(std::thread& t, std::string const& name) {
  // don't even try
}
#endif
```
https://github.com/llvm/llvm-project/pull/112094
    
    
More information about the llvm-commits
mailing list