blob: 06bc502516a6f49ec286460e7747aa0511735cae [file] [log] [blame]
Bruce Mitchener910af4d2015-10-13 05:04:13 +00001//===-- HostThreadNetBSD.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// lldb Includes
11#include "lldb/Host/netbsd/HostThreadNetBSD.h"
12#include "lldb/Host/Host.h"
13
14// C includes
15#include <errno.h>
16#include <pthread.h>
17#include <stdlib.h>
18#include <string.h>
19#include <sys/sysctl.h>
20#include <sys/user.h>
21
22// C++ includes
23#include <string>
24
25using namespace lldb_private;
26
27HostThreadNetBSD::HostThreadNetBSD()
28{
29}
30
31HostThreadNetBSD::HostThreadNetBSD(lldb::thread_t thread)
32 : HostThreadPosix(thread)
33{
34}
35
36void
37HostThreadNetBSD::SetName(lldb::thread_t thread, llvm::StringRef &name)
38{
39 ::pthread_setname_np(thread, "%s", const_cast<char*>(name.data()));
40}
41
42void
43HostThreadNetBSD::GetName(lldb::thread_t thread, llvm::SmallVectorImpl<char> &name)
44{
45 char buf[PTHREAD_MAX_NAMELEN_NP];
46 ::pthread_getname_np(thread, buf, PTHREAD_MAX_NAMELEN_NP);
47
48 name.clear();
49 name.append(buf, buf + strlen(buf));
50}