source: rtems/cpukit/score/src/objectidtoname.c @ 469dc47

Last change on this file since 469dc47 was 469dc47, checked in by Sebastian Huber <sebastian.huber@…>, on May 3, 2016 at 7:17:45 AM

score: Simplify _Objects_Id_to_name()

  • Property mode set to 100644
File size: 1.2 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.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/score/threadimpl.h>
22
23Objects_Name_or_id_lookup_errors _Objects_Id_to_name (
24  Objects_Id      id,
25  Objects_Name   *name
26)
27{
28  Objects_Id           tmpId;
29  Objects_Information *information;
30  Objects_Control     *the_object;
31  ISR_lock_Context     lock_context;
32
33  /*
34   *  Caller is trusted for name != NULL.
35   */
36
37  tmpId = (id == OBJECTS_ID_OF_SELF) ? _Thread_Get_executing()->Object.id : id;
38
39  information = _Objects_Get_information_id( tmpId );
40  if ( !information )
41    return OBJECTS_INVALID_ID;
42
43  #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
44    if ( information->is_string )
45      return OBJECTS_INVALID_ID;
46  #endif
47
48  the_object = _Objects_Get_local(
49    tmpId,
50    &lock_context,
51    information
52  );
53  if ( !the_object )
54    return OBJECTS_INVALID_ID;
55
56  *name = the_object->name;
57  _ISR_lock_ISR_enable( &lock_context );
58  return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL;
59}
Note: See TracBrowser for help on using the repository browser.