mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Threading] Move stack bounds fetching into the threading library.
Fetching the current stack bounds is done using threading functions, so should be in the threading library. rdar://90776105
This commit is contained in:
@@ -57,4 +57,23 @@ void swift::threading_impl::once_slow(once_t &predicate, void (*fn)(void *),
|
||||
linux::ulock_unlock(&predicate.lock);
|
||||
}
|
||||
|
||||
swift::threading_impl::stack_bounds
|
||||
swift::threading_impl::thread_get_current_stack_bounds() {
|
||||
stack_bounds result = { nullptr, nullptr };
|
||||
pthread_attr_t attr;
|
||||
size_t size = 0;
|
||||
void *begin = nullptr;
|
||||
|
||||
if (!pthread_getattr_np(pthread_self(), &attr)) {
|
||||
if (!pthread_attr_getstack(&attr, &begin, &size)) {
|
||||
result.low = begin;
|
||||
result.high = (char *)begin + size;
|
||||
}
|
||||
|
||||
pthread_attr_destroy(&attr);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // SWIFT_THREADING_LINUX
|
||||
|
||||
Reference in New Issue
Block a user