1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2021 Broadcom
13 /** Stack data structure
16 int max; /**< Maximum number of entries */
17 int top; /**< maximum value in stack */
18 uint32_t *items; /**< items in the stack */
21 /** Initialize stack of uint32_t elements
24 * maximum number of elements in the stack
27 * pointer to items (must be sized to (uint32_t * num_entries)
30 * pointer to the stack structure
35 int stack_init(int num_entries,
39 /** Return the address of the stack contents
42 * pointer to the stack
45 * pointer to the stack contents
47 uint32_t *stack_items(struct stack *st);
49 /** Return the size of the stack
52 * pointer to the stack
57 int32_t stack_size(struct stack *st);
59 /** Check if the stack is empty
62 * pointer to the stack
67 bool stack_is_empty(struct stack *st);
69 /** Check if the stack is full
72 * pointer to the stack
77 bool stack_is_full(struct stack *st);
79 /** Add element x to the stack
82 * pointer to the stack
85 * value to push on the stack
89 int stack_push(struct stack *st, uint32_t x);
91 /** Pop top element x from the stack and return
92 * in user provided location.
95 * pointer to the stack
98 * pointer to where the value popped will be written
103 int stack_pop(struct stack *st, uint32_t *x);
105 /** Dump stack information
107 * Warning: Don't use for large stacks due to prints
110 * pointer to the stack
115 void stack_dump(struct stack *st);
117 #endif /* _STACK_H_ */