summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/semdelete.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-20 21:39:56 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-30 16:16:21 +0200
commit2581a563f9182dc2debdba97f33feee6d797e53a (patch)
tree97883371771f9a2905d159d8e11c0b2e9da0408c /cpukit/rtems/src/semdelete.c
parentrtems: Simplify rtems_semaphore_delete() (diff)
downloadrtems-2581a563f9182dc2debdba97f33feee6d797e53a.tar.bz2
score: Add semaphore variants
Diffstat (limited to 'cpukit/rtems/src/semdelete.c')
-rw-r--r--cpukit/rtems/src/semdelete.c68
1 files changed, 39 insertions, 29 deletions
diff --git a/cpukit/rtems/src/semdelete.c b/cpukit/rtems/src/semdelete.c
index 16889cd6b6..45c356f452 100644
--- a/cpukit/rtems/src/semdelete.c
+++ b/cpukit/rtems/src/semdelete.c
@@ -53,22 +53,27 @@ rtems_status_code rtems_semaphore_delete(
&queue_context.Lock_context
);
+ switch ( the_semaphore->variant ) {
+ case SEMAPHORE_VARIANT_MUTEX:
+ if (
+ _CORE_mutex_Is_locked( &the_semaphore->Core_control.mutex )
+ && !_Attributes_Is_simple_binary_semaphore( attribute_set )
+ ) {
+ status = STATUS_RESOURCE_IN_USE;
+ } else {
+ status = STATUS_SUCCESSFUL;
+ }
+
+ break;
#if defined(RTEMS_SMP)
- if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
- status = _MRSP_Can_destroy( &the_semaphore->Core_control.mrsp );
- } else
+ case SEMAPHORE_VARIANT_MRSP:
+ status = _MRSP_Can_destroy( &the_semaphore->Core_control.mrsp );
+ break;
#endif
- if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
- if (
- _CORE_mutex_Is_locked( &the_semaphore->Core_control.mutex )
- && !_Attributes_Is_simple_binary_semaphore( attribute_set )
- ) {
- status = STATUS_RESOURCE_IN_USE;
- } else {
+ default:
+ _Assert( the_semaphore->variant == SEMAPHORE_VARIANT_COUNTING );
status = STATUS_SUCCESSFUL;
- }
- } else {
- status = STATUS_SUCCESSFUL;
+ break;
}
if ( status != STATUS_SUCCESSFUL ) {
@@ -82,27 +87,32 @@ 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)
- if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
- _MRSP_Destroy( &the_semaphore->Core_control.mrsp, &queue_context );
- } else
+ case SEMAPHORE_VARIANT_MRSP:
+ _MRSP_Destroy( &the_semaphore->Core_control.mrsp, &queue_context );
+ break;
#endif
- if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
- _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 );
- } else {
- _CORE_semaphore_Destroy(
- &the_semaphore->Core_control.semaphore,
- &queue_context
- );
+ default:
+ _Assert( the_semaphore->variant == SEMAPHORE_VARIANT_COUNTING );
+ _CORE_semaphore_Destroy(
+ &the_semaphore->Core_control.semaphore,
+ _Semaphore_Get_operations( the_semaphore ),
+ &queue_context
+ );
+ break;
}
#if defined(RTEMS_MULTIPROCESSING)
- if ( _Attributes_Is_global( attribute_set ) ) {
+ if ( the_semaphore->is_global ) {
_Objects_MP_Close( &_Semaphore_Information, id );