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

5
Last change on this file since 469dc47 was 469dc47, checked in by Sebastian Huber <sebastian.huber@…>, on 05/03/16 at 07:17:45

score: Simplify _Objects_Id_to_name()

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[ff08b808]1/*
[5a58b1e]2 *  @file
[ff08b808]3 *
[5a58b1e]4 *  @brief Object id to name
5 *  @ingroup Score
6 */
7
8/*
[ff08b808]9 *  COPYRIGHT (c) 1989-2003.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
[dcf3687]13 *  found in the file LICENSE in this distribution or at
[c499856]14 *  http://www.rtems.org/license/LICENSE.
[ff08b808]15 */
16
[a8eed23]17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
[5618c37a]21#include <rtems/score/threadimpl.h>
[ff08b808]22
23Objects_Name_or_id_lookup_errors _Objects_Id_to_name (
24  Objects_Id      id,
25  Objects_Name   *name
26)
27{
[8932955]28  Objects_Id           tmpId;
[ff08b808]29  Objects_Information *information;
[469dc47]30  Objects_Control     *the_object;
[47c9c083]31  ISR_lock_Context     lock_context;
[05279b84]32
[6fd4d06f]33  /*
34   *  Caller is trusted for name != NULL.
35   */
[ff08b808]36
[02f73d4]37  tmpId = (id == OBJECTS_ID_OF_SELF) ? _Thread_Get_executing()->Object.id : id;
[8932955]38
[0ab4fb7]39  information = _Objects_Get_information_id( tmpId );
[ff08b808]40  if ( !information )
41    return OBJECTS_INVALID_ID;
[05279b84]42
[47988fb]43  #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
44    if ( information->is_string )
45      return OBJECTS_INVALID_ID;
46  #endif
[ff08b808]47
[469dc47]48  the_object = _Objects_Get_local(
[47c9c083]49    tmpId,
[469dc47]50    &lock_context,
51    information
[47c9c083]52  );
[5670775]53  if ( !the_object )
[ff08b808]54    return OBJECTS_INVALID_ID;
55
56  *name = the_object->name;
[47c9c083]57  _ISR_lock_ISR_enable( &lock_context );
[ff08b808]58  return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL;
59}
Note: See TracBrowser for help on using the repository browser.