Changeset 70af0ea1 in rtems


Ignore:
Timestamp:
01/10/00 18:47:58 (24 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
aa1d76e
Parents:
f983d57
Message:

Don't look at the object information structure for threads/tasks
for APIs that are not configured. This resulted in weird behavior
when ITRON was disabled on some targets.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/posix/src/keycreate.c

    rf983d57 r70af0ea1  
    4040  the_key->destructor = destructor;
    4141
     42  /*
     43   *  This is a bit more complex than one might initially expect because
     44   *  APIs are optional.  Thus there may be no ITRON tasks to have keys
     45   *  for.  [NOTE: Currently RTEMS Classic API tasks are not always enabled.]
     46   */
     47
    4248  for ( the_class = OBJECTS_CLASSES_FIRST_THREAD_CLASS;
    4349        the_class <= OBJECTS_CLASSES_LAST_THREAD_CLASS;
    4450        the_class++ ) {
    4551
    46     bytes_to_allocate =
    47       (_Objects_Information_table[ the_class ]->maximum + 1) * sizeof( void * );
     52    if ( _Objects_Information_table[ the_class ] ) {
     53      bytes_to_allocate = sizeof( void * ) *
     54        (_Objects_Information_table[ the_class ]->maximum + 1);
     55      table = _Workspace_Allocate( bytes_to_allocate );
     56      if ( !table ) {
     57        for ( --the_class;
     58              the_class >= OBJECTS_CLASSES_FIRST_THREAD_CLASS;
     59              the_class-- )
     60          _Workspace_Free( the_key->Values[ the_class ] );
     61 
     62        _POSIX_Keys_Free( the_key );
     63        _Thread_Enable_dispatch();
     64        return ENOMEM;
     65      }
    4866
    49     table = _Workspace_Allocate( bytes_to_allocate );
    50 
    51     if ( !table ) {
    52       for ( --the_class;
    53             the_class >= OBJECTS_CLASSES_FIRST_THREAD_CLASS;
    54             the_class-- )
    55         _Workspace_Free( the_key->Values[ the_class ] );
    56 
    57       _POSIX_Keys_Free( the_key );
    58       _Thread_Enable_dispatch();
    59       return ENOMEM;
     67      the_key->Values[ the_class ] = table;
     68      memset( table, '\0', bytes_to_allocate );
     69    } else {
     70      the_key->Values[ the_class ] = NULL;
    6071    }
    6172
    62     the_key->Values[ the_class ] = table;
    63     memset( table, '\0', bytes_to_allocate );
     73
    6474  }
    6575
  • c/src/exec/posix/src/keydelete.c

    rf983d57 r70af0ea1  
    3939            the_class <= OBJECTS_CLASSES_LAST_THREAD_CLASS;
    4040            the_class++ )
    41         _Workspace_Free( the_key->Values[ the_class ] );
     41        if ( the_key->Values[ the_class ] )
     42          _Workspace_Free( the_key->Values[ the_class ] );
    4243
    4344      /*
  • cpukit/posix/src/keycreate.c

    rf983d57 r70af0ea1  
    4040  the_key->destructor = destructor;
    4141
     42  /*
     43   *  This is a bit more complex than one might initially expect because
     44   *  APIs are optional.  Thus there may be no ITRON tasks to have keys
     45   *  for.  [NOTE: Currently RTEMS Classic API tasks are not always enabled.]
     46   */
     47
    4248  for ( the_class = OBJECTS_CLASSES_FIRST_THREAD_CLASS;
    4349        the_class <= OBJECTS_CLASSES_LAST_THREAD_CLASS;
    4450        the_class++ ) {
    4551
    46     bytes_to_allocate =
    47       (_Objects_Information_table[ the_class ]->maximum + 1) * sizeof( void * );
     52    if ( _Objects_Information_table[ the_class ] ) {
     53      bytes_to_allocate = sizeof( void * ) *
     54        (_Objects_Information_table[ the_class ]->maximum + 1);
     55      table = _Workspace_Allocate( bytes_to_allocate );
     56      if ( !table ) {
     57        for ( --the_class;
     58              the_class >= OBJECTS_CLASSES_FIRST_THREAD_CLASS;
     59              the_class-- )
     60          _Workspace_Free( the_key->Values[ the_class ] );
     61 
     62        _POSIX_Keys_Free( the_key );
     63        _Thread_Enable_dispatch();
     64        return ENOMEM;
     65      }
    4866
    49     table = _Workspace_Allocate( bytes_to_allocate );
    50 
    51     if ( !table ) {
    52       for ( --the_class;
    53             the_class >= OBJECTS_CLASSES_FIRST_THREAD_CLASS;
    54             the_class-- )
    55         _Workspace_Free( the_key->Values[ the_class ] );
    56 
    57       _POSIX_Keys_Free( the_key );
    58       _Thread_Enable_dispatch();
    59       return ENOMEM;
     67      the_key->Values[ the_class ] = table;
     68      memset( table, '\0', bytes_to_allocate );
     69    } else {
     70      the_key->Values[ the_class ] = NULL;
    6071    }
    6172
    62     the_key->Values[ the_class ] = table;
    63     memset( table, '\0', bytes_to_allocate );
     73
    6474  }
    6575
  • cpukit/posix/src/keydelete.c

    rf983d57 r70af0ea1  
    3939            the_class <= OBJECTS_CLASSES_LAST_THREAD_CLASS;
    4040            the_class++ )
    41         _Workspace_Free( the_key->Values[ the_class ] );
     41        if ( the_key->Values[ the_class ] )
     42          _Workspace_Free( the_key->Values[ the_class ] );
    4243
    4344      /*
Note: See TracChangeset for help on using the changeset viewer.