source: rtems/cpukit/score/src/objectnametoid.c @ 37c7bfcb

4.104.114.84.95
Last change on this file since 37c7bfcb was 7f3d6fe9, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/06 at 22:59:41

2006-11-17 Joel Sherrill <joel@…>

  • score/inline/rtems/score/object.inl, score/src/objectnametoid.c: Properly honor searching only local node even when on single CPU system.
  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 *  Object Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/score/address.h>
21#include <rtems/score/chain.h>
22#include <rtems/score/object.h>
23#if defined(RTEMS_MULTIPROCESSING)
24#include <rtems/score/objectmp.h>
25#endif
26#include <rtems/score/thread.h>
27#include <rtems/score/wkspace.h>
28#include <rtems/score/sysstate.h>
29#include <rtems/score/isr.h>
30
31/*PAGE
32 *
33 *  _Objects_Name_to_id
34 *
35 *  These kernel routines search the object table(s) for the given
36 *  object name and returns the associated object id.
37 *
38 *  Input parameters:
39 *    information - object information
40 *    name        - user defined object name
41 *    node        - node indentifier (0 indicates any node)
42 *    id          - address of return ID
43 *
44 *  Output parameters:
45 *    id                                   - object id
46 *    OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL - if successful
47 *    error code                           - if unsuccessful
48 */
49
50Objects_Name_or_id_lookup_errors _Objects_Name_to_id(
51  Objects_Information *information,
52  Objects_Name         name,
53  uint32_t             node,
54  Objects_Id          *id
55)
56{
57  boolean                    search_local_node;
58  Objects_Control           *the_object;
59  uint32_t                   index;
60  uint32_t                   name_length;
61  Objects_Name_comparators   compare_them;
62
63  if ( !id )
64    return OBJECTS_INVALID_ADDRESS;
65
66  if ( name == 0 )
67    return OBJECTS_INVALID_NAME;
68
69  search_local_node = FALSE;
70
71  if ( information->maximum != 0 &&
72      (node == OBJECTS_SEARCH_ALL_NODES ||
73       node == OBJECTS_SEARCH_LOCAL_NODE ||
74       _Objects_Is_local_node( node )
75      ))
76   search_local_node = TRUE;
77
78  if ( search_local_node ) {
79    name_length = information->name_length;
80
81    if ( information->is_string ) compare_them = _Objects_Compare_name_string;
82    else                          compare_them = _Objects_Compare_name_raw;
83
84    for ( index = 1; index <= information->maximum; index++ ) {
85      the_object = information->local_table[ index ];
86      if ( !the_object || !the_object->name )
87        continue;
88
89      if ( (*compare_them)( name, the_object->name, name_length ) ) {
90        *id = the_object->id;
91        return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL;
92      }
93    }
94  }
95
96#if defined(RTEMS_MULTIPROCESSING)
97  if ( _Objects_Is_local_node( node ) || node == OBJECTS_SEARCH_LOCAL_NODE )
98    return OBJECTS_INVALID_NAME;
99
100  return ( _Objects_MP_Global_name_search( information, name, node, id ) );
101#else
102  return OBJECTS_INVALID_NAME;
103#endif
104}
Note: See TracBrowser for help on using the repository browser.