Voxia OS v0.0.1
Hobby Project Operating System Targeting x86-64
Loading...
Searching...
No Matches
llist.h
Go to the documentation of this file.
1#ifndef __LLIST_H__
2#define __LLIST_H__
3
4#include <type.h>
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10struct llist_head {
13};
14
15#define LLIST_INIT(n) = {&(n), &(n)}
16#define LIST_HEAD(n) struct llist_head n = LLIST_INIT(n)
17
18static inline void llist_init(struct llist_head* head) {
19 head->next = head;
20 head->prev = head;
21}
22
23static inline void llist_add(struct llist_head* new_, struct llist_head* next,
24 struct llist_head* prev) {
25 new_->next = next;
26 new_->prev = prev;
27 next->prev = new_;
28 prev->next = new_;
29}
30
31static inline void
32llist_add_tail(struct llist_head* new_, struct llist_head* head) {
33 llist_add(new_, head, head->prev);
34}
35
36static inline void
38 next->prev = prev;
39 prev->next = next;
40}
41
42static inline void llist_del(struct llist_head* entry) {
43 llist_del_init(entry->prev, entry->next);
44 entry->next = NULL;
45 entry->prev = NULL;
46}
47
48#define list_entry(ptr, type, member) container_of(ptr, type, member)
49
50#define list_for_each_entry(pos, head, member) \
51 for (pos = list_entry((head)->next, typeof(*pos), member); \
52 &pos->member != (head); \
53 pos = list_entry(pos->member.next, typeof(*pos), member))
54
55#ifdef __cplusplus
56}
57#endif
58
59#endif // __LLIST_H__
struct cdev * next
Definition dev.h:4
static void llist_add_tail(struct llist_head *new_, struct llist_head *head)
Definition llist.h:32
static void llist_init(struct llist_head *head)
Definition llist.h:18
static void llist_del_init(struct llist_head *prev, struct llist_head *next)
Definition llist.h:37
static void llist_del(struct llist_head *entry)
Definition llist.h:42
static void llist_add(struct llist_head *new_, struct llist_head *next, struct llist_head *prev)
Definition llist.h:23
struct process * prev
Definition process.h:19
struct llist_head * prev
Definition llist.h:12
struct llist_head * next
Definition llist.h:11
uint32_t head
Definition tty.h:10
#define NULL
Definition type.h:76