LLDB mainline
HostThreadPosix.cpp
Go to the documentation of this file.
1//===-- HostThreadPosix.cpp -----------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "lldb/Utility/Status.h"
11
12#include <cerrno>
13#include <pthread.h>
14
15using namespace lldb;
16using namespace lldb_private;
17
19
21 : HostNativeThreadBase(thread) {}
24
27 if (IsJoinable()) {
28 int err = ::pthread_join(m_thread, result);
30 } else {
31 if (result)
32 *result = nullptr;
33 error = Status(EINVAL, eErrorTypePOSIX);
34 }
35
36 Reset();
37 return error;
38}
39
42 if (IsJoinable()) {
43#ifndef __FreeBSD__
44 llvm_unreachable("someone is calling HostThread::Cancel()");
45#else
46 int err = ::pthread_cancel(m_thread);
48#endif
49 }
50 return error;
51}
52
55 if (IsJoinable()) {
56 int err = ::pthread_detach(m_thread);
58 }
59 Reset();
60 return error;
61}
static llvm::raw_ostream & error(Stream &strm)
Status Join(lldb::thread_result_t *result) override
An error handling class.
Definition: Status.h:115
A class that represents a running process on the host machine.
Definition: SBAddress.h:15
void * thread_result_t
Definition: lldb-types.h:62
@ eErrorTypePOSIX
POSIX error codes.
pthread_t thread_t
Definition: lldb-types.h:58