mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-02 06:57:24 +08:00
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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user