source: rtems/cpukit/score/src/objectgetnameasstring.c @ 1772a04

5
Last change on this file since 1772a04 was 582bb23c, checked in by Sebastian Huber <sebastian.huber@…>, on 05/20/16 at 13:04:16

score: Rename _Objects_Get_local()

Rename _Objects_Get_local() into _Objects_Get(). Confusions with the
previous _Objects_Get() function are avoided since the Objects_Locations
parameter is gone.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/**
2 * @file
3 *
4 * @brief Extracts a Node from a Chain
5 *
6 * @ingroup Score
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2008.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#ifdef HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/score/threadimpl.h>
23
24#include <ctype.h>
25
26/*
27 *  This method objects the name of an object and returns its name
28 *  in the form of a C string.  It attempts to be careful about
29 *  overflowing the user's string and about returning unprintable characters.
30 */
31
32char *_Objects_Get_name_as_string(
33  Objects_Id        id,
34  size_t            length,
35  char             *name
36)
37{
38  Objects_Information   *information;
39  const char            *s;
40  char                  *d;
41  uint32_t               i;
42  char                   lname[5];
43  Objects_Control       *the_object;
44  ISR_lock_Context       lock_context;
45  Objects_Id             tmpId;
46
47  if ( length == 0 )
48    return NULL;
49
50  if ( name == NULL )
51    return NULL;
52
53  tmpId = (id == OBJECTS_ID_OF_SELF) ? _Thread_Get_executing()->Object.id : id;
54
55  information = _Objects_Get_information_id( tmpId );
56  if ( !information )
57    return NULL;
58
59  the_object = _Objects_Get( tmpId, &lock_context, information );
60  if ( the_object == NULL ) {
61    return NULL;
62  }
63
64  #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
65    if ( information->is_string ) {
66      s = the_object->name.name_p;
67    } else
68  #endif
69  {
70    uint32_t  u32_name = (uint32_t) the_object->name.name_u32;
71
72    lname[ 0 ] = (u32_name >> 24) & 0xff;
73    lname[ 1 ] = (u32_name >> 16) & 0xff;
74    lname[ 2 ] = (u32_name >>  8) & 0xff;
75    lname[ 3 ] = (u32_name >>  0) & 0xff;
76    lname[ 4 ] = '\0';
77    s = lname;
78  }
79
80  d = name;
81  if ( s ) {
82    for ( i=0 ; i<(length-1) && *s ; i++, s++, d++ ) {
83      *d = (isprint((unsigned char)*s)) ? *s : '*';
84    }
85  }
86  *d = '\0';
87
88  _ISR_lock_ISR_enable( &lock_context );
89  return name;
90}
Note: See TracBrowser for help on using the repository browser.