From 61357479894b08c9017ba39f90572c57dc307869 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 16 Dec 2019 14:50:59 +0100 Subject: score: Split up objects free Split up the different objects free methods into separate functions. This helps to avoid a dependency on the workspace in case no objects or a static set of objects is configured. Update #3835. --- cpukit/include/rtems/score/objectimpl.h | 103 +++++++++++++++++--------------- 1 file changed, 54 insertions(+), 49 deletions(-) (limited to 'cpukit/include/rtems/score/objectimpl.h') diff --git a/cpukit/include/rtems/score/objectimpl.h b/cpukit/include/rtems/score/objectimpl.h index a2548dd980..c683e6b800 100644 --- a/cpukit/include/rtems/score/objectimpl.h +++ b/cpukit/include/rtems/score/objectimpl.h @@ -187,55 +187,6 @@ unsigned int _Objects_API_maximum_class( */ Objects_Control *_Objects_Allocate( Objects_Information *information ); -/** - * @brief Frees an object. - * - * Appends the object to the chain of inactive objects. - * - * @param information The object information block. - * @param[out] the_object The object to free. - * - * @see _Objects_Allocate(). - * - * A typical object deletion code looks like this: - * @code - * rtems_status_code some_delete( rtems_id id ) - * { - * Some_Control *some; - * - * // The object allocator mutex protects the executing thread from - * // asynchronous thread restart and deletion. - * _Objects_Allocator_lock(); - * - * // Get the object under protection of the object allocator mutex. - * some = (Semaphore_Control *) - * _Objects_Get_no_protection( id, &_Some_Information ); - * - * if ( some == NULL ) { - * _Objects_Allocator_unlock(); - * return RTEMS_INVALID_ID; - * } - * - * // After the object close an object get with this identifier will - * // fail. - * _Objects_Close( &_Some_Information, &some->Object ); - * - * _Some_Delete( some ); - * - * // Thread dispatching is enabled. The object free is only protected - * // by the object allocator mutex. - * _Objects_Free( &_Some_Information, &some->Object ); - * - * _Objects_Allocator_unlock(); - * return RTEMS_SUCCESSFUL; - * } - * @endcode - */ -void _Objects_Free( - Objects_Information *information, - Objects_Control *the_object -); - /** * This function implements the common portion of the object * identification directives. This directive returns the object @@ -925,6 +876,60 @@ RTEMS_INLINE_ROUTINE Objects_Control *_Objects_Allocate_unprotected( return ( *information->allocate )( information ); } +/** + * @brief Frees an object. + * + * Appends the object to the chain of inactive objects. + * + * @param information The object information block. + * @param[out] the_object The object to free. + * + * @see _Objects_Allocate(). + * + * A typical object deletion code looks like this: + * @code + * rtems_status_code some_delete( rtems_id id ) + * { + * Some_Control *some; + * + * // The object allocator mutex protects the executing thread from + * // asynchronous thread restart and deletion. + * _Objects_Allocator_lock(); + * + * // Get the object under protection of the object allocator mutex. + * some = (Semaphore_Control *) + * _Objects_Get_no_protection( id, &_Some_Information ); + * + * if ( some == NULL ) { + * _Objects_Allocator_unlock(); + * return RTEMS_INVALID_ID; + * } + * + * // After the object close an object get with this identifier will + * // fail. + * _Objects_Close( &_Some_Information, &some->Object ); + * + * _Some_Delete( some ); + * + * // Thread dispatching is enabled. The object free is only protected + * // by the object allocator mutex. + * _Objects_Free( &_Some_Information, &some->Object ); + * + * _Objects_Allocator_unlock(); + * return RTEMS_SUCCESSFUL; + * } + * @endcode + */ +RTEMS_INLINE_ROUTINE void _Objects_Free( + Objects_Information *information, + Objects_Control *the_object +) +{ + _Assert( _Objects_Allocator_is_owner() ); + _Assert( information->free != NULL ); + ( *information->free )( information, the_object ); +} + /** @} */ #ifdef __cplusplus -- cgit v1.2.3