Lines Matching +full:data +full:- +full:timeout

2  * Copyright (c) 2010-2016 Wind River Systems, Inc.
4 * SPDX-License-Identifier: Apache-2.0
8 * @brief fixed-size stack object
30 z_waitq_init(&stack->wait_q); in k_stack_init()
31 stack->lock = (struct k_spinlock) {}; in k_stack_init()
32 stack->next = buffer; in k_stack_init()
33 stack->base = buffer; in k_stack_init()
34 stack->top = stack->base + num_entries; in k_stack_init()
54 stack->flags = K_STACK_FLAG_ALLOC; in z_impl_k_stack_alloc_init()
57 ret = -ENOMEM; in z_impl_k_stack_alloc_init()
84 CHECKIF(z_waitq_head(&stack->wait_q) != NULL) { in k_stack_cleanup()
85 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_stack, cleanup, stack, -EAGAIN); in k_stack_cleanup()
87 return -EAGAIN; in k_stack_cleanup()
90 if ((stack->flags & K_STACK_FLAG_ALLOC) != (uint8_t)0) { in k_stack_cleanup()
91 k_free(stack->base); in k_stack_cleanup()
92 stack->base = NULL; in k_stack_cleanup()
93 stack->flags &= ~K_STACK_FLAG_ALLOC; in k_stack_cleanup()
101 int z_impl_k_stack_push(struct k_stack *stack, stack_data_t data) in z_impl_k_stack_push() argument
105 k_spinlock_key_t key = k_spin_lock(&stack->lock); in z_impl_k_stack_push()
109 CHECKIF(stack->next == stack->top) { in z_impl_k_stack_push()
110 ret = -ENOMEM; in z_impl_k_stack_push()
114 first_pending_thread = z_unpend_first_thread(&stack->wait_q); in z_impl_k_stack_push()
118 0, (void *)data); in z_impl_k_stack_push()
121 z_reschedule(&stack->lock, key); in z_impl_k_stack_push()
124 *(stack->next) = data; in z_impl_k_stack_push()
125 stack->next++; in z_impl_k_stack_push()
130 k_spin_unlock(&stack->lock, key); in z_impl_k_stack_push()
139 static inline int z_vrfy_k_stack_push(struct k_stack *stack, stack_data_t data) in z_vrfy_k_stack_push() argument
143 return z_impl_k_stack_push(stack, data); in z_vrfy_k_stack_push()
148 int z_impl_k_stack_pop(struct k_stack *stack, stack_data_t *data, in z_impl_k_stack_pop() argument
149 k_timeout_t timeout) in z_impl_k_stack_pop() argument
154 key = k_spin_lock(&stack->lock); in z_impl_k_stack_pop()
156 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_stack, pop, stack, timeout); in z_impl_k_stack_pop()
158 if (likely(stack->next > stack->base)) { in z_impl_k_stack_pop()
159 stack->next--; in z_impl_k_stack_pop()
160 *data = *(stack->next); in z_impl_k_stack_pop()
161 k_spin_unlock(&stack->lock, key); in z_impl_k_stack_pop()
163 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_stack, pop, stack, timeout, 0); in z_impl_k_stack_pop()
168 SYS_PORT_TRACING_OBJ_FUNC_BLOCKING(k_stack, pop, stack, timeout); in z_impl_k_stack_pop()
170 if (K_TIMEOUT_EQ(timeout, K_NO_WAIT)) { in z_impl_k_stack_pop()
171 k_spin_unlock(&stack->lock, key); in z_impl_k_stack_pop()
173 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_stack, pop, stack, timeout, -EBUSY); in z_impl_k_stack_pop()
175 return -EBUSY; in z_impl_k_stack_pop()
178 result = z_pend_curr(&stack->lock, key, &stack->wait_q, timeout); in z_impl_k_stack_pop()
179 if (result == -EAGAIN) { in z_impl_k_stack_pop()
180 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_stack, pop, stack, timeout, -EAGAIN); in z_impl_k_stack_pop()
182 return -EAGAIN; in z_impl_k_stack_pop()
185 *data = (stack_data_t)arch_current_thread()->base.swap_data; in z_impl_k_stack_pop()
187 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_stack, pop, stack, timeout, 0); in z_impl_k_stack_pop()
194 stack_data_t *data, k_timeout_t timeout) in z_vrfy_k_stack_pop() argument
197 K_OOPS(K_SYSCALL_MEMORY_WRITE(data, sizeof(stack_data_t))); in z_vrfy_k_stack_pop()
198 return z_impl_k_stack_pop(stack, data, timeout); in z_vrfy_k_stack_pop()