Skip to content

Commit 942490d

Browse files
authored
Merge pull request #62110 from mhjacobson/freebsd-fix-stack-bounds-accessor
Threading: fix the FreeBSD build
2 parents cbd9e6c + e8661a2 commit 942490d

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

lib/Threading/Pthreads.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,26 @@ swift::threading_impl::thread_get_current_stack_bounds() {
101101
#if defined(__FreeBSD__)
102102
if (pthread_attr_init(&attr))
103103
return {};
104-
#endif
105104

106-
if (!pthread_getattr_np(pthread_self(), &attr)) {
107-
if (!pthread_attr_getstack(&attr, &begin, &size)) {
108-
stack_bounds result = { begin, (char *)begin + size };
109-
pthread_attr_destroy(&attr);
110-
return result;
111-
}
105+
if (pthread_attr_get_np(pthread_self(), &attr)) {
106+
pthread_attr_destroy(&attr);
107+
return {};
108+
}
109+
#elif defined(__linux__)
110+
if (pthread_getattr_np(pthread_self(), &attr))
111+
return {};
112+
#else
113+
// We don't know how to get the thread attr for this platform.
114+
return {};
115+
#endif
112116

117+
if (!pthread_attr_getstack(&attr, &begin, &size)) {
118+
stack_bounds result = { begin, (char *)begin + size };
113119
pthread_attr_destroy(&attr);
120+
return result;
114121
}
115122

123+
pthread_attr_destroy(&attr);
116124
return {};
117125
}
118126
#endif

0 commit comments

Comments
 (0)