source: rtems/cpukit/score/src/userextiterate.c @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 3.7 KB
Line 
1/**
2 * @file
3 *
4 * @brief User Extension Iteration Helpers
5 *
6 * @ingroup ScoreUserExt
7 */
8
9/*
10 * Copyright (c) 2012 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.org/license/LICENSE.
21 */
22
23#if HAVE_CONFIG_H
24  #include "config.h"
25#endif
26
27#include <rtems/config.h>
28#include <rtems/score/userextimpl.h>
29
30CHAIN_DEFINE_EMPTY( _User_extensions_List );
31
32void _User_extensions_Thread_create_visitor(
33  Thread_Control              *executing,
34  void                        *arg,
35  const User_extensions_Table *callouts
36)
37{
38  User_extensions_thread_create_extension callout = callouts->thread_create;
39
40  if ( callout != NULL ) {
41    User_extensions_Thread_create_context *ctx = arg;
42
43    ctx->ok = ctx->ok && (*callout)( executing, ctx->created );
44  }
45}
46
47void _User_extensions_Thread_delete_visitor(
48  Thread_Control              *executing,
49  void                        *arg,
50  const User_extensions_Table *callouts
51)
52{
53  User_extensions_thread_delete_extension callout = callouts->thread_delete;
54
55  if ( callout != NULL ) {
56    (*callout)( executing, arg );
57  }
58}
59
60void _User_extensions_Thread_start_visitor(
61  Thread_Control              *executing,
62  void                        *arg,
63  const User_extensions_Table *callouts
64)
65{
66  User_extensions_thread_start_extension callout = callouts->thread_start;
67
68  if ( callout != NULL ) {
69    (*callout)( executing, arg );
70  }
71}
72
73void _User_extensions_Thread_restart_visitor(
74  Thread_Control              *executing,
75  void                        *arg,
76  const User_extensions_Table *callouts
77)
78{
79  User_extensions_thread_restart_extension callout = callouts->thread_restart;
80
81  if ( callout != NULL ) {
82    (*callout)( executing, arg );
83  }
84}
85
86void _User_extensions_Thread_begin_visitor(
87  Thread_Control              *executing,
88  void                        *arg,
89  const User_extensions_Table *callouts
90)
91{
92  User_extensions_thread_begin_extension callout = callouts->thread_begin;
93
94  if ( callout != NULL ) {
95    (*callout)( executing );
96  }
97}
98
99void _User_extensions_Thread_exitted_visitor(
100  Thread_Control              *executing,
101  void                        *arg,
102  const User_extensions_Table *callouts
103)
104{
105  User_extensions_thread_exitted_extension callout = callouts->thread_exitted;
106
107  if ( callout != NULL ) {
108    (*callout)( executing );
109  }
110}
111
112void _User_extensions_Fatal_visitor(
113  Thread_Control              *executing,
114  void                        *arg,
115  const User_extensions_Table *callouts
116)
117{
118  User_extensions_fatal_extension callout = callouts->fatal;
119
120  if ( callout != NULL ) {
121    const User_extensions_Fatal_context *ctx = arg;
122
123    (*callout)( ctx->source, ctx->is_internal, ctx->error );
124  }
125}
126
127void _User_extensions_Iterate(
128  void                    *arg,
129  User_extensions_Visitor  visitor
130)
131{
132  Thread_Control *executing = _Thread_Get_executing();
133  const User_extensions_Table *callouts_current =
134    rtems_configuration_get_user_extension_table();
135  const User_extensions_Table *callouts_end =
136    callouts_current + rtems_configuration_get_number_of_initial_extensions();
137  const Chain_Node *node;
138  const Chain_Node *tail;
139
140  while ( callouts_current != callouts_end ) {
141    (*visitor)( executing, arg, callouts_current );
142
143    ++callouts_current;
144  }
145
146  node = _Chain_Immutable_first( &_User_extensions_List );
147  tail = _Chain_Immutable_tail( &_User_extensions_List );
148  while ( node != tail ) {
149    const User_extensions_Control *extension =
150      (const User_extensions_Control *) node;
151
152    (*visitor)( executing, arg, &extension->Callouts );
153
154    node = _Chain_Immutable_next( node );
155  }
156}
Note: See TracBrowser for help on using the repository browser.