diff options
Diffstat (limited to 'libs/libc/inc/stack.h')
-rw-r--r-- | libs/libc/inc/stack.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/libs/libc/inc/stack.h b/libs/libc/inc/stack.h new file mode 100644 index 0000000..f5ad52b --- /dev/null +++ b/libs/libc/inc/stack.h @@ -0,0 +1,28 @@ +// MIT License, Copyright (c) 2020 Marvin Borner + +#ifndef STACK_H +#define STACK_H + +#include <def.h> + +struct stack_node { + void *data; + int nonce; + struct stack_node *next; + struct stack_node *prev; +}; + +struct stack { + struct stack_node *tail; +}; + +struct stack *stack_new(void); +void stack_destroy(struct stack *stack); +u32 stack_empty(struct stack *stack); +u32 stack_push_bot(struct stack *stack, void *data); +u32 stack_push(struct stack *stack, void *data); +void *stack_pop(struct stack *stack); +void *stack_peek(struct stack *stack); +void stack_clear(struct stack *stack); + +#endif |