aboutsummaryrefslogtreecommitdiff
path: root/include/lib/ll.h
blob: a9c37221ddfed51ddd96a1c5c57ec03b25b774ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef LIB_LL_H
#define LIB_LL_H

struct LL {
	struct LL* prev;
	struct LL* next;
	void* data;
} __attribute__((packed));

struct LL* new_ll(void* val);
void push_ll(struct LL* l, void* val);
void pop_ll(struct LL* l);
void remove_ll(struct LL* l, unsigned long idx);
unsigned long length_ll(struct LL* l);

#define show_ll(L, TYPE) { \
	struct LL* t = L; \
	do { \
		uart_hex(*(TYPE*)t->data); \
		t = t->next; \
		if (t != l) \
			uart_char(' '); \
	} while (t != l); \
}

#endif