source: rtems/c/src/exec/score/headers/chain.h @ 60b791ad

4.104.114.84.95
Last change on this file since 60b791ad was 60b791ad, checked in by Joel Sherrill <joel.sherrill@…>, on 02/17/98 at 23:46:28

updated copyright to 1998

  • Property mode set to 100644
File size: 3.7 KB
Line 
1/*  chain.h
2 *
3 *  This include file contains all the constants and structures associated
4 *  with the Doubly Linked Chain Handler.
5 *
6 *  COPYRIGHT (c) 1989-1998.
7 *  On-Line Applications Research Corporation (OAR).
8 *  Copyright assigned to U.S. Government, 1994.
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.OARcorp.com/rtems/license.html.
13 *
14 *  $Id$
15 */
16
17#ifndef __RTEMS_CHAIN_h
18#define __RTEMS_CHAIN_h
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#include <rtems/score/address.h>
25
26/*
27 *  This is used to manage each element (node) which is placed
28 *  on a chain.
29 *
30 *  NOTE:  Typically, a more complicated structure will use the
31 *         chain package.  The more complicated structure will
32 *         include a chain node as the first element in its
33 *         control structure.  It will then call the chain package
34 *         with a pointer to that node element.  The node pointer
35 *         and the higher level structure start at the same address
36 *         so the user can cast the pointers back and forth.
37 *
38 */
39
40typedef struct Chain_Node_struct Chain_Node;
41
42struct Chain_Node_struct {
43  Chain_Node *next;
44  Chain_Node *previous;
45};
46
47/*
48 *  This is used to manage a chain.  A chain consists of a doubly
49 *  linked list of zero or more nodes.
50 *
51 *  NOTE:  This implementation does not require special checks for
52 *         manipulating the first and last elements on the chain.
53 *         To accomplish this the chain control structure is
54 *         treated as two overlapping chain nodes.  The permanent
55 *         head of the chain overlays a node structure on the
56 *         first and permanent_null fields.  The permanent tail
57 *         of the chain overlays a node structure on the
58 *         permanent_null and last elements of the structure.
59 *
60 */
61
62typedef struct {
63  Chain_Node *first;
64  Chain_Node *permanent_null;
65  Chain_Node *last;
66} Chain_Control;
67
68/*
69 *  _Chain_Initialize
70 *
71 *  DESCRIPTION:
72 *
73 *  This routine initializes the_chain structure to manage the
74 *  contiguous array of number_nodes nodes which starts at
75 *  starting_address.  Each node is of node_size bytes.
76 *
77 */
78
79void _Chain_Initialize(
80  Chain_Control *the_chain,
81  void          *starting_address,
82  unsigned32     number_nodes,
83  unsigned32     node_size
84);
85
86/*
87 *  _Chain_Get_first_unprotected
88 */
89 
90#ifndef USE_INLINES
91Chain_Node *_Chain_Get_first_unprotected(
92  Chain_Control *the_chain
93);
94#endif
95
96/*
97 *  _Chain_Extract
98 *
99 *  DESCRIPTION:
100 *
101 *  This routine extracts the_node from the chain on which it resides.
102 *  It disables interrupts to insure the atomicity of the
103 *  extract operation.
104 *
105 */
106
107void _Chain_Extract(
108  Chain_Node *the_node
109);
110
111/*
112 *  _Chain_Get
113 *
114 *  DESCRIPTION:
115 *
116 *  This function removes the first node from the_chain and returns
117 *  a pointer to that node.  If the_chain is empty, then NULL is returned.
118 *  It disables interrupts to insure the atomicity of the
119 *  get operation.
120 *
121 */
122
123Chain_Node *_Chain_Get(
124  Chain_Control *the_chain
125);
126
127/*
128 *  _Chain_Insert
129 *
130 *  DESCRIPTION:
131 *
132 *  This routine inserts the_node on a chain immediately following
133 *  after_node.  It disables interrupts to insure the atomicity
134 *  of the extract operation.
135 *
136 */
137
138void _Chain_Insert(
139  Chain_Node *after_node,
140  Chain_Node *the_node
141);
142
143/*
144 *  _Chain_Append
145 *
146 *  DESCRIPTION:
147 *
148 *  This routine appends the_node onto the end of the_chain.
149 *  It disables interrupts to insure the atomicity of the
150 *  append operation.
151 *
152 */
153
154void _Chain_Append(
155  Chain_Control *the_chain,
156  Chain_Node    *the_node
157);
158
159#ifndef __RTEMS_APPLICATION__
160#include <rtems/score/chain.inl>
161#endif
162
163#ifdef __cplusplus
164}
165#endif
166
167#endif
168/* end of include file */
Note: See TracBrowser for help on using the repository browser.