public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/maskray/lld] support: Add support_small_thread_stack_size
@ 2021-01-18 21:39 Fangrui Song
0 siblings, 0 replies; only message in thread
From: Fangrui Song @ 2021-01-18 21:39 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=ecdb06cdf22c7d37699f5420265245ff31c53b3c
commit ecdb06cdf22c7d37699f5420265245ff31c53b3c
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Tue Dec 29 11:52:41 2020 -0300
support: Add support_small_thread_stack_size
It returns the minimum stack size large enough to cover most internal
glibc stack usage.
Diff:
---
support/support_set_small_thread_stack_size.c | 12 +++++++++---
support/xthread.h | 2 ++
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/support/support_set_small_thread_stack_size.c b/support/support_set_small_thread_stack_size.c
index 3b0426e28e..faa2e2f857 100644
--- a/support/support_set_small_thread_stack_size.c
+++ b/support/support_set_small_thread_stack_size.c
@@ -20,8 +20,8 @@
#include <pthread.h>
#include <support/xthread.h>
-void
-support_set_small_thread_stack_size (pthread_attr_t *attr)
+size_t
+support_small_thread_stack_size (void)
{
/* Some architectures have too small values for PTHREAD_STACK_MIN
which cannot be used for creating threads. Ensure that the stack
@@ -31,5 +31,11 @@ support_set_small_thread_stack_size (pthread_attr_t *attr)
if (stack_size < PTHREAD_STACK_MIN)
stack_size = PTHREAD_STACK_MIN;
#endif
- xpthread_attr_setstacksize (attr, stack_size);
+ return stack_size;
+}
+
+void
+support_set_small_thread_stack_size (pthread_attr_t *attr)
+{
+ xpthread_attr_setstacksize (attr, support_small_thread_stack_size ());
}
diff --git a/support/xthread.h b/support/xthread.h
index d57cef6db1..c2086db347 100644
--- a/support/xthread.h
+++ b/support/xthread.h
@@ -75,6 +75,8 @@ void xpthread_attr_setstacksize (pthread_attr_t *attr,
void xpthread_attr_setguardsize (pthread_attr_t *attr,
size_t guardsize);
+/* Return the stack size used on support_set_small_thread_stack_size. */
+size_t support_small_thread_stack_size (void);
/* Set the stack size in ATTR to a small value, but still large enough
to cover most internal glibc stack usage. */
void support_set_small_thread_stack_size (pthread_attr_t *attr);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-01-18 21:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-18 21:39 [glibc/maskray/lld] support: Add support_small_thread_stack_size Fangrui Song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).