[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 5/6] support: Add support_small_thread_stack_size
From: |
Adhemerval Zanella |
Subject: |
[PATCH v3 5/6] support: Add support_small_thread_stack_size |
Date: |
Tue, 29 Dec 2020 16:34:53 -0300 |
It returns the minimum stack size large enough to cover most internal
glibc stack usage.
---
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 69d66e97db..74a0e38a72 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 05f8d4a7d9..9aeee80032 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);
--
2.25.1
- [PATCH v3 0/6] Multiple fixes to realpath, Adhemerval Zanella, 2020/12/29
- [PATCH v3 1/6] Import idx.h from gnulib, Adhemerval Zanella, 2020/12/29
- [PATCH v3 2/6] Import filename.h from gnulib, Adhemerval Zanella, 2020/12/29
- [PATCH v3 3/6] malloc: Add scratch_buffer_dupfree, Adhemerval Zanella, 2020/12/29
- [PATCH v3 5/6] support: Add support_small_thread_stack_size,
Adhemerval Zanella <=
- [PATCH v3 6/6] stdlib: Add testcase fro BZ #26241, Adhemerval Zanella, 2020/12/29
- [PATCH v3 4/6] stdlib: Sync canonicalize with gnulib [BZ #10635] [BZ #26592] [BZ #26341] [BZ #24970], Adhemerval Zanella, 2020/12/29