Lines Matching refs:stack

20 static SLIST_HEAD(, stack) def_stacks = SLIST_HEAD_INITIALIZER(head);
23 struct stack *
26 struct stack *stack; in _rthread_alloc_stack() local
38 stack = SLIST_FIRST(&def_stacks); in _rthread_alloc_stack()
39 if (stack != NULL) { in _rthread_alloc_stack()
42 return (stack); in _rthread_alloc_stack()
48 stack = malloc(sizeof(*stack)); in _rthread_alloc_stack()
49 if (stack == NULL) in _rthread_alloc_stack()
63 stack->base = base = thread->attr.stack_addr; in _rthread_alloc_stack()
64 stack->len = thread->attr.stack_size; in _rthread_alloc_stack()
66 stack->sp = base + rnd; in _rthread_alloc_stack()
68 stack->sp = base + thread->attr.stack_size - (_STACKALIGNBYTES+1) - rnd; in _rthread_alloc_stack()
75 stack->guardsize = 1; in _rthread_alloc_stack()
76 return (stack); in _rthread_alloc_stack()
87 free(stack); in _rthread_alloc_stack()
97 free(stack); in _rthread_alloc_stack()
103 stack->sp = base + rnd; in _rthread_alloc_stack()
106 stack->sp = base + size - (_STACKALIGNBYTES+1) - rnd; in _rthread_alloc_stack()
112 free(stack); in _rthread_alloc_stack()
116 stack->base = base; in _rthread_alloc_stack()
117 stack->guardsize = guardsize; in _rthread_alloc_stack()
118 stack->len = size; in _rthread_alloc_stack()
119 return (stack); in _rthread_alloc_stack()
123 _rthread_free_stack(struct stack *stack) in _rthread_free_stack() argument
125 if (stack->len == RTHREAD_STACK_SIZE_DEF + stack->guardsize && in _rthread_free_stack()
126 stack->guardsize == _thread_pagesize) { in _rthread_free_stack()
128 SLIST_INSERT_HEAD(&def_stacks, stack, link); in _rthread_free_stack()
132 if (stack->guardsize != 1) in _rthread_free_stack()
133 munmap(stack->base, stack->len); in _rthread_free_stack()
134 free(stack); in _rthread_free_stack()