/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Host/posix/HostThreadPosix.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | |
9 | | #include "lldb/Host/posix/HostThreadPosix.h" |
10 | | #include "lldb/Utility/Status.h" |
11 | | |
12 | | #include <cerrno> |
13 | | #include <pthread.h> |
14 | | |
15 | | using namespace lldb; |
16 | | using namespace lldb_private; |
17 | | |
18 | 38.1k | HostThreadPosix::HostThreadPosix() = default; |
19 | | |
20 | | HostThreadPosix::HostThreadPosix(lldb::thread_t thread) |
21 | 7.94k | : HostNativeThreadBase(thread) {} |
22 | | |
23 | 45.6k | HostThreadPosix::~HostThreadPosix() = default; |
24 | | |
25 | 7.40k | Status HostThreadPosix::Join(lldb::thread_result_t *result) { |
26 | 7.40k | Status error; |
27 | 7.40k | if (IsJoinable()) { |
28 | 7.39k | int err = ::pthread_join(m_thread, result); |
29 | 7.39k | error.SetError(err, lldb::eErrorTypePOSIX); |
30 | 7.39k | } else { |
31 | 13 | if (result) |
32 | 0 | *result = nullptr; |
33 | 13 | error.SetError(EINVAL, eErrorTypePOSIX); |
34 | 13 | } |
35 | | |
36 | 7.40k | Reset(); |
37 | 7.40k | return error; |
38 | 7.40k | } |
39 | | |
40 | 0 | Status HostThreadPosix::Cancel() { |
41 | 0 | Status error; |
42 | 0 | if (IsJoinable()) { |
43 | 0 | #ifndef __FreeBSD__ |
44 | 0 | llvm_unreachable("someone is calling HostThread::Cancel()"); |
45 | | #else |
46 | | int err = ::pthread_cancel(m_thread); |
47 | | error.SetError(err, eErrorTypePOSIX); |
48 | | #endif |
49 | 0 | } |
50 | 0 | return error; |
51 | 0 | } |
52 | | |
53 | 0 | Status HostThreadPosix::Detach() { |
54 | 0 | Status error; |
55 | 0 | if (IsJoinable()) { |
56 | 0 | int err = ::pthread_detach(m_thread); |
57 | 0 | error.SetError(err, eErrorTypePOSIX); |
58 | 0 | } |
59 | 0 | Reset(); |
60 | 0 | return error; |
61 | 0 | } |