include/libtu/dlist.h

Thu, 17 Jul 2003 19:11:30 +0200

author
tuomov
date
Thu, 17 Jul 2003 19:11:30 +0200
changeset 54
2795b5fb21df
parent 53
f8f9366b359c
child 56
af2c6d224f9d
permissions
-rw-r--r--

trunk: changeset 58
Cleaned up system.mk

11
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
1 /*
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
2 * libtu/common.h
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
3 *
36
63cd573ffbcf trunk: changeset 39
tuomov
parents: 11
diff changeset
4 * Copyright (c) Tuomo Valkonen 1999-2002.
53
f8f9366b359c trunk: changeset 57
tuomov
parents: 43
diff changeset
5 *
f8f9366b359c trunk: changeset 57
tuomov
parents: 43
diff changeset
6 * You may distribute and modify this library under the terms of either
f8f9366b359c trunk: changeset 57
tuomov
parents: 43
diff changeset
7 * the Clarified Artistic License or the GNU LGPL, version 2.1 or later.
11
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
8 */
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
9
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
10 #ifndef LIBTU_DLIST_H
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
11 #define LIBTU_DLIST_H
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
12
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
13 #define LINK_ITEM(LIST, ITEM, NEXT, PREV) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
14 (ITEM)->NEXT=NULL; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
15 if((LIST)==NULL){ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
16 (LIST)=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
17 (ITEM)->PREV=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
18 }else{ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
19 (ITEM)->PREV=(LIST)->PREV; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
20 (ITEM)->PREV->NEXT=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
21 (LIST)->PREV=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
22 }
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
23
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
24
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
25 #define LINK_ITEM_FIRST(LIST, ITEM, NEXT, PREV) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
26 (ITEM)->NEXT=(LIST); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
27 if((LIST)==NULL){ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
28 (ITEM)->PREV=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
29 }else{ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
30 (ITEM)->PREV=(LIST)->PREV; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
31 (LIST)->PREV=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
32 } \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
33 (LIST)=(ITEM);
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
34
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
35
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
36 #define LINK_ITEM_LIST LINK_ITEM
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
37
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
38
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
39 #define LINK_ITEM_BEFORE(LIST, BEFORE, ITEM, NEXT, PREV) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
40 (ITEM)->NEXT=(BEFORE); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
41 (ITEM)->PREV=(BEFORE)->PREV; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
42 (BEFORE)->PREV=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
43 if((BEFORE)==(LIST)) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
44 (LIST)=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
45 else \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
46 (ITEM)->PREV->NEXT=(ITEM)
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
47
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
48
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
49 #define LINK_ITEM_AFTER(LIST, AFTER, ITEM, NEXT, PREV) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
50 (ITEM)->NEXT=(AFTER)->NEXT; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
51 (ITEM)->PREV=(AFTER); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
52 (AFTER)->NEXT=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
53 if((ITEM)->NEXT==NULL) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
54 (LIST)->PREV=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
55 else \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
56 (ITEM)->NEXT->PREV=ITEM;
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
57
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
58
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
59 #define UNLINK_ITEM(LIST, ITEM, NEXT, PREV) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
60 if((ITEM)==(LIST)){ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
61 (LIST)=(ITEM)->NEXT; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
62 if((LIST)!=NULL) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
63 (LIST)->PREV=(ITEM)->PREV; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
64 }else if((ITEM)->NEXT==NULL){ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
65 (ITEM)->PREV->NEXT=NULL; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
66 (LIST)->PREV=(ITEM)->PREV; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
67 }else{ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
68 (ITEM)->PREV->NEXT=(ITEM)->NEXT; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
69 (ITEM)->NEXT->PREV=(ITEM)->PREV; \
43
aad48c3d4966 trunk: changeset 46
tuomov
parents: 36
diff changeset
70 } \
aad48c3d4966 trunk: changeset 46
tuomov
parents: 36
diff changeset
71 (ITEM)->NEXT=NULL; \
aad48c3d4966 trunk: changeset 46
tuomov
parents: 36
diff changeset
72 (ITEM)->PREV=NULL;
11
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
73
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
74 #endif /* LIBTU_DLIST_H */

mercurial