[rtems commit] score: Remove _Objects_Open()

Sebastian Huber sebh at rtems.org
Wed Feb 24 09:47:56 UTC 2021


Module:    rtems
Branch:    master
Commit:    0b263b0eb7dd05efe44359b9d8172926856badc7
Changeset: http://git.rtems.org/rtems/commit/?id=0b263b0eb7dd05efe44359b9d8172926856badc7

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Sun Feb 21 10:47:36 2021 +0100

score: Remove _Objects_Open()

Use the type safe _Objects_Open_u32() instead.  Return the object
identifier to enforce a common usage pattern.

---

 cpukit/include/rtems/score/objectimpl.h | 60 ++++++++++++---------------------
 cpukit/include/rtems/score/threadimpl.h |  4 +--
 cpukit/rtems/src/barriercreate.c        |  9 +----
 cpukit/rtems/src/dpmemcreate.c          |  6 ++--
 cpukit/rtems/src/msgqconstruct.c        |  6 ++--
 cpukit/rtems/src/partcreate.c           |  5 ++-
 cpukit/rtems/src/ratemoncreate.c        |  6 ++--
 cpukit/rtems/src/regioncreate.c         |  5 ++-
 cpukit/rtems/src/semcreate.c            |  6 ++--
 cpukit/rtems/src/taskconstruct.c        |  2 +-
 cpukit/rtems/src/timercreate.c          |  6 ++--
 cpukit/sapi/src/extensioncreate.c       |  6 ++--
 cpukit/score/src/mpci.c                 |  2 +-
 cpukit/score/src/threadcreateidle.c     |  2 +-
 cpukit/score/src/threadinitialize.c     |  5 +--
 15 files changed, 44 insertions(+), 86 deletions(-)

diff --git a/cpukit/include/rtems/score/objectimpl.h b/cpukit/include/rtems/score/objectimpl.h
index 1a0029b..8ba8189 100644
--- a/cpukit/include/rtems/score/objectimpl.h
+++ b/cpukit/include/rtems/score/objectimpl.h
@@ -738,50 +738,27 @@ RTEMS_INLINE_ROUTINE void _Objects_Invalidate_Id(
 }
 
 /**
- * @brief Places the_object control pointer and object name
- *      in the Local Pointer and Local Name Tables, respectively.
+ * @brief Assigns the 32-bit unsigned integer name to the object and places the
+ *   object in the local object table.
  *
- * This method uses Objects_Name for the object name.
+ * @param information is the object information.
  *
- * @param[in, out] information Points to an Object Information Table.
- * @param the_object Pointer to an object.
- * @param name The name of the object to make accessible.
- */
-RTEMS_INLINE_ROUTINE void _Objects_Open(
-  Objects_Information *information,
-  Objects_Control     *the_object,
-  Objects_Name         name
-)
-{
-  _Assert( information != NULL );
-  _Assert( the_object != NULL );
-
-  the_object->name = name;
-
-  _Objects_Set_local_object(
-    information,
-    _Objects_Get_index( the_object->id ),
-    the_object
-  );
-}
-
-/**
- * @brief Places the_object control pointer and object name
- *      in the Local Pointer and Local Name Tables, respectively.
+ * @param[in, out] the_object is the object to open.
  *
- * This method uses uint32_t for the object name.
+ * @param name is the name of the object to open.
  *
- * @param[in, out] information Points to an Object Information Table.
- * @param the_object Pointer to an object.
- * @param name The name of the object to make accessible.
+ * @return Returns the identifier of the object which is now valid.
  */
-RTEMS_INLINE_ROUTINE void _Objects_Open_u32(
+RTEMS_INLINE_ROUTINE Objects_Id _Objects_Open_u32(
   const Objects_Information *information,
   Objects_Control           *the_object,
   uint32_t                   name
 )
 {
+  _Assert( information != NULL );
   _Assert( !_Objects_Has_string_name( information ) );
+  _Assert( the_object != NULL );
+
   the_object->name.name_u32 = name;
 
   _Objects_Set_local_object(
@@ -789,17 +766,19 @@ RTEMS_INLINE_ROUTINE void _Objects_Open_u32(
     _Objects_Get_index( the_object->id ),
     the_object
   );
+
+  return the_object->id;
 }
 
 /**
- * @brief Places the_object control pointer and object name
- *      in the Local Pointer and Local Name Tables, respectively.
+ * @brief Assigns the string name to the object and places the object in the
+ *   local object table.
  *
- * This method uses a String for the object name.
+ * @param information is the object information.
  *
- * @param[in, out] information Points to an Object Information Table.
- * @param the_object Pointer to an object.
- * @param name The name of the object to make accessible.
+ * @param[in, out] the_object is the object to open.
+ *
+ * @param name is the name of the object to open.
  */
 RTEMS_INLINE_ROUTINE void _Objects_Open_string(
   const Objects_Information *information,
@@ -807,7 +786,10 @@ RTEMS_INLINE_ROUTINE void _Objects_Open_string(
   const char                *name
 )
 {
+  _Assert( information != NULL );
   _Assert( _Objects_Has_string_name( information ) );
+  _Assert( the_object != NULL );
+
   the_object->name.name_p = name;
 
   _Objects_Set_local_object(
diff --git a/cpukit/include/rtems/score/threadimpl.h b/cpukit/include/rtems/score/threadimpl.h
index e9d4452..0c7df47 100644
--- a/cpukit/include/rtems/score/threadimpl.h
+++ b/cpukit/include/rtems/score/threadimpl.h
@@ -164,9 +164,9 @@ typedef struct {
   Thread_CPU_budget_algorithm_callout budget_callout;
 
   /**
-   * @brief Name of the object for the thread.
+   * @brief 32-bit unsigned integer name of the object for the thread.
    */
-  Objects_Name name;
+  uint32_t name;
 
   /**
    * @brief The thread's initial ISR level.
diff --git a/cpukit/rtems/src/barriercreate.c b/cpukit/rtems/src/barriercreate.c
index 6e6b294..99d916d 100644
--- a/cpukit/rtems/src/barriercreate.c
+++ b/cpukit/rtems/src/barriercreate.c
@@ -63,14 +63,7 @@ rtems_status_code rtems_barrier_create(
 
   _CORE_barrier_Initialize( &the_barrier->Barrier, &the_attributes );
 
-  _Objects_Open(
-    &_Barrier_Information,
-    &the_barrier->Object,
-    (Objects_Name) name
-  );
-
-  *id = the_barrier->Object.id;
-
+  *id = _Objects_Open_u32( &_Barrier_Information, &the_barrier->Object, name );
   _Objects_Allocator_unlock();
   return RTEMS_SUCCESSFUL;
 }
diff --git a/cpukit/rtems/src/dpmemcreate.c b/cpukit/rtems/src/dpmemcreate.c
index bc14de1..eba3a52 100644
--- a/cpukit/rtems/src/dpmemcreate.c
+++ b/cpukit/rtems/src/dpmemcreate.c
@@ -59,13 +59,11 @@ rtems_status_code rtems_port_create(
   the_port->external_base = external_start;
   the_port->length        = length - 1;
 
-  _Objects_Open(
+  *id = _Objects_Open_u32(
     &_Dual_ported_memory_Information,
     &the_port->Object,
-    (Objects_Name) name
+    name
   );
-
-  *id = the_port->Object.id;
   _Objects_Allocator_unlock();
   return RTEMS_SUCCESSFUL;
 }
diff --git a/cpukit/rtems/src/msgqconstruct.c b/cpukit/rtems/src/msgqconstruct.c
index a8a50e9..6cada4c 100644
--- a/cpukit/rtems/src/msgqconstruct.c
+++ b/cpukit/rtems/src/msgqconstruct.c
@@ -158,14 +158,12 @@ rtems_status_code _Message_queue_Create(
     return _Status_Get( status );
   }
 
-  _Objects_Open(
+  *id = _Objects_Open_u32(
     &_Message_queue_Information,
     &the_message_queue->Object,
-    (Objects_Name) config->name
+    config->name
   );
 
-  *id = the_message_queue->Object.id;
-
 #if defined(RTEMS_MULTIPROCESSING)
   if ( is_global )
     _Message_queue_MP_Send_process_packet(
diff --git a/cpukit/rtems/src/partcreate.c b/cpukit/rtems/src/partcreate.c
index 205a316..012a416 100644
--- a/cpukit/rtems/src/partcreate.c
+++ b/cpukit/rtems/src/partcreate.c
@@ -138,13 +138,12 @@ rtems_status_code rtems_partition_create(
     attribute_set
   );
 
-  _Objects_Open(
+  *id = _Objects_Open_u32(
     &_Partition_Information,
     &the_partition->Object,
-    (Objects_Name) name
+    name
   );
 
-  *id = the_partition->Object.id;
 #if defined(RTEMS_MULTIPROCESSING)
   if ( _Attributes_Is_global( attribute_set ) )
     _Partition_MP_Send_process_packet(
diff --git a/cpukit/rtems/src/ratemoncreate.c b/cpukit/rtems/src/ratemoncreate.c
index 09f7806..cd56a13 100644
--- a/cpukit/rtems/src/ratemoncreate.c
+++ b/cpukit/rtems/src/ratemoncreate.c
@@ -60,13 +60,11 @@ rtems_status_code rtems_rate_monotonic_create(
 
   _Rate_monotonic_Reset_statistics( the_period );
 
-  _Objects_Open(
+  *id = _Objects_Open_u32(
     &_Rate_monotonic_Information,
     &the_period->Object,
-    (Objects_Name) name
+    name
   );
-
-  *id = the_period->Object.id;
   _Objects_Allocator_unlock();
   return RTEMS_SUCCESSFUL;
 }
diff --git a/cpukit/rtems/src/regioncreate.c b/cpukit/rtems/src/regioncreate.c
index d05d37a..112cac2 100644
--- a/cpukit/rtems/src/regioncreate.c
+++ b/cpukit/rtems/src/regioncreate.c
@@ -75,13 +75,12 @@ rtems_status_code rtems_region_create(
       } else {
         the_region->attribute_set = attribute_set;
 
-        _Objects_Open(
+        *id = _Objects_Open_u32(
           &_Region_Information,
           &the_region->Object,
-          (Objects_Name) name
+          name
         );
 
-        *id = the_region->Object.id;
         return_status = RTEMS_SUCCESSFUL;
       }
     }
diff --git a/cpukit/rtems/src/semcreate.c b/cpukit/rtems/src/semcreate.c
index 20c2c71..3647bb7 100644
--- a/cpukit/rtems/src/semcreate.c
+++ b/cpukit/rtems/src/semcreate.c
@@ -245,14 +245,12 @@ rtems_status_code rtems_semaphore_create(
    *  Whether we initialized it as a mutex or counting semaphore, it is
    *  now ready to be "offered" for use as a Classic API Semaphore.
    */
-  _Objects_Open(
+  *id = _Objects_Open_u32(
     &_Semaphore_Information,
     &the_semaphore->Object,
-    (Objects_Name) name
+    name
   );
 
-  *id = the_semaphore->Object.id;
-
 #if defined(RTEMS_MULTIPROCESSING)
   if ( _Attributes_Is_global( attribute_set ) )
     _Semaphore_MP_Send_process_packet(
diff --git a/cpukit/rtems/src/taskconstruct.c b/cpukit/rtems/src/taskconstruct.c
index d33a850..799554c 100644
--- a/cpukit/rtems/src/taskconstruct.c
+++ b/cpukit/rtems/src/taskconstruct.c
@@ -135,7 +135,7 @@ rtems_status_code _RTEMS_tasks_Create(
     THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE
       : THREAD_CPU_BUDGET_ALGORITHM_NONE,
   thread_config.isr_level =  _Modes_Get_interrupt_level( config->initial_modes );
-  thread_config.name.name_u32 = config->name;
+  thread_config.name = config->name;
   thread_config.is_fp = _Attributes_Is_floating_point( attributes );
   thread_config.is_preemptible = _Modes_Is_preempt( config->initial_modes );
 
diff --git a/cpukit/rtems/src/timercreate.c b/cpukit/rtems/src/timercreate.c
index ce143f5..a3ece5c 100644
--- a/cpukit/rtems/src/timercreate.c
+++ b/cpukit/rtems/src/timercreate.c
@@ -209,13 +209,11 @@ rtems_status_code rtems_timer_create(
   the_timer->the_class = TIMER_DORMANT;
   _Watchdog_Preinitialize( &the_timer->Ticker, _Per_CPU_Get_snapshot() );
 
-  _Objects_Open(
+  *id = _Objects_Open_u32(
     &_Timer_Information,
     &the_timer->Object,
-    (Objects_Name) name
+    name
   );
-
-  *id = the_timer->Object.id;
   _Objects_Allocator_unlock();
   return RTEMS_SUCCESSFUL;
 }
diff --git a/cpukit/sapi/src/extensioncreate.c b/cpukit/sapi/src/extensioncreate.c
index 73ea91a..383ca66 100644
--- a/cpukit/sapi/src/extensioncreate.c
+++ b/cpukit/sapi/src/extensioncreate.c
@@ -55,13 +55,11 @@ rtems_status_code rtems_extension_create(
 
   _User_extensions_Add_set_with_table( &the_extension->Extension, extension_table );
 
-  _Objects_Open(
+  *id = _Objects_Open_u32(
     &_Extension_Information,
     &the_extension->Object,
-    (Objects_Name) name
+    name
   );
-
-  *id = the_extension->Object.id;
   _Objects_Allocator_unlock();
   return RTEMS_SUCCESSFUL;
 }
diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c
index a181553..91d0eb0 100644
--- a/cpukit/score/src/mpci.c
+++ b/cpukit/score/src/mpci.c
@@ -142,7 +142,7 @@ static void _MPCI_Create_server( void )
 
   memset( &config, 0, sizeof( config ) );
   config.scheduler = &_Scheduler_Table[ 0 ];
-  config.name.name_u32 = _Objects_Build_name( 'M', 'P', 'C', 'I' );
+  config.name = _Objects_Build_name( 'M', 'P', 'C', 'I' );
   config.priority = PRIORITY_PSEUDO_ISR;
   config.budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_NONE;
   config.is_fp = CPU_ALL_TASKS_ARE_FP;
diff --git a/cpukit/score/src/threadcreateidle.c b/cpukit/score/src/threadcreateidle.c
index 50114b8..04a103c 100644
--- a/cpukit/score/src/threadcreateidle.c
+++ b/cpukit/score/src/threadcreateidle.c
@@ -50,7 +50,7 @@ static void _Thread_Create_idle_for_CPU( Per_CPU_Control *cpu )
     config.scheduler->maximum_priority
   );
   config.budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_NONE;
-  config.name.name_u32 = _Objects_Build_name( 'I', 'D', 'L', 'E' );
+  config.name = _Objects_Build_name( 'I', 'D', 'L', 'E' );
   config.is_fp = CPU_IDLE_TASK_IS_FP;
   config.is_preemptible = true;
   config.stack_size = _Thread_Idle_stack_size
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index 05c30c3..10eb0d7 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -241,10 +241,7 @@ bool _Thread_Initialize(
 
   _Thread_Action_control_initialize( &the_thread->Post_switch_actions );
 
-  /*
-   *  Open the object
-   */
-  _Objects_Open( &information->Objects, &the_thread->Object, config->name );
+  _Objects_Open_u32( &information->Objects, &the_thread->Object, config->name );
 
   /*
    *  We assume the Allocator Mutex is locked and dispatching is



More information about the vc mailing list