source: rtems/c/src/exec/score/macros/rtems/score/chain.inl @ c43b34c

4.104.114.84.95
Last change on this file since c43b34c was c43b34c, checked in by Joel Sherrill <joel.sherrill@…>, on 03/11/97 at 15:42:14

modified _Chain_Insert_unprotected to have the form required to be used
as the sole statement in an if or else statement

  • Property mode set to 100644
File size: 3.8 KB
Line 
1/*  macros/chain.h
2 *
3 *  This include file contains the bodies of the routines which are
4 *  associated with doubly linked chains and inlined.
5 *
6 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
7 *  On-Line Applications Research Corporation (OAR).
8 *  All rights assigned to U.S. Government, 1994.
9 *
10 *  This material may be reproduced by or for the U.S. Government pursuant
11 *  to the copyright license under the clause at DFARS 252.227-7013.  This
12 *  notice must appear in all copies of this file and its derivatives.
13 *
14 *  $Id$
15 */
16
17#ifndef __MACROS_CHAIN_h
18#define __MACROS_CHAIN_h
19
20/*PAGE
21 *
22 *  _Chain_Are_nodes_equal
23 */
24
25#define _Chain_Are_nodes_equal( _left, _right ) \
26  ( (_left) == (_right) )
27
28/*PAGE
29 *
30 *  _Chain_Is_null
31 */
32
33#define _Chain_Is_null( _the_chain ) \
34  ( (_the_chain) == NULL )
35
36/*PAGE
37 *
38 *  _Chain_Is_null_node
39 */
40
41#define _Chain_Is_null_node( _the_node ) \
42  ( (_the_node) == NULL )
43
44/*PAGE
45 *
46 *  _Chain_Head
47 */
48
49#define _Chain_Head( _the_chain ) \
50   ((Chain_Node *) (_the_chain))
51
52/*PAGE
53 *
54 *  _Chain_Tail
55 */
56
57#define _Chain_Tail( _the_chain ) \
58   ((Chain_Node *) &(_the_chain)->permanent_null)
59
60/*PAGE
61 *
62 *  _Chain_Is_empty
63 */
64
65#define _Chain_Is_empty( _the_chain ) \
66  ( (_the_chain)->first == _Chain_Tail( (_the_chain) ) )
67
68/*PAGE
69 *
70 *  _Chain_Is_first
71 */
72
73#define _Chain_Is_first( _the_node ) \
74  ( (the_node)->previous == NULL )
75
76/*PAGE
77 *
78 *  _Chain_Is_last
79 */
80
81#define _Chain_Is_last( _the_node ) \
82  ( (_the_node)->next == NULL )
83
84/*PAGE
85 *
86 *  _Chain_Has_only_one_node
87 */
88
89#define _Chain_Has_only_one_node( _the_chain ) \
90  ( (_the_chain)->first == (_the_chain)->last )
91
92/*PAGE
93 *
94 *  _Chain_Is_head
95 */
96
97#define _Chain_Is_head( _the_chain, _the_node ) \
98   ( (_the_node) == _Chain_Head( (_the_chain) ) )
99
100/*PAGE
101 *
102 *  _Chain_Is_tail
103 */
104
105#define _Chain_Is_tail( _the_chain, _the_node ) \
106   ( (_the_node) == _Chain_Tail( (_the_chain) ) )
107
108/*PAGE
109 *
110 *  Chain_Initialize_empty
111 */
112
113#define _Chain_Initialize_empty( _the_chain ) \
114{ \
115  (_the_chain)->first          = _Chain_Tail( (_the_chain) ); \
116  (_the_chain)->permanent_null = NULL; \
117  (_the_chain)->last           = _Chain_Head( (_the_chain) ); \
118}
119
120/*PAGE
121 *
122 *  _Chain_Extract_unprotected
123 */
124
125#define _Chain_Extract_unprotected( _the_node ) \
126{ \
127  Chain_Node *_next; \
128  Chain_Node *_previous; \
129   \
130  _next           = (_the_node)->next; \
131  _previous       = (_the_node)->previous; \
132  _next->previous = _previous; \
133  _previous->next = _next; \
134}
135
136/*PAGE
137 *
138 *  _Chain_Get_unprotected
139 */
140
141/*PAGE
142 *
143 *  Chain_Get_unprotected
144 */
145
146#define _Chain_Get_unprotected( _the_chain ) \
147  (( !_Chain_Is_empty( (_the_chain) ) ) \
148    ? _Chain_Get_first_unprotected( (_the_chain) ) \
149    : NULL)
150
151/*PAGE
152 *
153 *  _Chain_Insert_unprotected
154 */
155
156#define _Chain_Insert_unprotected( _after_node, _the_node ) \
157do {  \
158  Chain_Node *_before_node; \
159   \
160  (_the_node)->previous  = (_after_node); \
161  _before_node           = (_after_node)->next; \
162  (_after_node)->next    = (_the_node);  \
163  (_the_node)->next      = _before_node;  \
164  _before_node->previous = (_the_node);  \
165} while (0)
166
167/*PAGE
168 *
169 *  _Chain_Append_unprotected
170 */
171
172#define _Chain_Append_unprotected( _the_chain, _the_node ) \
173{ \
174  Chain_Node *_old_last_node; \
175    \
176  (_the_node)->next     = _Chain_Tail( (_the_chain) ); \
177  _old_last_node        = (_the_chain)->last; \
178  (_the_chain)->last    = (_the_node); \
179  _old_last_node->next  = (_the_node); \
180  (_the_node)->previous = _old_last_node; \
181}
182
183/*PAGE
184 *
185 *  _Chain_Prepend_unprotected
186 */
187
188#define _Chain_Prepend_unprotected( _the_chain, _the_node ) \
189  _Chain_Insert_unprotected( _Chain_Head( (_the_chain) ), (_the_node) )
190
191/*PAGE
192 *
193 *  _Chain_Prepend
194 */
195
196#define _Chain_Prepend( _the_chain, _the_node ) \
197  _Chain_Insert( _Chain_Head( (_the_chain) ), (_the_node) )
198
199#endif
200/* end of include file */
Note: See TracBrowser for help on using the repository browser.