1 //===-- ThisThread.cpp ------------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "lldb/Host/HostNativeThread.h" 11 #include "lldb/Host/ThisThread.h" 12 13 #include "llvm/ADT/SmallVector.h" 14 15 #include <pthread.h> 16 #if defined (__FreeBSD__) 17 #include <pthread_np.h> 18 #endif 19 20 using namespace lldb_private; 21 22 void SetName(llvm::StringRef name)23ThisThread::SetName(llvm::StringRef name) 24 { 25 #if defined (__FreeBSD__) // Kfreebsd does not have a simple alternative 26 ::pthread_set_name_np(::pthread_self(), name.data()); 27 #endif 28 } 29 30 void GetName(llvm::SmallVectorImpl<char> & name)31ThisThread::GetName(llvm::SmallVectorImpl<char> &name) 32 { 33 #if defined (__FreeBSD__) 34 HostNativeThread::GetName(::pthread_getthreadid_np(), name); 35 #else 36 // Kfreebsd 37 HostNativeThread::GetName((unsigned)pthread_self(), name); 38 #endif 39 } 40