RTEMS
objectnametoid.c
Go to the documentation of this file.
1 
8 /*
9  * COPYRIGHT (c) 1989-2010.
10  * On-Line Applications Research Corporation (OAR).
11  *
12  * The license and distribution terms for this file may be
13  * found in the file LICENSE in this distribution or at
14  * http://www.rtems.org/license/LICENSE.
15  */
16 
17 #ifdef HAVE_CONFIG_H
18 #include "config.h"
19 #endif
20 
21 #include <rtems/score/objectimpl.h>
22 
24  uint32_t name,
25  uint32_t node,
26  Objects_Id *id,
27  const Objects_Information *information
28 )
29 {
30  bool search_local_node;
31  const Objects_Control *the_object;
32  Objects_Maximum maximum;
33  Objects_Maximum index;
34 #if defined(RTEMS_MULTIPROCESSING)
35  Objects_Name name_for_mp;
36 #endif
37 
38  /* ASSERT: information->is_string == false */
39 
40  if ( !id )
41  return OBJECTS_INVALID_ADDRESS;
42 
43  maximum = _Objects_Get_maximum_index( information );
44  search_local_node = false;
45 
46  if ( maximum > 0 &&
47  (node == OBJECTS_SEARCH_ALL_NODES ||
48  node == OBJECTS_SEARCH_LOCAL_NODE ||
50  ))
51  search_local_node = true;
52 
53  if ( search_local_node ) {
54  for ( index = 0; index < maximum; ++index ) {
55  the_object = information->local_table[ index ];
56  if ( !the_object )
57  continue;
58 
59  if ( name == the_object->name.name_u32 ) {
60  *id = the_object->id;
61  _Assert( name != 0 );
62  return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL;
63  }
64  }
65  }
66 
67 #if defined(RTEMS_MULTIPROCESSING)
68  if ( _Objects_Is_local_node( node ) || node == OBJECTS_SEARCH_LOCAL_NODE )
69  return OBJECTS_INVALID_NAME;
70 
71  name_for_mp.name_u32 = name;
72  return _Objects_MP_Global_name_search( information, name_for_mp, node, id );
73 #else
74  return OBJECTS_INVALID_NAME;
75 #endif
76 }
uint32_t name_u32
Definition: object.h:68
static __inline__ Objects_Maximum _Objects_Get_maximum_index(const Objects_Information *information)
Returns the maximum index of the specified object class.
Definition: objectimpl.h:642
static __inline__ bool _Objects_Is_local_node(uint32_t node)
Checks if the node is of the local object.
Definition: objectimpl.h:570
Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32(uint32_t name, uint32_t node, Objects_Id *id, const Objects_Information *information)
Searches an object of the specified class with the specified name on the specified set of nodes...
#define OBJECTS_SEARCH_LOCAL_NODE
Definition: object.h:212
Objects_Name_or_id_lookup_errors
Definition: objectimpl.h:203
uint16_t Objects_Maximum
Definition: object.h:86
Inlined Routines in the Object Handler.
Objects_Control ** local_table
This points to the table of local object control blocks.
Definition: objectdata.h:195
The information structure used to manage each API class of objects.
Definition: objectdata.h:176
uint32_t Objects_Id
Definition: object.h:80
Objects_Name name
Definition: objectdata.h:45
#define OBJECTS_SEARCH_ALL_NODES
Definition: object.h:200
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
Definition: assert.h:100
Objects_Id id
Definition: objectdata.h:43