From 856b362a4b68d5776ea37dc30a50e7414288d877 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 10 Jan 2021 16:52:06 +0100 Subject: Added very simple stack implementation for procfs This probably has several bugs, but idc --- libc/inc/stack.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 libc/inc/stack.h (limited to 'libc/inc') diff --git a/libc/inc/stack.h b/libc/inc/stack.h new file mode 100644 index 0000000..8fec25f --- /dev/null +++ b/libc/inc/stack.h @@ -0,0 +1,27 @@ +// MIT License, Copyright (c) 2020 Marvin Borner + +#ifndef STACK_H +#define STACK_H + +#include + +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 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); + +#endif -- cgit v1.2.3