Commit 1466e004 authored by Siddhartha's avatar Siddhartha Committed by Commit Bot

Expose default thread stack size set by chrome

This will be useful for stack sampling profiler to set buffer size
for copying stack.

BUG=859260

Change-Id: Ib87e44e82ff8d309e5ec2f7750fda9168b6906d0
Reviewed-on: https://chromium-review.googlesource.com/c/1297241Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: ssid <ssid@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603313}
parent 4b4e0eca
......@@ -231,6 +231,10 @@ class BASE_EXPORT PlatformThread {
ThreadPriority priority);
#endif
// Returns the default thread stack size set by chrome. If we do not
// explicitly set default size then returns 0.
static size_t GetDefaultThreadStackSize();
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread);
};
......
......@@ -342,4 +342,11 @@ ThreadPriority PlatformThread::GetCurrentThreadPriority() {
#endif // !defined(OS_MACOSX) && !defined(OS_FUCHSIA)
// static
size_t PlatformThread::GetDefaultThreadStackSize() {
pthread_attr_t attributes;
pthread_attr_init(&attributes);
return base::GetDefaultThreadStackSize(attributes);
}
} // namespace base
......@@ -395,4 +395,16 @@ TEST(PlatformThreadTest, SetHugeThreadName) {
PlatformThread::SetName(long_name);
}
TEST(PlatformThreadTest, GetDefaultThreadStackSize) {
size_t stack_size = PlatformThread::GetDefaultThreadStackSize();
#if defined(OS_WIN) || defined(OS_IOS) || defined(OS_FUCHSIA) || \
(defined(OS_LINUX) && !defined(THREAD_SANITIZER)) || \
(defined(OS_ANDROID) && !defined(ADDRESS_SANITIZER))
EXPECT_EQ(0u, stack_size);
#else
EXPECT_GT(stack_size, 0u);
EXPECT_LT(stack_size, 20u * (1 << 20));
#endif
}
} // namespace base
......@@ -359,4 +359,9 @@ ThreadPriority PlatformThread::GetCurrentThreadPriority() {
return ThreadPriority::NORMAL;
}
// static
size_t PlatformThread::GetDefaultThreadStackSize() {
return 0;
}
} // namespace base
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment