Skip to content

Commit 613116f

Browse files
authored
Merge pull request #39995 from 3405691582/BuildfixStackBounds
[stdlib] Buildfix getting stack bounds on OpenBSD.
2 parents afe116b + b5135fa commit 613116f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

stdlib/public/stubs/Stubs.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,10 +532,19 @@ __swift_bool _swift_stdlib_getCurrentStackBounds(__swift_uintptr_t *outBegin,
532532
*outEnd = highLimit;
533533
return true;
534534

535-
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__ANDROID__) || defined(__linux__)
535+
#elif defined(__OpenBSD__)
536+
stack_t sinfo;
537+
if (pthread_stackseg_np(pthread_self(), &sinfo) != 0) {
538+
return false;
539+
}
540+
541+
*outBegin = (uintptr_t)sinfo.ss_sp - sinfo.ss_size;
542+
*outEnd = (uintptr_t)sinfo.ss_sp;
543+
return true;
544+
#elif defined(__FreeBSD__) || defined(__ANDROID__) || defined(__linux__)
536545
pthread_attr_t attr;
537546

538-
#if defined(__FreeBSD__) || defined(__OpenBSD__)
547+
#if defined(__FreeBSD__)
539548
if (0 != pthread_attr_init(&attr) || 0 != pthread_attr_get_np(pthread_self(), &attr)) {
540549
return false;
541550
}

0 commit comments

Comments
 (0)