blob: fb25847be24f73092a3016391af7a08b0c28f16a [file] [log] [blame]
Zachary Turner39de3112014-09-09 20:54:56 +00001//===-- 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
Zachary Turner9daf1a62014-09-09 22:11:10 +000010#include "lldb/Host/HostNativeThread.h"
Zachary Turner39de3112014-09-09 20:54:56 +000011#include "lldb/Host/ThisThread.h"
12
13#include "llvm/ADT/SmallVector.h"
14
15#include <pthread.h>
Ed Maste39677642014-09-10 13:38:47 +000016#include <pthread_np.h>
Zachary Turner39de3112014-09-09 20:54:56 +000017
18using namespace lldb_private;
19
20void
21ThisThread::SetName(llvm::StringRef name)
22{
Ed Maste3b7382d2014-09-10 17:09:46 +000023 ::pthread_set_name_np(::pthread_self(), name.data());
Zachary Turner39de3112014-09-09 20:54:56 +000024}
25
26void
27ThisThread::GetName(llvm::SmallVectorImpl<char> &name)
28{
Ed Maste39677642014-09-10 13:38:47 +000029 HostNativeThread::GetName(::pthread_getthreadid_np(), name);
Zachary Turner39de3112014-09-09 20:54:56 +000030}