blob: e5d3e9bca3038d7c6fdfe1df733e2a6d213d3461 (
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
|
--- base/allocator/partition_allocator/starscan/stack/stack.cc.orig 2023-09-17 07:59:53 UTC
+++ base/allocator/partition_allocator/starscan/stack/stack.cc
@@ -18,6 +18,10 @@
#include <pthread.h>
#endif
+#if BUILDFLAG(IS_BSD)
+#include <pthread_np.h>
+#endif
+
#if defined(LIBC_GLIBC)
extern "C" void* __libc_stack_end;
#endif
@@ -48,6 +52,36 @@ void* GetStackTop() {
void* GetStackTop() {
return pthread_get_stackaddr_np(pthread_self());
+}
+
+#elif defined(OS_OPENBSD)
+
+void* GetStackTop() {
+ stack_t ss;
+ if (pthread_stackseg_np(pthread_self(), &ss) != 0)
+ return nullptr;
+ return reinterpret_cast<uint8_t*>(ss.ss_sp);
+}
+
+#elif defined(OS_FREEBSD)
+
+void* GetStackTop() {
+ pthread_attr_t attr;
+ int error = pthread_attr_init(&attr);
+ if (error) {
+ return nullptr;
+ }
+ error = pthread_attr_get_np(pthread_self(), &attr);
+ if (!error) {
+ void* base;
+ size_t size;
+ error = pthread_attr_getstack(&attr, &base, &size);
+ PA_CHECK(!error);
+ pthread_attr_destroy(&attr);
+ return reinterpret_cast<uint8_t*>(base) + size;
+ }
+ pthread_attr_destroy(&attr);
+ return nullptr;
}
#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
|