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