parent
ce7c925924
commit
13e44ab035
Notes:
sideshowbarker
2024-07-17 07:16:27 +09:00
Author: https://github.com/ptrcnull 🔰 Commit: https://github.com/SerenityOS/serenity/commit/13e44ab035 Pull-request: https://github.com/SerenityOS/serenity/pull/24287 Issue: https://github.com/SerenityOS/serenity/issues/16681 Reviewed-by: https://github.com/ADKaster ✅
1 changed files with 16 additions and 0 deletions
|
@ -14,6 +14,7 @@
|
|||
# include <serenity.h>
|
||||
#elif defined(AK_OS_LINUX) || defined(AK_LIBC_GLIBC) || defined(AK_OS_MACOS) || defined(AK_OS_IOS) || defined(AK_OS_NETBSD) || defined(AK_OS_SOLARIS) || defined(AK_OS_HAIKU)
|
||||
# include <pthread.h>
|
||||
# include <sys/resource.h>
|
||||
#elif defined(AK_OS_FREEBSD) || defined(AK_OS_OPENBSD)
|
||||
# include <pthread.h>
|
||||
# include <pthread_np.h>
|
||||
|
@ -95,6 +96,21 @@ StackInfo::StackInfo()
|
|||
#endif
|
||||
|
||||
m_top = m_base + m_size;
|
||||
|
||||
#if defined(AK_OS_LINUX) && !defined(AK_OS_ANDROID) && !defined(AK_LIBC_GLIBC)
|
||||
// Note: musl libc always gives the initial size of the main thread's stack
|
||||
if (getpid() == static_cast<pid_t>(gettid())) {
|
||||
rlimit limit;
|
||||
getrlimit(RLIMIT_STACK, &limit);
|
||||
rlim_t size = limit.rlim_cur;
|
||||
if (size == RLIM_INFINITY)
|
||||
size = 8 * 0x10000;
|
||||
// account for a guard page
|
||||
size -= static_cast<rlim_t>(sysconf(_SC_PAGESIZE));
|
||||
m_size = static_cast<size_t>(size);
|
||||
m_base = m_top - m_size;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue