summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/thread/thr_fork.c
diff options
context:
space:
mode:
authorjasone <jasone@FreeBSD.org>2001-07-20 04:23:11 +0000
committerjasone <jasone@FreeBSD.org>2001-07-20 04:23:11 +0000
commita9a7a5e9d63f8a71f1d3dfe0e1ed1a28ab589215 (patch)
tree656e85a738aa3a12d8926a342cea87c2eae35e1d /lib/libpthread/thread/thr_fork.c
parentf7019990adf13ef4a3ccbd680c5c5ba8292d5f7f (diff)
downloadFreeBSD-src-a9a7a5e9d63f8a71f1d3dfe0e1ed1a28ab589215.zip
FreeBSD-src-a9a7a5e9d63f8a71f1d3dfe0e1ed1a28ab589215.tar.gz
Implement pthread_attr_[gs]etguardsize(). Non-default-size stacks used to
be malloc()ed, but they are now allocated using mmap(), just as the default-size stacks are. A separate cache of stacks is kept for non-default-size stacks. Collaboration with: deischen
Diffstat (limited to 'lib/libpthread/thread/thr_fork.c')
-rw-r--r--lib/libpthread/thread/thr_fork.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/lib/libpthread/thread/thr_fork.c b/lib/libpthread/thread/thr_fork.c
index 4437d88..9d9a647 100644
--- a/lib/libpthread/thread/thr_fork.c
+++ b/lib/libpthread/thread/thr_fork.c
@@ -31,6 +31,7 @@
*
* $FreeBSD$
*/
+#include <sys/param.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
@@ -220,28 +221,16 @@ _fork(void)
static void
free_thread_resources(struct pthread *thread)
{
- struct stack *spare_stack;
/* Check to see if the threads library allocated the stack. */
if ((thread->attr.stackaddr_attr == NULL) && (thread->stack != NULL)) {
- if (thread->attr.stacksize_attr != PTHREAD_STACK_DEFAULT) {
- /*
- * The threads library malloc()'d the stack;
- * just free() it.
- */
- free(thread->stack);
- } else {
- /*
- * This stack was allocated from the main threads
- * stack; cache it for future use. Since this is
- * being called from fork, we are currently single
- * threaded so there is no need to protect the
- * queue insertion.
- */
- spare_stack = (thread->stack + PTHREAD_STACK_DEFAULT -
- sizeof(struct stack));
- SLIST_INSERT_HEAD(&_stackq, spare_stack, qe);
- }
+ /*
+ * Since this is being called from fork, we are currently single
+ * threaded so there is no need to protect the call to
+ * _thread_stack_free() with _gc_mutex.
+ */
+ _thread_stack_free(thread->stack, thread->attr.stacksize_attr,
+ thread->attr.guardsize_attr);
}
if (thread->specific_data != NULL)
OpenPOWER on IntegriCloud