blob: 73d12e31ceb62340e807e606e912ed10ed84d756 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
--- base/threading/platform_thread_posix.cc.orig 2021-04-14 18:40:48 UTC
+++ base/threading/platform_thread_posix.cc
@@ -32,6 +32,10 @@
#include <sys/syscall.h>
#endif
+#if defined(OS_BSD)
+#include <pthread_np.h>
+#endif
+
#if defined(OS_FUCHSIA)
#include <zircon/process.h>
#else
@@ -141,7 +145,7 @@ bool CreateThread(size_t stack_size,
return success;
}
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_BSD)
// Store the thread ids in local storage since calling the SWI can be
// expensive and PlatformThread::CurrentId is used liberally. Clear
@@ -159,11 +163,11 @@ class InitAtFork {
InitAtFork() { pthread_atfork(nullptr, nullptr, internal::ClearTidCache); }
};
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_BSD)
} // namespace
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_BSD)
namespace internal {
@@ -173,7 +177,7 @@ void ClearTidCache() {
} // namespace internal
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_BSD)
// static
PlatformThreadId PlatformThread::CurrentId() {
@@ -181,6 +185,8 @@ PlatformThreadId PlatformThread::CurrentId() {
// into the kernel.
#if defined(OS_APPLE)
return pthread_mach_thread_np(pthread_self());
+#elif defined(OS_BSD)
+ return pthread_getthreadid_np();
#elif defined(OS_LINUX) || defined(OS_CHROMEOS)
static NoDestructor<InitAtFork> init_at_fork;
if (g_thread_id == -1) {
|