ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
list.h
Go to the documentation of this file.
1 /*
2 # _____ ___ ____ ___ ____
3 # ____| | ____| | | |____|
4 # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5 #-----------------------------------------------------------------------
6 # Copyright (c) 2003 Marcus R. Brown <mrbrown@0xd6.org>
7 # Licenced under Academic Free License version 2.0
8 # Review ps2sdk README & LICENSE files for further details.
9 */
10 
16 #ifndef __LIST_H__
17 #define __LIST_H__
18 
19 typedef struct _list {
20  struct _list *next;
21  struct _list *prev;
22 } list_t;
23 
24 #define LIST_INIT(name) { &(name), &(name) }
25 
26 static inline int list_empty(void *l)
27 {
28  list_t *list = (list_t *)l;
29 
30  return list->next == list && list->prev == list;
31 }
32 
34 static inline void list_insert(void *l, void *i)
35 {
36  list_t *list = (list_t *)l, *item = (list_t *)i;
37 
38  item->prev = list;
39  item->next = list->next;
40  list->next->prev = item;
41  list->next = item;
42 }
43 
45 static inline list_t *list_remove(void *i)
46 {
47  list_t *item = (list_t *)i;
48 
49  item->prev->next = item->next;
50  item->next->prev = item->prev;
51  return item;
52 }
53 
54 
56 #define list_for_each(dir, pos, head) \
57  for (pos = (head)->dir; pos != (head); pos = pos->dir)
58 
59 #endif /* __LIST_H__ */
static int list_empty(void *l)
Definition: list.h:26
static void list_insert(void *l, void *i)
Definition: list.h:34
static list_t * list_remove(void *i)
Definition: list.h:45
Definition: list.h:19
struct _list * prev
Definition: list.h:21
struct _list * next
Definition: list.h:20