Changeset 0a97ba5b in rtems


Ignore:
Timestamp:
Apr 12, 2016, 3:02:27 PM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
709f38a
Parents:
36272279
git-author:
Sebastian Huber <sebastian.huber@…> (04/12/16 15:02:27)
git-committer:
Sebastian Huber <sebastian.huber@…> (04/18/16 06:20:15)
Message:

score: _User_extensions_Handler_initialization()

Simplify _User_extensions_Handler_initialization().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/src/userext.c

    r36272279 r0a97ba5b  
    2424#include <rtems/score/wkspace.h>
    2525
    26 typedef struct {
    27   User_extensions_Switch_control *switch_control;
    28 } User_extensions_Switch_context;
     26void _User_extensions_Handler_initialization(void)
     27{
     28  User_extensions_Switch_control *initial_extension_switch_controls;
     29  const User_extensions_Table    *initial_table;
     30  uint32_t                        n;
     31  uint32_t                        i;
    2932
    30 static void _User_extensions_Switch_visitor(
    31   Thread_Control              *executing,
    32   void                        *arg,
    33   const User_extensions_Table *callouts
    34 )
    35 {
    36   User_extensions_thread_switch_extension callout = callouts->thread_switch;
     33  n = rtems_configuration_get_number_of_initial_extensions();
    3734
    38   if ( callout != NULL ) {
    39     User_extensions_Switch_context *ctx = arg;
    40     User_extensions_Switch_control *ctrl = ctx->switch_control;
     35  initial_extension_switch_controls = _Workspace_Allocate_or_fatal_error(
     36    n * sizeof( *initial_extension_switch_controls )
     37  );
    4138
    42     _Chain_Append_unprotected( &_User_extensions_Switches_list, &ctrl->Node );
    43     ctrl->thread_switch = callout;
     39  initial_table = rtems_configuration_get_user_extension_table();
    4440
    45     ctx->switch_control = ctrl + 1;
     41  for ( i = 0 ; i < n ; ++i ) {
     42    User_extensions_thread_switch_extension callout;
     43
     44    callout = initial_table[ i ].thread_switch;
     45
     46    if ( callout != NULL ) {
     47      User_extensions_Switch_control *c;
     48
     49      c = &initial_extension_switch_controls[ i ];
     50      c->thread_switch = callout;
     51      _Chain_Append_unprotected( &_User_extensions_Switches_list, &c->Node );
     52    }
    4653  }
    4754}
    48 
    49 void _User_extensions_Handler_initialization(void)
    50 {
    51   User_extensions_Switch_control *initial_extension_switch_controls =
    52     _Workspace_Allocate_or_fatal_error(
    53       rtems_configuration_get_number_of_initial_extensions()
    54         * sizeof( *initial_extension_switch_controls )
    55     );
    56   User_extensions_Switch_context ctx = { initial_extension_switch_controls };
    57 
    58   _User_extensions_Iterate( &ctx, _User_extensions_Switch_visitor );
    59 }
Note: See TracChangeset for help on using the changeset viewer.