Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 7626e2b

Browse files
committed
core/thread: Support StackGrowsUp in getStackBottom()
1 parent b917007 commit 7626e2b

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

src/core/thread.d

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3256,7 +3256,9 @@ private void* getStackBottom() nothrow @nogc
32563256
pthread_getattr_np(pthread_self(), &attr);
32573257
pthread_attr_getstack(&attr, &addr, &size);
32583258
pthread_attr_destroy(&attr);
3259-
return addr + size;
3259+
version (StackGrowsDown)
3260+
addr += size;
3261+
return addr;
32603262
}
32613263
else version (FreeBSD)
32623264
{
@@ -3267,7 +3269,9 @@ private void* getStackBottom() nothrow @nogc
32673269
pthread_attr_get_np(pthread_self(), &attr);
32683270
pthread_attr_getstack(&attr, &addr, &size);
32693271
pthread_attr_destroy(&attr);
3270-
return addr + size;
3272+
version (StackGrowsDown)
3273+
addr += size;
3274+
return addr;
32713275
}
32723276
else version (NetBSD)
32733277
{
@@ -3278,7 +3282,9 @@ private void* getStackBottom() nothrow @nogc
32783282
pthread_attr_get_np(pthread_self(), &attr);
32793283
pthread_attr_getstack(&attr, &addr, &size);
32803284
pthread_attr_destroy(&attr);
3281-
return addr + size;
3285+
version (StackGrowsDown)
3286+
addr += size;
3287+
return addr;
32823288
}
32833289
else version (DragonFlyBSD)
32843290
{
@@ -3289,7 +3295,9 @@ private void* getStackBottom() nothrow @nogc
32893295
pthread_attr_get_np(pthread_self(), &attr);
32903296
pthread_attr_getstack(&attr, &addr, &size);
32913297
pthread_attr_destroy(&attr);
3292-
return addr + size;
3298+
version (StackGrowsDown)
3299+
addr += size;
3300+
return addr;
32933301
}
32943302
else version (Solaris)
32953303
{
@@ -3306,7 +3314,9 @@ private void* getStackBottom() nothrow @nogc
33063314
pthread_getattr_np(pthread_self(), &attr);
33073315
pthread_attr_getstack(&attr, &addr, &size);
33083316
pthread_attr_destroy(&attr);
3309-
return addr + size;
3317+
version (StackGrowsDown)
3318+
addr += size;
3319+
return addr;
33103320
}
33113321
else version (CRuntime_Musl)
33123322
{
@@ -3316,7 +3326,9 @@ private void* getStackBottom() nothrow @nogc
33163326
pthread_getattr_np(pthread_self(), &attr);
33173327
pthread_attr_getstack(&attr, &addr, &size);
33183328
pthread_attr_destroy(&attr);
3319-
return addr + size;
3329+
version (StackGrowsDown)
3330+
addr += size;
3331+
return addr;
33203332
}
33213333
else version (CRuntime_UClibc)
33223334
{
@@ -3326,7 +3338,9 @@ private void* getStackBottom() nothrow @nogc
33263338
pthread_getattr_np(pthread_self(), &attr);
33273339
pthread_attr_getstack(&attr, &addr, &size);
33283340
pthread_attr_destroy(&attr);
3329-
return addr + size;
3341+
version (StackGrowsDown)
3342+
addr += size;
3343+
return addr;
33303344
}
33313345
else
33323346
static assert(false, "Platform not supported.");

0 commit comments

Comments
 (0)