1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: 16: 17: 18: 19:
20:
21: #ifndef __SYS_QUEUE_H__
22: #define __SYS_QUEUE_H__
23:
24: #include <basic.h>
25:
26: #ifdef __cplusplus
27: extern "C" {
28: #endif
29:
30: 31: 32:
33: typedef struct queue {
34: struct queue *next;
35: struct queue *prev;
36: } QUEUE;
37:
38: 39: 40:
41: Inline void QueInit( QUEUE *que )
42: {
43: que->next = (struct queue *)que;
44: que->prev = (struct queue *)que;
45: }
46:
47: 48: 49:
50: Inline BOOL isQueEmpty( QUEUE *que )
51: {
52: return ( que->next == que )? TRUE: FALSE;
53: }
54:
55: 56: 57: 58:
59: Inline void QueInsert( QUEUE *entry, QUEUE *que )
60: {
61: entry->prev = (struct queue*) que->prev;
62: entry->next = que;
63: que->prev->next = entry;
64: que->prev = entry;
65: }
66:
67: 68: 69: 70: 71:
72: Inline void QueRemove( QUEUE *entry )
73: {
74: if ( entry->next != entry ) {
75: entry->prev->next = (struct queue*) entry->next;
76: entry->next->prev = (struct queue*) entry->prev;
77: }
78: }
79:
80: 81: 82: 83: 84: 85:
86: Inline QUEUE* QueRemoveNext( QUEUE *que )
87: {
88: QUEUE *entry;
89:
90: if ( que->next == que ) {
91: return NULL;
92: }
93:
94: entry = que->next;
95: que->next = (struct queue*)entry->next;
96: entry->next->prev = que;
97:
98: return entry;
99: }
100:
101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131:
132: IMPORT QUEUE* QueSearch ( QUEUE *start, QUEUE *end, W val, W offset );
133: IMPORT QUEUE* QueSearchH ( QUEUE *start, QUEUE *end, H val, W offset );
134: IMPORT QUEUE* QueSearchNE ( QUEUE *start, QUEUE *end, W val, W offset );
135: IMPORT QUEUE* QueSearchNEH ( QUEUE *start, QUEUE *end, H val, W offset );
136: IMPORT QUEUE* QueSearchGT ( QUEUE *start, QUEUE *end, W val, W offset );
137: IMPORT QUEUE* QueSearchGTUB( QUEUE *start, QUEUE *end, UB val, W offset );
138: IMPORT QUEUE* QueSearchGE ( QUEUE *start, QUEUE *end, W val, W offset );
139: IMPORT QUEUE* QueSearchGEU ( QUEUE *start, QUEUE *end, UW val, W offset );
140:
141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154:
155: IMPORT QUEUE* QueSearchRevLTU( QUEUE *start, QUEUE *end, UW val, W offset );
156:
157: #ifdef __cplusplus
158: }
159: #endif
160: #endif