Changeset c0d4abe6 in rtems


Ignore:
Timestamp:
May 15, 2002, 4:29:05 PM (18 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
a923a82
Parents:
0df8293e
Message:

2002-05-15 Chris Johns <ccj@…>

  • libc/newlibc.c: Per PR141, move the C library re-enterrant support directly into the thread dispatch code. RTEMS needs libc and so requiring libc to use a user extension with its overhead is not the best solution. This patch lowers the overhead to 2 pointer moves.
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/libcsupport/src/newlibc.c

    r0df8293e rc0d4abe6  
    4444#include <stdio.h>
    4545#endif
    46 
    47 static int extension_index;
    48 
    49 /*
    50  *  Private routines
    51  */
    52 
    53 #define set_newlib_extension( _the_thread, _value ) \
    54   (_the_thread)->extensions[ extension_index ] = (_value);
    55 
    56 #define get_newlib_extension( _the_thread ) \
    57   (_the_thread)->extensions[ extension_index ]
    5846
    5947int              libc_reentrant;        /* do we think we are reentrant? */
     
    115103)
    116104{
    117   set_newlib_extension( creating_task, NULL );
     105  creating_task->libc_reent = NULL;
    118106  return TRUE;
    119107}
     
    157145#endif
    158146
    159   set_newlib_extension( starting_task, ptr );
     147  starting_task->libc_reent = ptr;
    160148}
    161149
     
    170158}
    171159#endif
    172 
    173 rtems_extension libc_switch_hook(
    174   rtems_tcb *current_task,
    175   rtems_tcb *heir_task
    176 )
    177 {
    178   /*
    179    *  Don't touch the outgoing task if it has been deleted.
    180    */
    181 
    182   if ( !_States_Is_transient( current_task->current_state ) ) {
    183     set_newlib_extension( current_task, _REENT );
    184   }
    185 
    186   _REENT = (struct _reent *) get_newlib_extension( heir_task );
    187 }
    188160
    189161/*
     
    226198    ptr = _REENT;
    227199  } else {
    228     ptr = (struct _reent *) get_newlib_extension( deleted_task );
     200    ptr = (struct _reent *) deleted_task->libc_reent;
    229201  }
    230202
     
    236208  }
    237209
    238   set_newlib_extension( deleted_task, NULL );
     210  deleted_task->libc_reent = NULL;
    239211
    240212  /*
     
    295267    libc_extension.thread_begin   = libc_begin_hook;
    296268#endif
    297     libc_extension.thread_switch  = libc_switch_hook;
    298269    libc_extension.thread_delete  = libc_delete_hook;
     270
     271    _Thread_Set_libc_reent ((void**) &_REENT);
    299272
    300273    rc = rtems_extension_create(rtems_build_name('L', 'I', 'B', 'C'),
     
    304277
    305278    libc_reentrant = reentrant;
    306     extension_index = rtems_get_index( extension_id );
    307279  }
    308280}
     
    360332#endif
    361333
    362 
    363 #endif
     334#endif
  • c/src/lib/ChangeLog

    r0df8293e rc0d4abe6  
     12002-05-15      Chris Johns <ccj@acm.org>
     2
     3        * libc/newlibc.c: Per PR141, move the C library re-enterrant
     4        support directly into the thread dispatch code. RTEMS needs
     5        libc and so requiring libc to use a user extension with its
     6        overhead is not the best solution. This patch lowers the
     7        overhead to 2 pointer moves.
     8
    192001-05-15      Joel Sherrill <joel@OARcorp.com>
    210
  • c/src/lib/libc/newlibc.c

    r0df8293e rc0d4abe6  
    4444#include <stdio.h>
    4545#endif
    46 
    47 static int extension_index;
    48 
    49 /*
    50  *  Private routines
    51  */
    52 
    53 #define set_newlib_extension( _the_thread, _value ) \
    54   (_the_thread)->extensions[ extension_index ] = (_value);
    55 
    56 #define get_newlib_extension( _the_thread ) \
    57   (_the_thread)->extensions[ extension_index ]
    5846
    5947int              libc_reentrant;        /* do we think we are reentrant? */
     
    115103)
    116104{
    117   set_newlib_extension( creating_task, NULL );
     105  creating_task->libc_reent = NULL;
    118106  return TRUE;
    119107}
     
    157145#endif
    158146
    159   set_newlib_extension( starting_task, ptr );
     147  starting_task->libc_reent = ptr;
    160148}
    161149
     
    170158}
    171159#endif
    172 
    173 rtems_extension libc_switch_hook(
    174   rtems_tcb *current_task,
    175   rtems_tcb *heir_task
    176 )
    177 {
    178   /*
    179    *  Don't touch the outgoing task if it has been deleted.
    180    */
    181 
    182   if ( !_States_Is_transient( current_task->current_state ) ) {
    183     set_newlib_extension( current_task, _REENT );
    184   }
    185 
    186   _REENT = (struct _reent *) get_newlib_extension( heir_task );
    187 }
    188160
    189161/*
     
    226198    ptr = _REENT;
    227199  } else {
    228     ptr = (struct _reent *) get_newlib_extension( deleted_task );
     200    ptr = (struct _reent *) deleted_task->libc_reent;
    229201  }
    230202
     
    236208  }
    237209
    238   set_newlib_extension( deleted_task, NULL );
     210  deleted_task->libc_reent = NULL;
    239211
    240212  /*
     
    295267    libc_extension.thread_begin   = libc_begin_hook;
    296268#endif
    297     libc_extension.thread_switch  = libc_switch_hook;
    298269    libc_extension.thread_delete  = libc_delete_hook;
     270
     271    _Thread_Set_libc_reent ((void**) &_REENT);
    299272
    300273    rc = rtems_extension_create(rtems_build_name('L', 'I', 'B', 'C'),
     
    304277
    305278    libc_reentrant = reentrant;
    306     extension_index = rtems_get_index( extension_id );
    307279  }
    308280}
     
    360332#endif
    361333
    362 
    363 #endif
     334#endif
  • cpukit/libcsupport/src/newlibc.c

    r0df8293e rc0d4abe6  
    4444#include <stdio.h>
    4545#endif
    46 
    47 static int extension_index;
    48 
    49 /*
    50  *  Private routines
    51  */
    52 
    53 #define set_newlib_extension( _the_thread, _value ) \
    54   (_the_thread)->extensions[ extension_index ] = (_value);
    55 
    56 #define get_newlib_extension( _the_thread ) \
    57   (_the_thread)->extensions[ extension_index ]
    5846
    5947int              libc_reentrant;        /* do we think we are reentrant? */
     
    115103)
    116104{
    117   set_newlib_extension( creating_task, NULL );
     105  creating_task->libc_reent = NULL;
    118106  return TRUE;
    119107}
     
    157145#endif
    158146
    159   set_newlib_extension( starting_task, ptr );
     147  starting_task->libc_reent = ptr;
    160148}
    161149
     
    170158}
    171159#endif
    172 
    173 rtems_extension libc_switch_hook(
    174   rtems_tcb *current_task,
    175   rtems_tcb *heir_task
    176 )
    177 {
    178   /*
    179    *  Don't touch the outgoing task if it has been deleted.
    180    */
    181 
    182   if ( !_States_Is_transient( current_task->current_state ) ) {
    183     set_newlib_extension( current_task, _REENT );
    184   }
    185 
    186   _REENT = (struct _reent *) get_newlib_extension( heir_task );
    187 }
    188160
    189161/*
     
    226198    ptr = _REENT;
    227199  } else {
    228     ptr = (struct _reent *) get_newlib_extension( deleted_task );
     200    ptr = (struct _reent *) deleted_task->libc_reent;
    229201  }
    230202
     
    236208  }
    237209
    238   set_newlib_extension( deleted_task, NULL );
     210  deleted_task->libc_reent = NULL;
    239211
    240212  /*
     
    295267    libc_extension.thread_begin   = libc_begin_hook;
    296268#endif
    297     libc_extension.thread_switch  = libc_switch_hook;
    298269    libc_extension.thread_delete  = libc_delete_hook;
     270
     271    _Thread_Set_libc_reent ((void**) &_REENT);
    299272
    300273    rc = rtems_extension_create(rtems_build_name('L', 'I', 'B', 'C'),
     
    304277
    305278    libc_reentrant = reentrant;
    306     extension_index = rtems_get_index( extension_id );
    307279  }
    308280}
     
    360332#endif
    361333
    362 
    363 #endif
     334#endif
Note: See TracChangeset for help on using the changeset viewer.