source: rtems/cpukit/score/src/objectidtoname.c @ 2d2352b

4.115
Last change on this file since 2d2352b was 2d2352b, checked in by Sebastian Huber <sebastian.huber@…>, on 06/05/13 at 09:48:57

score: Add and use _Objects_Put()

Add and use _Objects_Put_without_thread_dispatch(). These two functions
pair with the _Objects_Get() function. This helps to introduce object
specific SMP locks to avoid lock contention.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  @file
3 *
4 *  @brief Object id to name
5 *  @ingroup Score
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2003.
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.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/score/object.h>
23#include <rtems/score/thread.h>
24
25Objects_Name_or_id_lookup_errors _Objects_Id_to_name (
26  Objects_Id      id,
27  Objects_Name   *name
28)
29{
30  uint32_t             the_api;
31  uint32_t             the_class;
32  Objects_Id           tmpId;
33  Objects_Information *information;
34  Objects_Control     *the_object = (Objects_Control *) 0;
35  Objects_Locations    ignored_location;
36
37  /*
38   *  Caller is trusted for name != NULL.
39   */
40
41  tmpId = (id == OBJECTS_ID_OF_SELF) ? _Thread_Executing->Object.id : id;
42
43  the_api = _Objects_Get_API( tmpId );
44  if ( !_Objects_Is_api_valid( the_api ) )
45    return OBJECTS_INVALID_ID;
46
47  if ( !_Objects_Information_table[ the_api ] )
48    return OBJECTS_INVALID_ID;
49
50  the_class = _Objects_Get_class( tmpId );
51
52  information = _Objects_Information_table[ the_api ][ the_class ];
53  if ( !information )
54    return OBJECTS_INVALID_ID;
55
56  #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
57    if ( information->is_string )
58      return OBJECTS_INVALID_ID;
59  #endif
60
61  the_object = _Objects_Get( information, tmpId, &ignored_location );
62  if ( !the_object )
63    return OBJECTS_INVALID_ID;
64
65  *name = the_object->name;
66  _Objects_Put( the_object );
67  return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL;
68}
Note: See TracBrowser for help on using the repository browser.