diff --git a/druntime/src/core/thread/osthread.d b/druntime/src/core/thread/osthread.d index 5074ccdb7417..827b19b61df9 100644 --- a/druntime/src/core/thread/osthread.d +++ b/druntime/src/core/thread/osthread.d @@ -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; @@ -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; -} diff --git a/druntime/src/core/thread/posix_impl.d b/druntime/src/core/thread/posix_impl.d index d1fb6e6b46ad..821ac51e35ba 100644 --- a/druntime/src/core/thread/posix_impl.d +++ b/druntime/src/core/thread/posix_impl.d @@ -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 {