From 6136168881ebcb154e62f0a0296b4b829b6a5422 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 22 Aug 1995 13:56:54 +0000 Subject: Modified object name to id translation loop to make it easier to incorporate variable length object names. Previously the algorithm scanned an array of 4-byte names for a match. Now it scans the object table, grabs a pointer to the name, and then compares it if the object is active and has a name. --- c/src/exec/score/src/object.c | 40 ++++++++++++++++++++++++---------------- cpukit/score/src/object.c | 40 ++++++++++++++++++++++++---------------- 2 files changed, 48 insertions(+), 32 deletions(-) diff --git a/c/src/exec/score/src/object.c b/c/src/exec/score/src/object.c index bd8edaef58..0181903647 100644 --- a/c/src/exec/score/src/object.c +++ b/c/src/exec/score/src/object.c @@ -161,28 +161,36 @@ rtems_status_code _Objects_Name_to_id( Objects_Id *id ) { - Objects_Name *names; - unsigned32 index; + boolean search_local_node; + Objects_Control **objects; + Objects_Control *the_object; + unsigned32 index; if ( name == 0 ) return( RTEMS_INVALID_NAME ); - if ( (information->maximum != 0) && - (node == RTEMS_SEARCH_ALL_NODES || - node == RTEMS_SEARCH_LOCAL_NODE || - _Objects_Is_local_node( node )) ) { - for ( names = information->name_table, index = 1; - index <= information->maximum; - index++ - ) - if ( name == names[ index ] ) { - *id = _Objects_Build_id( - information->the_class, - _Objects_Local_node, - index - ); + search_local_node = FALSE; + + if ( information->maximum != 0 && + (node == RTEMS_SEARCH_ALL_NODES || node == RTEMS_SEARCH_LOCAL_NODE || + _Objects_Is_local_node( node ) ) ) + search_local_node = TRUE; + + if ( search_local_node ) { + objects = information->local_table; + + for ( index = 1; index <= information->maximum; index++ ) { + + the_object = objects[ index ]; + + if ( !the_object || !the_object->name ) + continue; + + if ( name == *the_object->name ) { + *id = the_object->id; return( RTEMS_SUCCESSFUL ); } + } } if ( _Objects_Is_local_node( node ) || node == RTEMS_SEARCH_LOCAL_NODE ) diff --git a/cpukit/score/src/object.c b/cpukit/score/src/object.c index bd8edaef58..0181903647 100644 --- a/cpukit/score/src/object.c +++ b/cpukit/score/src/object.c @@ -161,28 +161,36 @@ rtems_status_code _Objects_Name_to_id( Objects_Id *id ) { - Objects_Name *names; - unsigned32 index; + boolean search_local_node; + Objects_Control **objects; + Objects_Control *the_object; + unsigned32 index; if ( name == 0 ) return( RTEMS_INVALID_NAME ); - if ( (information->maximum != 0) && - (node == RTEMS_SEARCH_ALL_NODES || - node == RTEMS_SEARCH_LOCAL_NODE || - _Objects_Is_local_node( node )) ) { - for ( names = information->name_table, index = 1; - index <= information->maximum; - index++ - ) - if ( name == names[ index ] ) { - *id = _Objects_Build_id( - information->the_class, - _Objects_Local_node, - index - ); + search_local_node = FALSE; + + if ( information->maximum != 0 && + (node == RTEMS_SEARCH_ALL_NODES || node == RTEMS_SEARCH_LOCAL_NODE || + _Objects_Is_local_node( node ) ) ) + search_local_node = TRUE; + + if ( search_local_node ) { + objects = information->local_table; + + for ( index = 1; index <= information->maximum; index++ ) { + + the_object = objects[ index ]; + + if ( !the_object || !the_object->name ) + continue; + + if ( name == *the_object->name ) { + *id = the_object->id; return( RTEMS_SUCCESSFUL ); } + } } if ( _Objects_Is_local_node( node ) || node == RTEMS_SEARCH_LOCAL_NODE ) -- cgit v1.2.3