mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-02-16 23:27:17 +02:00
Get max stack size in setStackSize
to match Linux
This commit is contained in:
parent
a41f4223de
commit
5f68e6d69f
1 changed files with 6 additions and 2 deletions
|
@ -82,19 +82,23 @@ void setStackSize(size_t stackSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
ULONG_PTR stackLow, stackHigh;
|
||||||
|
GetCurrentThreadStackLimits(&stackLow, &stackHigh);
|
||||||
|
ULONG maxStackSize = stackHigh - stackLow;
|
||||||
ULONG currStackSize = 0;
|
ULONG currStackSize = 0;
|
||||||
// This retrieves the current promised stack size
|
// This retrieves the current promised stack size
|
||||||
SetThreadStackGuarantee(&currStackSize);
|
SetThreadStackGuarantee(&currStackSize);
|
||||||
if (currStackSize < stackSize) {
|
if (currStackSize < stackSize) {
|
||||||
savedStackSize = currStackSize;
|
savedStackSize = currStackSize;
|
||||||
ULONG newStackSize = stackSize;
|
ULONG newStackSize = std::min(static_cast<ULONG>(stackSize), maxStackSize);
|
||||||
if (SetThreadStackGuarantee(&newStackSize) == 0) {
|
if (SetThreadStackGuarantee(&newStackSize) == 0) {
|
||||||
logger->log(
|
logger->log(
|
||||||
lvlError,
|
lvlError,
|
||||||
HintFmt(
|
HintFmt(
|
||||||
"Failed to increase stack size from %1% to %2%: %3%",
|
"Failed to increase stack size from %1% to %2% (maximum allowed stack size: %3%): %4%",
|
||||||
savedStackSize,
|
savedStackSize,
|
||||||
stackSize,
|
stackSize,
|
||||||
|
maxStackSize,
|
||||||
std::to_string(GetLastError())
|
std::to_string(GetLastError())
|
||||||
).str()
|
).str()
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue