summaryrefslogtreecommitdiffstats
path: root/cpukit/include/rtems/score/objectimpl.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/include/rtems/score/objectimpl.h')
-rw-r--r--cpukit/include/rtems/score/objectimpl.h102
1 files changed, 70 insertions, 32 deletions
diff --git a/cpukit/include/rtems/score/objectimpl.h b/cpukit/include/rtems/score/objectimpl.h
index 54db4577bc..a1a87b5ccb 100644
--- a/cpukit/include/rtems/score/objectimpl.h
+++ b/cpukit/include/rtems/score/objectimpl.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
/**
* @file
*
@@ -11,9 +13,26 @@
* COPYRIGHT (c) 1989-2011.
* On-Line Applications Research Corporation (OAR).
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RTEMS_SCORE_OBJECTIMPL_H
@@ -377,7 +396,7 @@ Objects_Information *_Objects_Get_information_id(
* @retval true The object has a string name.
* @retval false The object does not have a string name.
*/
-RTEMS_INLINE_ROUTINE bool _Objects_Has_string_name(
+static inline bool _Objects_Has_string_name(
const Objects_Information *information
)
{
@@ -452,7 +471,7 @@ Status_Control _Objects_Set_name(
* @param information The corresponding object information table.
* @param[out] the_object The object to operate upon.
*/
-RTEMS_INLINE_ROUTINE void _Objects_Namespace_remove_u32(
+static inline void _Objects_Namespace_remove_u32(
const Objects_Information *information,
Objects_Control *the_object
)
@@ -504,7 +523,7 @@ Objects_Maximum _Objects_Active_count(
*
* @return The number of objects per block of @a information.
*/
-RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Extend_size(
+static inline Objects_Maximum _Objects_Extend_size(
const Objects_Information *information
)
{
@@ -519,13 +538,11 @@ RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Extend_size(
* @retval true The specified api value is valid.
* @retval false The specified api value is not valid.
*/
-RTEMS_INLINE_ROUTINE bool _Objects_Is_api_valid(
+static inline bool _Objects_Is_api_valid(
uint32_t the_api
)
{
- if ( !the_api || the_api > OBJECTS_APIS_LAST )
- return false;
- return true;
+ return ( 1 <= the_api && the_api <= OBJECTS_APIS_LAST );
}
/**
@@ -537,7 +554,7 @@ RTEMS_INLINE_ROUTINE bool _Objects_Is_api_valid(
* @retval true The specified node is the local node.
* @retval false The specified node is not the local node.
*/
-RTEMS_INLINE_ROUTINE bool _Objects_Is_local_node(
+static inline bool _Objects_Is_local_node(
uint32_t node
)
{
@@ -554,7 +571,7 @@ RTEMS_INLINE_ROUTINE bool _Objects_Is_local_node(
*
* @note On a single processor configuration, this always returns true.
*/
-RTEMS_INLINE_ROUTINE bool _Objects_Is_local_id(
+static inline bool _Objects_Is_local_id(
#if defined(RTEMS_MULTIPROCESSING)
Objects_Id id
#else
@@ -578,7 +595,7 @@ RTEMS_INLINE_ROUTINE bool _Objects_Is_local_id(
* @retval true The specified object IDs are equal.
* @retval false The specified object IDs are not equal.
*/
-RTEMS_INLINE_ROUTINE bool _Objects_Are_ids_equal(
+static inline bool _Objects_Are_ids_equal(
Objects_Id left,
Objects_Id right
)
@@ -595,7 +612,7 @@ RTEMS_INLINE_ROUTINE bool _Objects_Are_ids_equal(
*
* @return The corresponding ID with the minimum index.
*/
-RTEMS_INLINE_ROUTINE Objects_Id _Objects_Get_minimum_id( Objects_Id id )
+static inline Objects_Id _Objects_Get_minimum_id( Objects_Id id )
{
id &= ~OBJECTS_INDEX_MASK;
id += (Objects_Id) OBJECTS_INDEX_MINIMUM << OBJECTS_INDEX_START_BIT;
@@ -609,7 +626,7 @@ RTEMS_INLINE_ROUTINE Objects_Id _Objects_Get_minimum_id( Objects_Id id )
*
* @return The maximum index of the specified object class.
*/
-RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Get_maximum_index(
+static inline Objects_Maximum _Objects_Get_maximum_index(
const Objects_Information *information
)
{
@@ -622,7 +639,7 @@ RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Get_maximum_index(
* @retval NULL No inactive object is available.
* @retval object An inactive object.
*/
-RTEMS_INLINE_ROUTINE Objects_Control *_Objects_Get_inactive(
+static inline Objects_Control *_Objects_Get_inactive(
Objects_Information *information
)
{
@@ -638,7 +655,7 @@ RTEMS_INLINE_ROUTINE Objects_Control *_Objects_Get_inactive(
* @retval true The automatic object extension (unlimited objects) is enabled.
* @retval false The automatic object extension (unlimited objects) is not enabled.
*/
-RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Is_auto_extend(
+static inline Objects_Maximum _Objects_Is_auto_extend(
const Objects_Information *information
)
{
@@ -659,7 +676,7 @@ RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Is_auto_extend(
* or delete/destroy operations.
*/
-RTEMS_INLINE_ROUTINE void _Objects_Set_local_object(
+static inline void _Objects_Set_local_object(
const Objects_Information *information,
uint32_t index,
Objects_Control *the_object
@@ -692,7 +709,7 @@ RTEMS_INLINE_ROUTINE void _Objects_Set_local_object(
* or delete/destroy operations.
*/
-RTEMS_INLINE_ROUTINE void _Objects_Invalidate_Id(
+static inline void _Objects_Invalidate_Id(
const Objects_Information *information,
Objects_Control *the_object
)
@@ -719,7 +736,7 @@ RTEMS_INLINE_ROUTINE void _Objects_Invalidate_Id(
*
* @return Returns the identifier of the object which is now valid.
*/
-RTEMS_INLINE_ROUTINE Objects_Id _Objects_Open_u32(
+static inline Objects_Id _Objects_Open_u32(
const Objects_Information *information,
Objects_Control *the_object,
uint32_t name
@@ -750,7 +767,7 @@ RTEMS_INLINE_ROUTINE Objects_Id _Objects_Open_u32(
*
* @param name is the name of the object to open.
*/
-RTEMS_INLINE_ROUTINE void _Objects_Open_string(
+static inline void _Objects_Open_string(
const Objects_Information *information,
Objects_Control *the_object,
const char *name
@@ -783,7 +800,7 @@ RTEMS_INLINE_ROUTINE void _Objects_Open_string(
*
* @see _Objects_Allocator_unlock() and _Objects_Allocate().
*/
-RTEMS_INLINE_ROUTINE void _Objects_Allocator_lock( void )
+static inline void _Objects_Allocator_lock( void )
{
_RTEMS_Lock_allocator();
}
@@ -795,7 +812,7 @@ RTEMS_INLINE_ROUTINE void _Objects_Allocator_lock( void )
* previous thread life protection state and thus may not return if the
* executing thread was restarted or deleted in the mean-time.
*/
-RTEMS_INLINE_ROUTINE void _Objects_Allocator_unlock( void )
+static inline void _Objects_Allocator_unlock( void )
{
_RTEMS_Unlock_allocator();
}
@@ -806,7 +823,7 @@ RTEMS_INLINE_ROUTINE void _Objects_Allocator_unlock( void )
* @retval true The allocator is the owner of the object allocator mutex.
* @retval false The allocato is not the owner of the object allocator mutex.
*/
-RTEMS_INLINE_ROUTINE bool _Objects_Allocator_is_owner( void )
+static inline bool _Objects_Allocator_is_owner( void )
{
return _RTEMS_Allocator_is_owner();
}
@@ -826,7 +843,7 @@ RTEMS_INLINE_ROUTINE bool _Objects_Allocator_is_owner( void )
*
* @see _Objects_Allocate() and _Objects_Free().
*/
-RTEMS_INLINE_ROUTINE Objects_Control *_Objects_Allocate_unprotected(
+static inline Objects_Control *_Objects_Allocate_unprotected(
Objects_Information *information
)
{
@@ -882,7 +899,7 @@ RTEMS_INLINE_ROUTINE Objects_Control *_Objects_Allocate_unprotected(
* }
* @endcode
*/
-RTEMS_INLINE_ROUTINE void _Objects_Free(
+static inline void _Objects_Free(
Objects_Information *information,
Objects_Control *the_object
)
@@ -893,6 +910,25 @@ RTEMS_INLINE_ROUTINE void _Objects_Free(
}
/**
+ * @brief Returns true, if the object associated with the zero-based index is
+ * contained in an allocated block of objects, otherwise false.
+ *
+ * @param index is the zero-based object index.
+ * @param objects_per_block is the object count per block.
+ *
+ * @retval true The object associated with the zero-based index is in an
+ * allocated block of objects.
+ * @retval false Otherwise.
+ */
+static inline bool _Objects_Is_in_allocated_block(
+ Objects_Maximum index,
+ Objects_Maximum objects_per_block
+)
+{
+ return index >= objects_per_block;
+}
+
+/**
* @brief Activate the object.
*
* This function must be only used in case this objects information supports
@@ -901,21 +937,23 @@ RTEMS_INLINE_ROUTINE void _Objects_Free(
* @param information The object information block.
* @param the_object The object to activate.
*/
-RTEMS_INLINE_ROUTINE void _Objects_Activate_unlimited(
+static inline void _Objects_Activate_unlimited(
Objects_Information *information,
Objects_Control *the_object
)
{
Objects_Maximum objects_per_block;
- Objects_Maximum block;
+ Objects_Maximum index;
_Assert( _Objects_Is_auto_extend( information ) );
objects_per_block = information->objects_per_block;
- block = _Objects_Get_index( the_object->id ) - OBJECTS_INDEX_MINIMUM;
+ index = _Objects_Get_index( the_object->id ) - OBJECTS_INDEX_MINIMUM;
+
+ if ( _Objects_Is_in_allocated_block( index, objects_per_block ) ) {
+ Objects_Maximum block;
- if ( block > objects_per_block ) {
- block /= objects_per_block;
+ block = index / objects_per_block;
information->inactive_per_block[ block ]--;
information->inactive--;
@@ -931,7 +969,7 @@ RTEMS_INLINE_ROUTINE void _Objects_Activate_unlimited(
* @param information The object information block.
* @param extend The object information extend handler.
*/
-RTEMS_INLINE_ROUTINE Objects_Control *_Objects_Allocate_with_extend(
+static inline Objects_Control *_Objects_Allocate_with_extend(
Objects_Information *information,
void ( *extend )( Objects_Information * )
)