[rtems commit] rtems: Simplify rtems_semaphore_delete()

Sebastian Huber sebh at rtems.org
Mon May 30 14:17:58 UTC 2016


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri May 27 09:41:18 2016 +0200

rtems: Simplify rtems_semaphore_delete()

Due to the unified status codes, we can now use a common flush and
destroy method for semaphore and mutex variants.

---

 cpukit/rtems/src/semdelete.c                     | 17 ++++++-----------
 cpukit/score/include/rtems/score/coremuteximpl.h | 14 --------------
 cpukit/score/include/rtems/score/coresemimpl.h   | 14 --------------
 3 files changed, 6 insertions(+), 39 deletions(-)

diff --git a/cpukit/rtems/src/semdelete.c b/cpukit/rtems/src/semdelete.c
index 908c178..34da496b 100644
--- a/cpukit/rtems/src/semdelete.c
+++ b/cpukit/rtems/src/semdelete.c
@@ -84,14 +84,6 @@ rtems_status_code rtems_semaphore_delete(
   _Objects_Close( &_Semaphore_Information, &the_semaphore->Object );
 
   switch ( the_semaphore->variant ) {
-    case SEMAPHORE_VARIANT_MUTEX:
-      _CORE_mutex_Flush(
-        &the_semaphore->Core_control.mutex,
-        _Thread_queue_Flush_status_object_was_deleted,
-        &queue_context
-      );
-      _CORE_mutex_Destroy( &the_semaphore->Core_control.mutex );
-      break;
 #if defined(RTEMS_SMP)
     case SEMAPHORE_VARIANT_MRSP:
       _MRSP_Destroy( &the_semaphore->Core_control.mrsp, &queue_context );
@@ -99,14 +91,17 @@ rtems_status_code rtems_semaphore_delete(
 #endif
     default:
       _Assert(
-        the_semaphore->variant == SEMAPHORE_VARIANT_SIMPLE_BINARY
+        the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX
+          || the_semaphore->variant == SEMAPHORE_VARIANT_SIMPLE_BINARY
           || the_semaphore->variant == SEMAPHORE_VARIANT_COUNTING
       );
-      _CORE_semaphore_Destroy(
-        &the_semaphore->Core_control.semaphore,
+      _Thread_queue_Flush_critical(
+        &the_semaphore->Core_control.Wait_queue.Queue,
         _Semaphore_Get_operations( the_semaphore ),
+        _Thread_queue_Flush_status_object_was_deleted,
         &queue_context
       );
+      _Thread_queue_Destroy( &the_semaphore->Core_control.Wait_queue );
       break;
   }
 
diff --git a/cpukit/score/include/rtems/score/coremuteximpl.h b/cpukit/score/include/rtems/score/coremuteximpl.h
index ccc4148..f8869b0 100644
--- a/cpukit/score/include/rtems/score/coremuteximpl.h
+++ b/cpukit/score/include/rtems/score/coremuteximpl.h
@@ -314,20 +314,6 @@ Status_Control _CORE_mutex_Surrender(
   Thread_queue_Context *queue_context
 );
 
-RTEMS_INLINE_ROUTINE void _CORE_mutex_Flush(
-  CORE_mutex_Control        *the_mutex,
-  Thread_queue_Flush_filter  filter,
-  Thread_queue_Context      *queue_context
-)
-{
-  _Thread_queue_Flush_critical(
-    &the_mutex->Wait_queue.Queue,
-    the_mutex->operations,
-    filter,
-    queue_context
-  );
-}
-
 RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_owner(
   const CORE_mutex_Control *the_mutex,
   const Thread_Control     *the_thread
diff --git a/cpukit/score/include/rtems/score/coresemimpl.h b/cpukit/score/include/rtems/score/coresemimpl.h
index 24d8c51..487a91b 100644
--- a/cpukit/score/include/rtems/score/coresemimpl.h
+++ b/cpukit/score/include/rtems/score/coresemimpl.h
@@ -141,20 +141,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Surrender(
   return status;
 }
 
-RTEMS_INLINE_ROUTINE void _CORE_semaphore_Flush(
-  CORE_semaphore_Control        *the_semaphore,
-  const Thread_queue_Operations *operations,
-  Thread_queue_Context          *queue_context
-)
-{
-  _Thread_queue_Flush_critical(
-    &the_semaphore->Wait_queue.Queue,
-    operations,
-    _Thread_queue_Flush_status_unavailable,
-    queue_context
-  );
-}
-
 /**
  * This routine returns the current count associated with the semaphore.
  *



More information about the vc mailing list