Implemented stackLimit() for Mac OS X

master
Marius Kintel 2014-11-24 18:29:13 -05:00
parent d8010a0659
commit 15835271c2
1 changed files with 13 additions and 1 deletions

View File

@ -20,7 +20,19 @@ std::string PlatformUtils::userConfigPath()
unsigned long PlatformUtils::stackLimit()
{
return STACK_LIMIT_DEFAULT;
struct rlimit limit;
int ret = getrlimit(RLIMIT_STACK, &limit);
if (ret == 0) {
if (limit.rlim_cur > STACK_BUFFER_SIZE) {
return limit.rlim_cur - STACK_BUFFER_SIZE;
}
if (limit.rlim_max > STACK_BUFFER_SIZE) {
return limit.rlim_max - STACK_BUFFER_SIZE;
}
}
return STACK_LIMIT_DEFAULT;
}
void PlatformUtils::ensureStdIO(void) {}