[PATCH 3/4] score: _User_extensions_Handler_initialization()

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Apr 15 09:16:07 UTC 2016


Simplify  _User_extensions_Handler_initialization().
---
 cpukit/score/src/userext.c | 51 +++++++++++++++++++++-------------------------
 1 file changed, 23 insertions(+), 28 deletions(-)

diff --git a/cpukit/score/src/userext.c b/cpukit/score/src/userext.c
index 1ac622e..b4d4b0a 100644
--- a/cpukit/score/src/userext.c
+++ b/cpukit/score/src/userext.c
@@ -23,37 +23,32 @@
 #include <rtems/score/userextimpl.h>
 #include <rtems/score/wkspace.h>
 
-typedef struct {
-  User_extensions_Switch_control *switch_control;
-} User_extensions_Switch_context;
-
-static void _User_extensions_Switch_visitor(
-  Thread_Control              *executing,
-  void                        *arg,
-  const User_extensions_Table *callouts
-)
+void _User_extensions_Handler_initialization(void)
 {
-  User_extensions_thread_switch_extension callout = callouts->thread_switch;
+  User_extensions_Switch_control *initial_extension_switch_controls;
+  const User_extensions_Table    *initial_table;
+  uint32_t                        n;
+  uint32_t                        i;
 
-  if ( callout != NULL ) {
-    User_extensions_Switch_context *ctx = arg;
-    User_extensions_Switch_control *ctrl = ctx->switch_control;
+  n = rtems_configuration_get_number_of_initial_extensions();
 
-    _Chain_Append_unprotected( &_User_extensions_Switches_list, &ctrl->Node );
-    ctrl->thread_switch = callout;
+  initial_extension_switch_controls = _Workspace_Allocate_or_fatal_error(
+    n * sizeof( *initial_extension_switch_controls )
+  );
 
-    ctx->switch_control = ctrl + 1;
-  }
-}
+  initial_table = rtems_configuration_get_user_extension_table();
 
-void _User_extensions_Handler_initialization(void)
-{
-  User_extensions_Switch_control *initial_extension_switch_controls =
-    _Workspace_Allocate_or_fatal_error(
-      rtems_configuration_get_number_of_initial_extensions()
-        * sizeof( *initial_extension_switch_controls )
-    );
-  User_extensions_Switch_context ctx = { initial_extension_switch_controls };
-
-  _User_extensions_Iterate( &ctx, _User_extensions_Switch_visitor );
+  for ( i = 0 ; i < n ; ++i ) {
+    User_extensions_thread_switch_extension callout;
+
+    callout = initial_table[ i ].thread_switch;
+
+    if ( callout != NULL ) {
+      User_extensions_Switch_control *c;
+
+      c = &initial_extension_switch_controls[ i ];
+      c->thread_switch = callout;
+      _Chain_Append_unprotected( &_User_extensions_Switches_list, &c->Node );
+    }
+  }
 }
-- 
1.8.4.5




More information about the devel mailing list