]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
support: Add support_small_thread_stack_size
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 29 Dec 2020 14:52:41 +0000 (11:52 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 5 Jan 2021 14:33:16 +0000 (11:33 -0300)
It returns the minimum stack size large enough to cover most internal
glibc stack usage.

support/support_set_small_thread_stack_size.c
support/xthread.h

index 3b0426e28e36fa4710283eb40ccbba92d516db0e..faa2e2f857da02c80799c5c3f54dd232cc3d3eed 100644 (file)
@@ -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 ());
 }
index d57cef6db17686ccd8dcc5adef48b71b29fddc8f..c2086db3475e120e686a607afaae15e47f0671fb 100644 (file)
@@ -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);