Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions druntime/src/core/thread/osthread.d
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module core.thread.osthread;

import core.atomic;
import core.internal.traits : externDFunc;
import core.memory : GC, pageSize;
import core.memory : GC;
import core.thread.context;
import core.thread.threadbase;
import core.thread.types;
Expand Down Expand Up @@ -2220,26 +2220,3 @@ nothrow @nogc unittest

assert(task.n == tids.length);
}

version (Posix)
package size_t adjustStackSize(size_t sz) nothrow @nogc
{
if (sz == 0)
return 0;

// stack size must be at least PTHREAD_STACK_MIN for most platforms.
if (PTHREAD_STACK_MIN > sz)
sz = PTHREAD_STACK_MIN;

version (CRuntime_Glibc)
{
// On glibc, TLS uses the top of the stack, so add its size to the requested size
sz += externDFunc!("rt.sections_elf_shared.sizeOfTLS",
size_t function() @nogc nothrow)();
}

// stack size must be a multiple of pageSize
sz = ((sz + pageSize - 1) & ~(pageSize - 1));

return sz;
}
25 changes: 25 additions & 0 deletions druntime/src/core/thread/posix_impl.d
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,31 @@ package bool launchLLThread(LLThreadProperties* tprop, ref LLThreadContext conte
return true;
}

private size_t adjustStackSize(size_t sz) nothrow @nogc
{
import core.memory: pageSize;
import core.thread.types: PTHREAD_STACK_MIN;

if (sz == 0)
return 0;

// stack size must be at least PTHREAD_STACK_MIN for most platforms.
if (PTHREAD_STACK_MIN > sz)
sz = PTHREAD_STACK_MIN;

version (CRuntime_Glibc)
{
// On glibc, TLS uses the top of the stack, so add its size to the requested size
sz += externDFunc!("rt.sections_elf_shared.sizeOfTLS",
size_t function() @nogc nothrow)();
}

// stack size must be a multiple of pageSize
sz = ((sz + pageSize - 1) & ~(pageSize - 1));

return sz;
}

version (CoreDdoc) {} else
void joinLowLevelThread(ThreadID tid) nothrow @nogc
{
Expand Down
Loading