FreeBSD/lib/libthr/thread/thr_stack.c
/* This function must be called with _thread_list_lock held. */
This function must be called with _thread_list_lock held.
This function must be called with _thread_list_lock held .
void
_thr_stack_free(struct pthread_attr *attr)
{
	struct stack *spare_stack;
	if ((attr != NULL) && ((attr->flags & THR_STACK_USER) == 0)
	    && (attr->stackaddr_attr != NULL)) {
		spare_stack = (struct stack *)
			((char *)attr->stackaddr_attr +
			attr->stacksize_attr - sizeof(struct stack));
		spare_stack->stacksize = round_up(attr->stacksize_attr);
		spare_stack->guardsize = round_up(attr->guardsize_attr);
		spare_stack->stackaddr = attr->stackaddr_attr;
		if (spare_stack->stacksize == THR_STACK_DEFAULT &&
		    spare_stack->guardsize == _thr_guard_default) {
			LIST_INSERT_HEAD(&dstackq, spare_stack, qe);
		} else {
			LIST_INSERT_HEAD(&mstackq, spare_stack, qe);
		}
		attr->stackaddr_attr = NULL;
	}
}
void _thr_stack_free ( struct pthread_attr * attr ) { struct stack * spare_stack ; if ( ( attr != NULL ) && ( ( attr -> flags & THR_STACK_USER ) == 0 ) && ( attr -> stackaddr_attr != NULL ) ) { spare_stack = ( struct stack * ) ( ( char * ) attr -> stackaddr_attr + attr -> stacksize_attr - sizeof ( struct stack ) ) ; spare_stack -> stacksize = round_up ( attr -> stacksize_attr ) ; spare_stack -> guardsize = round_up ( attr -> guardsize_attr ) ; spare_stack -> stackaddr = attr -> stackaddr_attr ; if ( spare_stack -> stacksize == THR_STACK_DEFAULT && spare_stack -> guardsize == _thr_guard_default ) { LIST_INSERT_HEAD ( & dstackq , spare_stack , qe ) ; } else { LIST_INSERT_HEAD ( & mstackq , spare_stack , qe ) ; } attr -> stackaddr_attr = NULL ; } }
This function must be called with _thread_list_lock held.
This function must be called with _thread_list_lock held .
/* Default stack/guard size. */ /* Non-default stack/guard size. */