OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [score/] [macros/] [rtems/] [score/] [chain.inl] - Blame information for rev 546

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  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-1999.
7
 *  On-Line Applications Research Corporation (OAR).
8
 *
9
 *  The license and distribution terms for this file may be
10
 *  found in the file LICENSE in this distribution or at
11
 *  http://www.OARcorp.com/rtems/license.html.
12
 *
13
 *  $Id: chain.inl,v 1.2 2001-09-27 11:59:34 chris Exp $
14
 */
15
 
16
#ifndef __MACROS_CHAIN_h
17
#define __MACROS_CHAIN_h
18
 
19
/*PAGE
20
 *
21
 *  _Chain_Are_nodes_equal
22
 */
23
 
24
#define _Chain_Are_nodes_equal( _left, _right ) \
25
  ( (_left) == (_right) )
26
 
27
/*PAGE
28
 *
29
 *  _Chain_Is_null
30
 */
31
 
32
#define _Chain_Is_null( _the_chain ) \
33
  ( (_the_chain) == NULL )
34
 
35
/*PAGE
36
 *
37
 *  _Chain_Is_null_node
38
 */
39
 
40
#define _Chain_Is_null_node( _the_node ) \
41
  ( (_the_node) == NULL )
42
 
43
/*PAGE
44
 *
45
 *  _Chain_Head
46
 */
47
 
48
#define _Chain_Head( _the_chain ) \
49
   ((Chain_Node *) (_the_chain))
50
 
51
/*PAGE
52
 *
53
 *  _Chain_Tail
54
 */
55
 
56
#define _Chain_Tail( _the_chain ) \
57
   ((Chain_Node *) &(_the_chain)->permanent_null)
58
 
59
/*PAGE
60
 *
61
 *  _Chain_Is_empty
62
 */
63
 
64
#define _Chain_Is_empty( _the_chain ) \
65
  ( (_the_chain)->first == _Chain_Tail( (_the_chain) ) )
66
 
67
/*PAGE
68
 *
69
 *  _Chain_Is_first
70
 */
71
 
72
#define _Chain_Is_first( _the_node ) \
73
  ( (the_node)->previous == NULL )
74
 
75
/*PAGE
76
 *
77
 *  _Chain_Is_last
78
 */
79
 
80
#define _Chain_Is_last( _the_node ) \
81
  ( (_the_node)->next == NULL )
82
 
83
/*PAGE
84
 *
85
 *  _Chain_Has_only_one_node
86
 */
87
 
88
#define _Chain_Has_only_one_node( _the_chain ) \
89
  ( (_the_chain)->first == (_the_chain)->last )
90
 
91
/*PAGE
92
 *
93
 *  _Chain_Is_head
94
 */
95
 
96
#define _Chain_Is_head( _the_chain, _the_node ) \
97
   ( (_the_node) == _Chain_Head( (_the_chain) ) )
98
 
99
/*PAGE
100
 *
101
 *  _Chain_Is_tail
102
 */
103
 
104
#define _Chain_Is_tail( _the_chain, _the_node ) \
105
   ( (_the_node) == _Chain_Tail( (_the_chain) ) )
106
 
107
/*PAGE
108
 *
109
 *  Chain_Initialize_empty
110
 */
111
 
112
#define _Chain_Initialize_empty( _the_chain ) \
113
{ \
114
  (_the_chain)->first          = _Chain_Tail( (_the_chain) ); \
115
  (_the_chain)->permanent_null = NULL; \
116
  (_the_chain)->last           = _Chain_Head( (_the_chain) ); \
117
}
118
 
119
/*PAGE
120
 *
121
 *  _Chain_Extract_unprotected
122
 */
123
 
124
#define _Chain_Extract_unprotected( _the_node ) \
125
{ \
126
  Chain_Node *_next; \
127
  Chain_Node *_previous; \
128
   \
129
  _next           = (_the_node)->next; \
130
  _previous       = (_the_node)->previous; \
131
  _next->previous = _previous; \
132
  _previous->next = _next; \
133
}
134
 
135
/*PAGE
136
 *
137
 *  _Chain_Get_unprotected
138
 */
139
 
140
/*PAGE
141
 *
142
 *  Chain_Get_unprotected
143
 */
144
 
145
#define _Chain_Get_unprotected( _the_chain ) \
146
  (( !_Chain_Is_empty( (_the_chain) ) ) \
147
    ? _Chain_Get_first_unprotected( (_the_chain) ) \
148
    : NULL)
149
 
150
/*PAGE
151
 *
152
 *  _Chain_Insert_unprotected
153
 */
154
 
155
#define _Chain_Insert_unprotected( _after_node, _the_node ) \
156
do {  \
157
  Chain_Node *_before_node; \
158
   \
159
  (_the_node)->previous  = (_after_node); \
160
  _before_node           = (_after_node)->next; \
161
  (_after_node)->next    = (_the_node);  \
162
  (_the_node)->next      = _before_node;  \
163
  _before_node->previous = (_the_node);  \
164
} while (0)
165
 
166
/*PAGE
167
 *
168
 *  _Chain_Append_unprotected
169
 */
170
 
171
#define _Chain_Append_unprotected( _the_chain, _the_node ) \
172
{ \
173
  Chain_Node *_old_last_node; \
174
    \
175
  (_the_node)->next     = _Chain_Tail( (_the_chain) ); \
176
  _old_last_node        = (_the_chain)->last; \
177
  (_the_chain)->last    = (_the_node); \
178
  _old_last_node->next  = (_the_node); \
179
  (_the_node)->previous = _old_last_node; \
180
}
181
 
182
/*PAGE
183
 *
184
 *  _Chain_Prepend_unprotected
185
 */
186
 
187
#define _Chain_Prepend_unprotected( _the_chain, _the_node ) \
188
  _Chain_Insert_unprotected( _Chain_Head( (_the_chain) ), (_the_node) )
189
 
190
/*PAGE
191
 *
192
 *  _Chain_Prepend
193
 */
194
 
195
#define _Chain_Prepend( _the_chain, _the_node ) \
196
  _Chain_Insert( _Chain_Head( (_the_chain) ), (_the_node) )
197
 
198
#endif
199
/* end of include file */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.