[PATCH 2/7] score: Remove Objects_Information::is_string
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Nov 26 13:12:09 UTC 2018
Use Objects_Information::name_length to store this information.
Update #3621.
---
cpukit/include/rtems/score/objectimpl.h | 33 +++++++++++++-------
cpukit/posix/src/key.c | 3 +-
cpukit/posix/src/mqueue.c | 1 -
cpukit/posix/src/psxsemaphore.c | 1 -
cpukit/posix/src/ptimer.c | 3 +-
cpukit/posix/src/shm.c | 1 -
cpukit/rtems/src/barrier.c | 3 +-
cpukit/rtems/src/dpmem.c | 3 +-
cpukit/rtems/src/msg.c | 3 +-
cpukit/rtems/src/part.c | 3 +-
cpukit/rtems/src/ratemon.c | 3 +-
cpukit/rtems/src/region.c | 3 +-
cpukit/rtems/src/rtemstimer.c | 3 +-
cpukit/rtems/src/sem.c | 3 +-
cpukit/sapi/src/extension.c | 3 +-
cpukit/score/src/objectgetnameasstring.c | 2 +-
cpukit/score/src/objectidtoname.c | 2 +-
cpukit/score/src/objectinitializeinformation.c | 4 +--
cpukit/score/src/objectnamespaceremove.c | 4 +--
cpukit/score/src/objectnametoidstring.c | 2 +-
cpukit/score/src/objectsetname.c | 43 +++++++++++++-------------
cpukit/score/src/thread.c | 3 +-
testsuites/psxtests/psxobj01/init.c | 1 -
23 files changed, 62 insertions(+), 68 deletions(-)
diff --git a/cpukit/include/rtems/score/objectimpl.h b/cpukit/include/rtems/score/objectimpl.h
index 8934e24244..4141183176 100644
--- a/cpukit/include/rtems/score/objectimpl.h
+++ b/cpukit/include/rtems/score/objectimpl.h
@@ -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(
diff --git a/cpukit/posix/src/key.c b/cpukit/posix/src/key.c
index 71c202926e..a39e8d6479 100644
--- a/cpukit/posix/src/key.c
+++ b/cpukit/posix/src/key.c
@@ -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 */
);
diff --git a/cpukit/posix/src/mqueue.c b/cpukit/posix/src/mqueue.c
index e2c9b5f2b2..192d853c35 100644
--- a/cpukit/posix/src/mqueue.c
+++ b/cpukit/posix/src/mqueue.c
@@ -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 */
);
diff --git a/cpukit/posix/src/psxsemaphore.c b/cpukit/posix/src/psxsemaphore.c
index 9e259b8ea3..a26ba7563e 100644
--- a/cpukit/posix/src/psxsemaphore.c
+++ b/cpukit/posix/src/psxsemaphore.c
@@ -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 */
);
diff --git a/cpukit/posix/src/ptimer.c b/cpukit/posix/src/ptimer.c
index 9472cd49e5..f3af1710b8 100644
--- a/cpukit/posix/src/ptimer.c
+++ b/cpukit/posix/src/ptimer.c
@@ -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 */
);
}
diff --git a/cpukit/posix/src/shm.c b/cpukit/posix/src/shm.c
index 131aa1384b..5030a9376e 100644
--- a/cpukit/posix/src/shm.c
+++ b/cpukit/posix/src/shm.c
@@ -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 */
);
diff --git a/cpukit/rtems/src/barrier.c b/cpukit/rtems/src/barrier.c
index a2912389e9..59b0a5d142 100644
--- a/cpukit/rtems/src/barrier.c
+++ b/cpukit/rtems/src/barrier.c
@@ -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 */
);
}
diff --git a/cpukit/rtems/src/dpmem.c b/cpukit/rtems/src/dpmem.c
index 2522a59951..ccecdfd6cc 100644
--- a/cpukit/rtems/src/dpmem.c
+++ b/cpukit/rtems/src/dpmem.c
@@ -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 */
);
}
diff --git a/cpukit/rtems/src/msg.c b/cpukit/rtems/src/msg.c
index 44a0727ea4..8060735beb 100644
--- a/cpukit/rtems/src/msg.c
+++ b/cpukit/rtems/src/msg.c
@@ -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 */
);
diff --git a/cpukit/rtems/src/part.c b/cpukit/rtems/src/part.c
index 4df676ed7a..d395f34342 100644
--- a/cpukit/rtems/src/part.c
+++ b/cpukit/rtems/src/part.c
@@ -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 */
);
diff --git a/cpukit/rtems/src/ratemon.c b/cpukit/rtems/src/ratemon.c
index dd3ca29cdd..a8681dda44 100644
--- a/cpukit/rtems/src/ratemon.c
+++ b/cpukit/rtems/src/ratemon.c
@@ -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 */
);
}
diff --git a/cpukit/rtems/src/region.c b/cpukit/rtems/src/region.c
index 892c680f15..4fbce63160 100644
--- a/cpukit/rtems/src/region.c
+++ b/cpukit/rtems/src/region.c
@@ -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 */
);
}
diff --git a/cpukit/rtems/src/rtemstimer.c b/cpukit/rtems/src/rtemstimer.c
index d60e4a9b48..f0a8c672fa 100644
--- a/cpukit/rtems/src/rtemstimer.c
+++ b/cpukit/rtems/src/rtemstimer.c
@@ -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 */
);
}
diff --git a/cpukit/rtems/src/sem.c b/cpukit/rtems/src/sem.c
index 74ce661725..e91e2d14bf 100644
--- a/cpukit/rtems/src/sem.c
+++ b/cpukit/rtems/src/sem.c
@@ -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 */
);
diff --git a/cpukit/sapi/src/extension.c b/cpukit/sapi/src/extension.c
index 9c496832ab..70246048a4 100644
--- a/cpukit/sapi/src/extension.c
+++ b/cpukit/sapi/src/extension.c
@@ -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 */
);
}
diff --git a/cpukit/score/src/objectgetnameasstring.c b/cpukit/score/src/objectgetnameasstring.c
index ed6a73c0f8..845334075a 100644
--- a/cpukit/score/src/objectgetnameasstring.c
+++ b/cpukit/score/src/objectgetnameasstring.c
@@ -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
);
diff --git a/cpukit/score/src/objectidtoname.c b/cpukit/score/src/objectidtoname.c
index 85eb409a8e..63948160e6 100644
--- a/cpukit/score/src/objectidtoname.c
+++ b/cpukit/score/src/objectidtoname.c
@@ -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(
diff --git a/cpukit/score/src/objectinitializeinformation.c b/cpukit/score/src/objectinitializeinformation.c
index 23c7819bfa..2105c325d3 100644
--- a/cpukit/score/src/objectinitializeinformation.c
+++ b/cpukit/score/src/objectinitializeinformation.c
@@ -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
diff --git a/cpukit/score/src/objectnamespaceremove.c b/cpukit/score/src/objectnamespaceremove.c
index cc2c954a77..122ed862b7 100644
--- a/cpukit/score/src/objectnamespaceremove.c
+++ b/cpukit/score/src/objectnamespaceremove.c
@@ -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 );
diff --git a/cpukit/score/src/objectnametoidstring.c b/cpukit/score/src/objectnametoidstring.c
index dd69f8a9ea..3bca0441e0 100644
--- a/cpukit/score/src/objectnametoidstring.c
+++ b/cpukit/score/src/objectnametoidstring.c
@@ -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 ) {
diff --git a/cpukit/score/src/objectsetname.c b/cpukit/score/src/objectsetname.c
index 227de515ec..32197a3cf8 100644
--- a/cpukit/score/src/objectsetname.c
+++ b/cpukit/score/src/objectsetname.c
@@ -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 );
+ length = strnlen( name, information->name_length );
+ dup = _Workspace_String_duplicate( name, length );
+ if ( dup == NULL ) {
+ return false;
+ }
- if ( information->is_string ) {
- char *d;
+ the_object->name.name_p = dup;
+ } else {
+ char c[ 4 ];
+ size_t i;
- d = _Workspace_Allocate( length + 1 );
- if ( !d )
- return false;
+ memset( c, ' ', sizeof( c ) );
- _Workspace_Free( (void *)the_object->name.name_p );
- the_object->name.name_p = NULL;
+ for ( i = 0; i < 4; ++i ) {
+ if ( name[ i ] == '\0') {
+ break;
+ }
- strncpy( d, name, length );
- d[length] = '\0';
- the_object->name.name_p = d;
- } else {
- the_object->name.name_u32 = _Objects_Build_name(
- ((length) ? s[ 0 ] : ' '),
- ((length > 1) ? s[ 1 ] : ' '),
- ((length > 2) ? s[ 2 ] : ' '),
- ((length > 3) ? s[ 3 ] : ' ')
- );
+ c[ i ] = name[ i ];
+ }
+
+ the_object->name.name_u32 =
+ _Objects_Build_name( c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ] );
}
return true;
diff --git a/cpukit/score/src/thread.c b/cpukit/score/src/thread.c
index b63a6b14cd..5c27ee00ef 100644
--- a/cpukit/score/src/thread.c
+++ b/cpukit/score/src/thread.c
@@ -58,8 +58,7 @@ void _Thread_Initialize_information(
the_class,
maximum,
_Thread_Control_size,
- false,
- RTEMS_MAXIMUM_NAME_LENGTH,
+ OBJECTS_NO_STRING_NAME,
NULL
);
diff --git a/testsuites/psxtests/psxobj01/init.c b/testsuites/psxtests/psxobj01/init.c
index ca1fbc52ee..52cad3462d 100644
--- a/testsuites/psxtests/psxobj01/init.c
+++ b/testsuites/psxtests/psxobj01/init.c
@@ -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 */
);
--
2.16.4
More information about the devel
mailing list