source: rtems/cpukit/score/src/objectnametoid.c @ 54cf0e34

4.115
Last change on this file since 54cf0e34 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Object Name To Id
5 *  @ingroup Score
6 */
7
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#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/score/objectimpl.h>
22
23Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32(
24  Objects_Information *information,
25  uint32_t             name,
26  uint32_t             node,
27  Objects_Id          *id
28)
29{
30  bool                       search_local_node;
31  Objects_Control           *the_object;
32  uint32_t                   index;
33#if defined(RTEMS_MULTIPROCESSING)
34  Objects_Name               name_for_mp;
35#endif
36
37  /* ASSERT: information->is_string == false */
38
39  if ( !id )
40    return OBJECTS_INVALID_ADDRESS;
41
42  if ( name == 0 )
43    return OBJECTS_INVALID_NAME;
44
45  search_local_node = false;
46
47  if ( information->maximum != 0 &&
48      (node == OBJECTS_SEARCH_ALL_NODES ||
49       node == OBJECTS_SEARCH_LOCAL_NODE ||
50       _Objects_Is_local_node( node )
51      ))
52   search_local_node = true;
53
54  if ( search_local_node ) {
55    for ( index = 1; index <= information->maximum; index++ ) {
56      the_object = information->local_table[ index ];
57      if ( !the_object )
58        continue;
59
60      if ( name == the_object->name.name_u32 ) {
61        *id = the_object->id;
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}
Note: See TracBrowser for help on using the repository browser.