mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-26 06:08:20 +00:00
score: Remove Objects_Information::is_string
Use Objects_Information::name_length to store this information. Update #3621.
This commit is contained in:
@@ -132,14 +132,17 @@ typedef struct {
|
||||
Objects_Maximum inactive;
|
||||
/** This is the number of objects in a block. */
|
||||
Objects_Maximum allocation_size;
|
||||
/** This is the maximum length of names. */
|
||||
/**
|
||||
* @brief This is the maximum length of names.
|
||||
*
|
||||
* A length of zero indicates that this object has a no string name
|
||||
* (OBJECTS_NO_STRING_NAME).
|
||||
*/
|
||||
uint16_t name_length;
|
||||
/** This field indicates the API of this object class. */
|
||||
uint8_t the_api;
|
||||
/** This is the class of this object set. */
|
||||
uint8_t the_class;
|
||||
/** This is true if names are strings. */
|
||||
bool is_string;
|
||||
/** This is the true if unlimited objects in this class. */
|
||||
bool auto_extend;
|
||||
/** This is the size in bytes of each object instance. */
|
||||
@@ -225,14 +228,19 @@ void _Objects_Do_initialize_information(
|
||||
uint16_t the_class,
|
||||
uint32_t maximum,
|
||||
uint16_t size,
|
||||
bool is_string,
|
||||
uint32_t maximum_name_length
|
||||
uint16_t maximum_name_length
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
,
|
||||
Objects_Thread_queue_Extract_callout extract
|
||||
#endif
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Constant for the object information string name length to indicate
|
||||
* that this object class has no string names.
|
||||
*/
|
||||
#define OBJECTS_NO_STRING_NAME 0
|
||||
|
||||
/**
|
||||
* @brief Initialize object Information
|
||||
*
|
||||
@@ -261,7 +269,6 @@ void _Objects_Do_initialize_information(
|
||||
the_class, \
|
||||
maximum, \
|
||||
size, \
|
||||
is_string, \
|
||||
maximum_name_length, \
|
||||
extract \
|
||||
) \
|
||||
@@ -271,7 +278,6 @@ void _Objects_Do_initialize_information(
|
||||
the_class, \
|
||||
maximum, \
|
||||
size, \
|
||||
is_string, \
|
||||
maximum_name_length, \
|
||||
extract \
|
||||
)
|
||||
@@ -282,7 +288,6 @@ void _Objects_Do_initialize_information(
|
||||
the_class, \
|
||||
maximum, \
|
||||
size, \
|
||||
is_string, \
|
||||
maximum_name_length, \
|
||||
extract \
|
||||
) \
|
||||
@@ -292,7 +297,6 @@ void _Objects_Do_initialize_information(
|
||||
the_class, \
|
||||
maximum, \
|
||||
size, \
|
||||
is_string, \
|
||||
maximum_name_length \
|
||||
)
|
||||
#endif
|
||||
@@ -735,6 +739,13 @@ Objects_Maximum _Objects_Active_count(
|
||||
const Objects_Information *information
|
||||
);
|
||||
|
||||
RTEMS_INLINE_ROUTINE bool _Objects_Has_string_name(
|
||||
const Objects_Information *information
|
||||
)
|
||||
{
|
||||
return information->name_length > 0;
|
||||
}
|
||||
|
||||
RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Extend_size(
|
||||
const Objects_Information *information
|
||||
)
|
||||
@@ -919,7 +930,7 @@ RTEMS_INLINE_ROUTINE void _Objects_Open_u32(
|
||||
uint32_t name
|
||||
)
|
||||
{
|
||||
_Assert( !information->is_string );
|
||||
_Assert( !_Objects_Has_string_name( information ) );
|
||||
the_object->name.name_u32 = name;
|
||||
|
||||
_Objects_Set_local_object(
|
||||
@@ -943,7 +954,7 @@ RTEMS_INLINE_ROUTINE void _Objects_Open_string(
|
||||
const char *name
|
||||
)
|
||||
{
|
||||
_Assert( information->is_string );
|
||||
_Assert( _Objects_Has_string_name( information ) );
|
||||
the_object->name.name_p = name;
|
||||
|
||||
_Objects_Set_local_object(
|
||||
|
||||
@@ -142,8 +142,7 @@ static void _POSIX_Keys_Manager_initialization(void)
|
||||
/* maximum objects of this class */
|
||||
sizeof( POSIX_Keys_Control ),
|
||||
/* size of this object's control block */
|
||||
false, /* true if names for this object are strings */
|
||||
0, /* maximum length of each object's name */
|
||||
OBJECTS_NO_STRING_NAME, /* maximum length of each object's name */
|
||||
NULL /* Proxy extraction support callout */
|
||||
);
|
||||
|
||||
|
||||
@@ -54,7 +54,6 @@ static void _POSIX_Message_queue_Manager_initialization(void)
|
||||
_Configuration_POSIX_Maximum_message_queues,
|
||||
sizeof( POSIX_Message_queue_Control ),
|
||||
/* size of this object's control block */
|
||||
true, /* true if names for this object are strings */
|
||||
_POSIX_PATH_MAX, /* maximum length of each object's name */
|
||||
NULL /* Proxy extraction support callout */
|
||||
);
|
||||
|
||||
@@ -45,7 +45,6 @@ static void _POSIX_Semaphore_Manager_initialization(void)
|
||||
_Configuration_POSIX_Maximum_named_semaphores,
|
||||
sizeof( POSIX_Semaphore_Control ),
|
||||
/* size of this object's control block */
|
||||
true, /* true if names for this object are strings */
|
||||
_POSIX_PATH_MAX, /* maximum length of each object's name */
|
||||
NULL /* Proxy extraction support callout */
|
||||
);
|
||||
|
||||
@@ -65,8 +65,7 @@ static void _POSIX_Timer_Manager_initialization(void)
|
||||
_Configuration_POSIX_Maximum_timers,
|
||||
sizeof( POSIX_Timer_Control ),
|
||||
/* size of this object's control block */
|
||||
false, /* true if names for this object are strings */
|
||||
0, /* maximum length of each object's name */
|
||||
OBJECTS_NO_STRING_NAME, /* maximum length of an object name */
|
||||
NULL /* Proxy extraction support callout */
|
||||
);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ static void _POSIX_Shm_Manager_initialization( void )
|
||||
_Configuration_POSIX_Maximum_shms,
|
||||
sizeof( POSIX_Shm_Control ),
|
||||
/* size of this object's control block */
|
||||
true, /* true if names for this object are strings */
|
||||
_POSIX_PATH_MAX, /* maximum length of each object's name */
|
||||
NULL /* Proxy extraction support callout */
|
||||
);
|
||||
|
||||
@@ -39,8 +39,7 @@ static void _Barrier_Manager_initialization(void)
|
||||
Configuration_RTEMS_API.maximum_barriers,
|
||||
/* maximum objects of this class */
|
||||
sizeof( Barrier_Control ), /* size of this object's control block */
|
||||
false, /* true if the name is a string */
|
||||
RTEMS_MAXIMUM_NAME_LENGTH, /* maximum length of an object name */
|
||||
OBJECTS_NO_STRING_NAME, /* maximum length of an object name */
|
||||
NULL /* Proxy extraction support callout */
|
||||
);
|
||||
}
|
||||
|
||||
@@ -37,8 +37,7 @@ static void _Dual_ported_memory_Manager_initialization(void)
|
||||
/* maximum objects of this class */
|
||||
sizeof( Dual_ported_memory_Control ),
|
||||
/* size of this object's control block */
|
||||
false, /* true if names of this object are strings */
|
||||
RTEMS_MAXIMUM_NAME_LENGTH, /* maximum length of each object's name */
|
||||
OBJECTS_NO_STRING_NAME, /* maximum length of an object name */
|
||||
NULL /* Proxy extraction support callout */
|
||||
);
|
||||
}
|
||||
|
||||
@@ -39,8 +39,7 @@ static void _Message_queue_Manager_initialization(void)
|
||||
/* maximum objects of this class */
|
||||
sizeof( Message_queue_Control ),
|
||||
/* size of this object's control block */
|
||||
false, /* true if names of this object are strings */
|
||||
RTEMS_MAXIMUM_NAME_LENGTH, /* maximum length of each object's name */
|
||||
OBJECTS_NO_STRING_NAME, /* maximum length of an object name */
|
||||
_Message_queue_MP_Send_extract_proxy
|
||||
/* Proxy extraction support callout */
|
||||
);
|
||||
|
||||
@@ -36,8 +36,7 @@ static void _Partition_Manager_initialization(void)
|
||||
Configuration_RTEMS_API.maximum_partitions,
|
||||
/* maximum objects of this class */
|
||||
sizeof( Partition_Control ), /* size of this object's control block */
|
||||
false, /* true if the name is a string */
|
||||
RTEMS_MAXIMUM_NAME_LENGTH, /* maximum length of an object name */
|
||||
OBJECTS_NO_STRING_NAME, /* maximum length of an object name */
|
||||
_Partition_MP_Send_extract_proxy /* Proxy extraction support callout */
|
||||
);
|
||||
|
||||
|
||||
@@ -36,8 +36,7 @@ static void _Rate_monotonic_Manager_initialization(void)
|
||||
Configuration_RTEMS_API.maximum_periods,
|
||||
/* maximum objects of this class */
|
||||
sizeof( Rate_monotonic_Control ),/* size of this object's control block */
|
||||
false, /* true if the name is a string */
|
||||
RTEMS_MAXIMUM_NAME_LENGTH, /* maximum length of an object name */
|
||||
OBJECTS_NO_STRING_NAME, /* maximum length of an object name */
|
||||
NULL /* Proxy extraction support callout */
|
||||
);
|
||||
}
|
||||
|
||||
@@ -47,8 +47,7 @@ static void _Region_Manager_initialization(void)
|
||||
Configuration_RTEMS_API.maximum_regions,
|
||||
/* maximum objects of this class */
|
||||
sizeof( Region_Control ), /* size of this object's control block */
|
||||
false, /* true if the name is a string */
|
||||
RTEMS_MAXIMUM_NAME_LENGTH, /* maximum length of an object name */
|
||||
OBJECTS_NO_STRING_NAME, /* maximum length of an object name */
|
||||
NULL /* Proxy extraction support callout */
|
||||
);
|
||||
}
|
||||
|
||||
@@ -38,8 +38,7 @@ static void _Timer_Manager_initialization(void)
|
||||
Configuration_RTEMS_API.maximum_timers ,
|
||||
/* maximum objects of this class */
|
||||
sizeof( Timer_Control ), /* size of this object's control block */
|
||||
false, /* true if the name is a string */
|
||||
RTEMS_MAXIMUM_NAME_LENGTH, /* maximum length of an object name */
|
||||
OBJECTS_NO_STRING_NAME, /* maximum length of an object name */
|
||||
NULL /* Proxy extraction support callout */
|
||||
);
|
||||
}
|
||||
|
||||
@@ -33,8 +33,7 @@ static void _Semaphore_Manager_initialization(void)
|
||||
Configuration_RTEMS_API.maximum_semaphores,
|
||||
/* maximum objects of this class */
|
||||
sizeof( Semaphore_Control ), /* size of this object's control block */
|
||||
false, /* true if the name is a string */
|
||||
RTEMS_MAXIMUM_NAME_LENGTH, /* maximum length of an object name */
|
||||
OBJECTS_NO_STRING_NAME, /* maximum length of an object name */
|
||||
_Semaphore_MP_Send_extract_proxy /* Proxy extraction support callout */
|
||||
);
|
||||
|
||||
|
||||
@@ -35,8 +35,7 @@ static void _Extension_Manager_initialization(void)
|
||||
OBJECTS_RTEMS_EXTENSIONS,
|
||||
rtems_configuration_get_maximum_extensions(),
|
||||
sizeof( Extension_Control ),
|
||||
false, /* true if the name is a string */
|
||||
RTEMS_MAXIMUM_NAME_LENGTH, /* maximum length of an object name */
|
||||
OBJECTS_NO_STRING_NAME, /* maximum length of an object name */
|
||||
NULL /* Proxy extraction support callout */
|
||||
);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ char *_Objects_Get_name_as_string(
|
||||
|
||||
_Objects_Name_to_string(
|
||||
the_object->name,
|
||||
information->is_string,
|
||||
_Objects_Has_string_name( information ),
|
||||
name,
|
||||
length
|
||||
);
|
||||
|
||||
@@ -40,7 +40,7 @@ Objects_Name_or_id_lookup_errors _Objects_Id_to_name (
|
||||
if ( !information )
|
||||
return OBJECTS_INVALID_ID;
|
||||
|
||||
if ( information->is_string )
|
||||
if ( _Objects_Has_string_name( information ) )
|
||||
return OBJECTS_INVALID_ID;
|
||||
|
||||
the_object = _Objects_Get(
|
||||
|
||||
@@ -30,8 +30,7 @@ void _Objects_Do_initialize_information(
|
||||
uint16_t the_class,
|
||||
uint32_t maximum,
|
||||
uint16_t size,
|
||||
bool is_string,
|
||||
uint32_t maximum_name_length
|
||||
uint16_t maximum_name_length
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
,
|
||||
Objects_Thread_queue_Extract_callout extract
|
||||
@@ -49,7 +48,6 @@ void _Objects_Do_initialize_information(
|
||||
information->inactive_per_block = 0;
|
||||
information->object_blocks = 0;
|
||||
information->inactive = 0;
|
||||
information->is_string = is_string;
|
||||
|
||||
/*
|
||||
* Set the maximum value to 0. It will be updated when objects are
|
||||
|
||||
@@ -27,7 +27,7 @@ void _Objects_Namespace_remove_u32(
|
||||
Objects_Control *the_object
|
||||
)
|
||||
{
|
||||
_Assert( !information->is_string );
|
||||
_Assert( !_Objects_Has_string_name( information ) );
|
||||
the_object->name.name_u32 = 0;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ void _Objects_Namespace_remove_string(
|
||||
{
|
||||
char *name;
|
||||
|
||||
_Assert( information->is_string );
|
||||
_Assert( _Objects_Has_string_name( information ) );
|
||||
name = RTEMS_DECONST( char *, the_object->name.name_p );
|
||||
the_object->name.name_p = NULL;
|
||||
_Workspace_Free( name );
|
||||
|
||||
@@ -33,7 +33,7 @@ Objects_Control *_Objects_Get_by_name(
|
||||
size_t max_name_length;
|
||||
uint32_t index;
|
||||
|
||||
_Assert( information->is_string );
|
||||
_Assert( _Objects_Has_string_name( information ) );
|
||||
_Assert( _Objects_Allocator_is_owner() );
|
||||
|
||||
if ( name == NULL ) {
|
||||
|
||||
@@ -29,32 +29,33 @@ bool _Objects_Set_name(
|
||||
const char *name
|
||||
)
|
||||
{
|
||||
size_t length;
|
||||
const char *s;
|
||||
if ( _Objects_Has_string_name( information ) ) {
|
||||
size_t length;
|
||||
char *dup;
|
||||
|
||||
s = name;
|
||||
length = strnlen( name, information->name_length );
|
||||
|
||||
if ( information->is_string ) {
|
||||
char *d;
|
||||
|
||||
d = _Workspace_Allocate( length + 1 );
|
||||
if ( !d )
|
||||
length = strnlen( name, information->name_length );
|
||||
dup = _Workspace_String_duplicate( name, length );
|
||||
if ( dup == NULL ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
_Workspace_Free( (void *)the_object->name.name_p );
|
||||
the_object->name.name_p = NULL;
|
||||
|
||||
strncpy( d, name, length );
|
||||
d[length] = '\0';
|
||||
the_object->name.name_p = d;
|
||||
the_object->name.name_p = dup;
|
||||
} else {
|
||||
the_object->name.name_u32 = _Objects_Build_name(
|
||||
((length) ? s[ 0 ] : ' '),
|
||||
((length > 1) ? s[ 1 ] : ' '),
|
||||
((length > 2) ? s[ 2 ] : ' '),
|
||||
((length > 3) ? s[ 3 ] : ' ')
|
||||
);
|
||||
char c[ 4 ];
|
||||
size_t i;
|
||||
|
||||
memset( c, ' ', sizeof( c ) );
|
||||
|
||||
for ( i = 0; i < 4; ++i ) {
|
||||
if ( name[ i ] == '\0') {
|
||||
break;
|
||||
}
|
||||
|
||||
c[ i ] = name[ i ];
|
||||
}
|
||||
|
||||
the_object->name.name_u32 =
|
||||
_Objects_Build_name( c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ] );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -58,8 +58,7 @@ void _Thread_Initialize_information(
|
||||
the_class,
|
||||
maximum,
|
||||
_Thread_Control_size,
|
||||
false,
|
||||
RTEMS_MAXIMUM_NAME_LENGTH,
|
||||
OBJECTS_NO_STRING_NAME,
|
||||
NULL
|
||||
);
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ rtems_task Init(
|
||||
4, /* the_class */
|
||||
0, /* maximum */
|
||||
4, /* size */
|
||||
true, /* is_string */
|
||||
10, /* maximum_name_length */
|
||||
NULL /* Objects_Thread_queue_Extract_callout extract */
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user