aboutsummaryrefslogtreecommitdiff
path: root/devel/electron13/files/patch-third__party_perfetto_include_perfetto_ext_base_thread__utils.h
blob: dce6f5bb41aacf54472281c8ba0088cc15f6c2eb (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
--- third_party/perfetto/include/perfetto/ext/base/thread_utils.h.orig	2021-07-15 19:15:50 UTC
+++ third_party/perfetto/include/perfetto/ext/base/thread_utils.h
@@ -23,7 +23,8 @@
 
 #if PERFETTO_BUILDFLAG(PERFETTO_OS_LINUX) ||   \
     PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID) || \
-    PERFETTO_BUILDFLAG(PERFETTO_OS_APPLE)
+    PERFETTO_BUILDFLAG(PERFETTO_OS_APPLE) ||   \
+    PERFETTO_BUILDFLAG(PERFETTO_OS_FREEBSD)
 #include <pthread.h>
 #include <string.h>
 #include <algorithm>
@@ -41,7 +42,8 @@ namespace base {
 
 #if PERFETTO_BUILDFLAG(PERFETTO_OS_LINUX) ||   \
     PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID) || \
-    PERFETTO_BUILDFLAG(PERFETTO_OS_APPLE)
+    PERFETTO_BUILDFLAG(PERFETTO_OS_APPLE) ||   \
+    PERFETTO_BUILDFLAG(PERFETTO_OS_FREEBSD)
 // Sets the "comm" of the calling thread to the first 15 chars of the given
 // string.
 inline bool MaybeSetThreadName(const std::string& name) {
@@ -51,6 +53,9 @@ inline bool MaybeSetThreadName(const std::string& name
 
 #if PERFETTO_BUILDFLAG(PERFETTO_OS_APPLE)
   return pthread_setname_np(buf) == 0;
+#elif PERFETTO_BUILDFLAG(PERFETTO_OS_FREEBSD)
+  pthread_set_name_np(pthread_self(), buf);
+  return true;
 #else
   return pthread_setname_np(pthread_self(), buf) == 0;
 #endif
@@ -61,6 +66,8 @@ inline bool GetThreadName(std::string& out_result) {
 #if PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID)
   if (prctl(PR_GET_NAME, buf) != 0)
     return false;
+#elif PERFETTO_BUILDFLAG(PERFETTO_OS_FREEBSD)
+  pthread_get_name_np(pthread_self(), buf, sizeof(buf));
 #else
   if (pthread_getname_np(pthread_self(), buf, sizeof(buf)) != 0)
     return false;