File indexing completed on 2025-05-11 08:24:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 #ifdef HAVE_CONFIG_H
0039 #include "config.h"
0040 #endif
0041
0042 #include <rtems/score/threadimpl.h>
0043
0044
0045
0046
0047
0048 static bool _Objects_Name_char_is_printable( char c )
0049 {
0050 unsigned char uc;
0051
0052 uc = (unsigned char) c;
0053 return uc >= ' ' && uc <= '~';
0054 }
0055
0056 size_t _Objects_Name_to_string(
0057 Objects_Name name,
0058 bool is_string,
0059 char *buffer,
0060 size_t buffer_size
0061 )
0062 {
0063 char lname[ 5 ];
0064 const char *s;
0065 char *d;
0066 size_t i;
0067
0068 if ( is_string ) {
0069 s = name.name_p;
0070 } else {
0071 lname[ 0 ] = (name.name_u32 >> 24) & 0xff;
0072 lname[ 1 ] = (name.name_u32 >> 16) & 0xff;
0073 lname[ 2 ] = (name.name_u32 >> 8) & 0xff;
0074 lname[ 3 ] = (name.name_u32 >> 0) & 0xff;
0075 lname[ 4 ] = '\0';
0076 s = lname;
0077 }
0078
0079 d = buffer;
0080 i = 1;
0081
0082 if ( s != NULL ) {
0083 while ( *s != '\0' ) {
0084 if ( i < buffer_size ) {
0085 *d = _Objects_Name_char_is_printable(*s) ? *s : '*';
0086 ++d;
0087 }
0088
0089 ++s;
0090 ++i;
0091 }
0092 }
0093
0094 if ( buffer_size > 0 ) {
0095 *d = '\0';
0096 }
0097
0098 return i - 1;
0099 }
0100
0101
0102
0103
0104
0105
0106
0107 char *_Objects_Get_name_as_string(
0108 Objects_Id id,
0109 size_t length,
0110 char *name
0111 )
0112 {
0113 const Objects_Information *information;
0114 const Objects_Control *the_object;
0115 ISR_lock_Context lock_context;
0116 Objects_Id tmpId;
0117
0118 if ( length == 0 )
0119 return NULL;
0120
0121 if ( name == NULL )
0122 return NULL;
0123
0124 tmpId = (id == OBJECTS_ID_OF_SELF) ? _Thread_Get_executing()->Object.id : id;
0125
0126 information = _Objects_Get_information_id( tmpId );
0127 if ( !information )
0128 return NULL;
0129
0130 the_object = _Objects_Get( tmpId, &lock_context, information );
0131 if ( the_object == NULL ) {
0132 return NULL;
0133 }
0134
0135 _Objects_Name_to_string(
0136 the_object->name,
0137 _Objects_Has_string_name( information ),
0138 name,
0139 length
0140 );
0141
0142 _ISR_lock_ISR_enable( &lock_context );
0143 return name;
0144 }