1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 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 size of the stack
42 * pointer to the stack
47 int32_t stack_size(struct stack *st);
49 /** Check if the stack is empty
52 * pointer to the stack
57 bool stack_is_empty(struct stack *st);
59 /** Check if the stack is full
62 * pointer to the stack
67 bool stack_is_full(struct stack *st);
69 /** Add element x to the stack
72 * pointer to the stack
75 * value to push on the stack
79 int stack_push(struct stack *st, uint32_t x);
81 /** Pop top element x from the stack and return
82 * in user provided location.
85 * pointer to the stack
88 * pointer to where the value popped will be written
93 int stack_pop(struct stack *st, uint32_t *x);
95 /** Dump stack information
97 * Warning: Don't use for large stacks due to prints
100 * pointer to the stack
105 void stack_dump(struct stack *st);
107 #endif /* _STACK_H_ */