source: rtems/cpukit/score/macros/rtems/score/userext.inl @ 02a200d

4.104.114.84.95
Last change on this file since 02a200d was 02a200d, checked in by Joel Sherrill <joel.sherrill@…>, on 04/09/02 at 19:19:03

2002-04-08 Chris Johns <ccj@…>

  • Per PR141 and PR174, make task switch extension its own list and fix all odd problems introduced by providing macro version.
  • inline/rtems/score/userext.inl: Fix.
  • Property mode set to 100644
File size: 4.3 KB
Line 
1/*  userext.inl
2 *
3 *  This file contains the macro implementation of the inlined routines
4 *  from the User Extension Handler
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$
14 */
15
16#ifndef __USER_EXTENSIONS_inl
17#define __USER_EXTENSIONS_inl
18
19/*PAGE
20 *
21 *  _User_extensions_Handler_initialization
22 *
23 */
24
25#define _User_extensions_Handler_initialization( \
26  _number_of_extensions, _initial_extensions \
27) \
28  { \
29    User_extensions_Control *extension; \
30    unsigned32               i; \
31    \
32    _Chain_Initialize_empty( &_User_extensions_List ); \
33    _Chain_Initialize_empty( &_User_extensions_Switches_list ); \
34    \
35    if ( (_initial_extensions) ) { \
36      extension = _Workspace_Allocate_or_fatal_error( \
37          sizeof(User_extensions_Control) * _number_of_extensions ); \
38      \
39      memset ( \
40        extension, \
41        0, \
42        _number_of_extensions * sizeof( User_extensions_Control ) \
43      ); \
44      \
45      for ( i = 0 ; i < _number_of_extensions ; i++ ) { \
46        _User_extensions_Add_set (extension, &_initial_extensions[i]); \
47        extension++; \
48      } \
49    } \
50  }
51
52/*PAGE
53 *
54 *  _User_extensions_Add_set
55 */
56
57#define _User_extensions_Add_set( _the_extension, _extension_table ) \
58  do { \
59    (_the_extension)->Callouts = *(_extension_table); \
60    \
61    _Chain_Prepend( &_User_extensions_List, &(_the_extension)->Node ); \
62    \
63    if ( (_the_extension)->Callouts.thread_switch != NULL ) { \
64      (_the_extension)->Switch.thread_switch = \
65        (_the_extension)->Callouts.thread_switch; \
66      _Chain_Append( \
67        &_User_extensions_Switches_list, \
68        &(_the_extension)->Switch.Node \
69     ); \
70    } \
71  } while ( 0 )
72 
73
74/*PAGE
75 *
76 *  _User_extensions_Add_API_set
77 */
78 
79#define _User_extensions_Add_API_set( _the_extension ) \
80  do { \
81    _Chain_Prepend( &_User_extensions_List, &(_the_extension)->Node ); \
82    \
83    if ( (_the_extension)->Callouts.thread_switch != NULL ) { \
84      (_the_extension)->Switch.thread_switch = \
85          (_the_extension)->Callouts.thread_switch; \
86      _Chain_Append( \
87        &_User_extensions_Switches_list, &(_the_extension)->Switch.Node ); \
88    } \
89  } while ( 0 )
90 
91 
92/*PAGE
93 *
94 *  _User_extensions_Remove_set
95 */
96
97#define _User_extensions_Remove_set( _the_extension ) \
98  do { \
99    _Chain_Extract( &(_the_extension)->Node ); \
100    \
101    if ( (_the_extension)->Callouts.thread_switch != NULL ) { \
102      _Chain_Extract( &(_the_extension)->Node ); \
103    } \
104  } while (0)
105
106/*PAGE
107 *
108 *  _User_extensions_Run_list_forward
109 *
110 *  NOTE:  No parentheses around macro names here to avoid
111 *         messing up the name and function call expansion.
112 */
113
114#define _User_extensions_Run_list_forward( _list, _name, _arguments ) \
115  do { \
116    Chain_Node              *the_node; \
117    User_extensions_Control *the_extension; \
118    \
119    for ( the_node = (_list).first ; \
120          !_Chain_Is_tail( &(_list), the_node ) ; \
121          the_node = the_node->next ) { \
122      the_extension = (User_extensions_Control *) the_node; \
123      \
124      if ( the_extension->Callouts.## _name != NULL ) \
125        (*the_extension->Callouts.## _name) _arguments; \
126      \
127    } \
128    \
129  } while ( 0 )
130
131/*PAGE
132 *
133 *  _User_extensions_Run_list_backward
134 *
135 *  NOTE:  No parentheses around macro names here to avoid
136 *         messing up the name and function call expansion.
137 */
138
139#define _User_extensions_Run_list_backward( _list, _name, _arguments ) \
140  do { \
141    Chain_Node              *the_node; \
142    User_extensions_Control *the_extension; \
143    \
144    for ( the_node = (_list).last ; \
145          !_Chain_Is_head( &(_list), the_node ) ; \
146          the_node = the_node->previous ) { \
147      the_extension = (User_extensions_Control *) the_node; \
148      \
149      if ( the_extension->Callouts.## _name != NULL ) \
150        (*the_extension->Callouts.## _name) _arguments; \
151      \
152    } \
153    \
154  } while ( 0 )
155
156/*PAGE
157 *
158 *  _User_extensions_Thread_switch
159 *
160 */
161
162#define _User_extensions_Thread_switch( _executing, _heir ) \
163  _User_extensions_Run_list_forward( \
164    _User_extensions_Switches_list, \
165    thread_switch, \
166    (_executing, _heir) \
167  )
168
169#endif
170/* end of include file */
Note: See TracBrowser for help on using the repository browser.