mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-11-16 19:04:53 +08:00
score: Flatten the red-black tree node
The red-black tree node held its links and its color in a nested member. The nesting came from the entry macro of the header which the previous commit removed. It served no purpose, and each access had to name the nested member. Move the links and the color into the node. Change the prefix of the fields from rbe_ of the entry to rbn_ of the node. The Linux API wrapper <linux/rbtree.h> renames the Linux fields with "#define rb_left rbn_left" and "#define rb_right rbn_right". Other Linux compatibility layers such as the linuxkpi of FreeBSD define rb_left and rb_right as object-like macros. The prefix rbn_ is no Linux name, so these macros leave the fields alone. The tests sprbtree01 and ts-unit-no-clock-0 passed on the boards of eight targets. Target Processor aarch64/zynqmp_apu Cortex-A53 LS1046A Cortex-A72 arm/zynqmp_rpu_lock_step Cortex-R5F arm/samrh71_flexram Cortex-M7 arm/xilinx_zynq_zc702 Cortex-A9 riscv/mpfs_e51 E51 riscv/mpfs_u54 U54 sparc/gr740 LEON4 Update #5804. Assisted-by: Claude:claude-opus-5-5 claude-code Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
This commit is contained in:
1 parent
9485932096
commit
26a73bcdec
6 files changed
+38
-47
No files matched your search
@@ -434,8 +434,8 @@ static void eat_last(struct rb_root *root, struct rb_node *node)
|
||||
node->rb_left->__rb_parent_color = node->__rb_parent_color;
|
||||
#else /* __rtems__ */
|
||||
{
|
||||
node->rb_left->Node.rbe_parent = node->Node.rbe_parent;
|
||||
node->rb_left->Node.rbe_color = node->Node.rbe_color;
|
||||
node->rb_left->rbn_parent = node->rbn_parent;
|
||||
node->rb_left->rbn_color = node->rbn_color;
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
@@ -45,9 +45,9 @@ extern "C" {
|
||||
|
||||
#define rb_node RBTree_Node
|
||||
|
||||
#define rb_left Node.rbe_left
|
||||
#define rb_left rbn_left
|
||||
|
||||
#define rb_right Node.rbe_right
|
||||
#define rb_right rbn_right
|
||||
|
||||
/*
|
||||
* Getting rid of this placeholder structure is a bit difficult. The use of
|
||||
|
||||
@@ -77,29 +77,24 @@ struct RBTree_Control;
|
||||
*/
|
||||
typedef struct RBTree_Node {
|
||||
/**
|
||||
* @brief This member contains the links and the color of the node.
|
||||
* @brief This member references the left child of the node.
|
||||
*/
|
||||
struct {
|
||||
/**
|
||||
* @brief This member references the left child of the node.
|
||||
*/
|
||||
struct RBTree_Node *rbe_left;
|
||||
struct RBTree_Node *rbn_left;
|
||||
|
||||
/**
|
||||
* @brief This member references the right child of the node.
|
||||
*/
|
||||
struct RBTree_Node *rbe_right;
|
||||
/**
|
||||
* @brief This member references the right child of the node.
|
||||
*/
|
||||
struct RBTree_Node *rbn_right;
|
||||
|
||||
/**
|
||||
* @brief This member references the parent of the node.
|
||||
*/
|
||||
struct RBTree_Node *rbe_parent;
|
||||
/**
|
||||
* @brief This member references the parent of the node.
|
||||
*/
|
||||
struct RBTree_Node *rbn_parent;
|
||||
|
||||
/**
|
||||
* @brief This member contains the color of the node.
|
||||
*/
|
||||
int rbe_color;
|
||||
} Node;
|
||||
/**
|
||||
* @brief This member contains the color of the node.
|
||||
*/
|
||||
int rbn_color;
|
||||
} RBTree_Node;
|
||||
|
||||
/**
|
||||
@@ -145,7 +140,7 @@ typedef struct RBTree_Control {
|
||||
*/
|
||||
static inline int _RBTree_Color( const RBTree_Node *the_node )
|
||||
{
|
||||
return the_node->Node.rbe_color;
|
||||
return the_node->rbn_color;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,7 +152,7 @@ static inline int _RBTree_Color( const RBTree_Node *the_node )
|
||||
*/
|
||||
static inline void _RBTree_Set_color( RBTree_Node *the_node, int color )
|
||||
{
|
||||
the_node->Node.rbe_color = color;
|
||||
the_node->rbn_color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,7 +167,7 @@ static inline void _RBTree_Set_parent(
|
||||
RBTree_Node *parent
|
||||
)
|
||||
{
|
||||
the_node->Node.rbe_parent = parent;
|
||||
the_node->rbn_parent = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,7 +179,7 @@ static inline void _RBTree_Set_parent(
|
||||
*/
|
||||
static inline void _RBTree_Set_left( RBTree_Node *the_node, RBTree_Node *left )
|
||||
{
|
||||
the_node->Node.rbe_left = left;
|
||||
the_node->rbn_left = left;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,7 +194,7 @@ static inline void _RBTree_Set_right(
|
||||
RBTree_Node *right
|
||||
)
|
||||
{
|
||||
the_node->Node.rbe_right = right;
|
||||
the_node->rbn_right = right;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -444,7 +439,7 @@ static inline RBTree_Node *const *_RBTree_Root_const_reference(
|
||||
*/
|
||||
static inline RBTree_Node *_RBTree_Parent( const RBTree_Node *the_node )
|
||||
{
|
||||
return the_node->Node.rbe_parent;
|
||||
return the_node->rbn_parent;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -458,7 +453,7 @@ static inline RBTree_Node *_RBTree_Parent( const RBTree_Node *the_node )
|
||||
*/
|
||||
static inline RBTree_Node *_RBTree_Left( const RBTree_Node *the_node )
|
||||
{
|
||||
return the_node->Node.rbe_left;
|
||||
return the_node->rbn_left;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -471,7 +466,7 @@ static inline RBTree_Node *_RBTree_Left( const RBTree_Node *the_node )
|
||||
*/
|
||||
static inline RBTree_Node **_RBTree_Left_reference( RBTree_Node *the_node )
|
||||
{
|
||||
return &the_node->Node.rbe_left;
|
||||
return &the_node->rbn_left;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -485,7 +480,7 @@ static inline RBTree_Node **_RBTree_Left_reference( RBTree_Node *the_node )
|
||||
*/
|
||||
static inline RBTree_Node *_RBTree_Right( const RBTree_Node *the_node )
|
||||
{
|
||||
return the_node->Node.rbe_right;
|
||||
return the_node->rbn_right;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -498,7 +493,7 @@ static inline RBTree_Node *_RBTree_Right( const RBTree_Node *the_node )
|
||||
*/
|
||||
static inline RBTree_Node **_RBTree_Right_reference( RBTree_Node *the_node )
|
||||
{
|
||||
return &the_node->Node.rbe_right;
|
||||
return &the_node->rbn_right;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -93,14 +93,14 @@ typedef enum {
|
||||
* @see _Watchdog_Preinitialize().
|
||||
*/
|
||||
#if defined( RTEMS_SMP )
|
||||
#define WATCHDOG_INITIALIZER( routine ) \
|
||||
{ { { { NULL, NULL, NULL, WATCHDOG_INACTIVE } } }, \
|
||||
&_Per_CPU_Information[ 0 ].per_cpu, \
|
||||
( routine ), \
|
||||
#define WATCHDOG_INITIALIZER( routine ) \
|
||||
{ { { NULL, NULL, NULL, WATCHDOG_INACTIVE } }, \
|
||||
&_Per_CPU_Information[ 0 ].per_cpu, \
|
||||
( routine ), \
|
||||
0 }
|
||||
#else
|
||||
#define WATCHDOG_INITIALIZER( routine ) \
|
||||
{ { { { NULL, NULL, NULL, WATCHDOG_INACTIVE } } }, ( routine ), 0 }
|
||||
{ { { NULL, NULL, NULL, WATCHDOG_INACTIVE } }, ( routine ), 0 }
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
@@ -67,14 +67,10 @@ bool _POSIX_Mutex_Auto_initialization( POSIX_Mutex_Control *the_mutex )
|
||||
zero |= (unsigned long) the_mutex->Recursive.Mutex.Queue.Queue.owner;
|
||||
zero |= (unsigned long) the_mutex->Recursive.Mutex.Queue.Queue.name;
|
||||
zero |= the_mutex->Recursive.nest_level;
|
||||
zero |= (unsigned long)
|
||||
the_mutex->Priority_ceiling.Node.RBTree.Node.rbe_left;
|
||||
zero |= (unsigned long)
|
||||
the_mutex->Priority_ceiling.Node.RBTree.Node.rbe_right;
|
||||
zero |= (unsigned long)
|
||||
the_mutex->Priority_ceiling.Node.RBTree.Node.rbe_parent;
|
||||
zero |= (unsigned long)
|
||||
the_mutex->Priority_ceiling.Node.RBTree.Node.rbe_color;
|
||||
zero |= (unsigned long) the_mutex->Priority_ceiling.Node.RBTree.rbn_left;
|
||||
zero |= (unsigned long) the_mutex->Priority_ceiling.Node.RBTree.rbn_right;
|
||||
zero |= (unsigned long) the_mutex->Priority_ceiling.Node.RBTree.rbn_parent;
|
||||
zero |= (unsigned long) the_mutex->Priority_ceiling.Node.RBTree.rbn_color;
|
||||
zero |= (unsigned long) the_mutex->Priority_ceiling.priority;
|
||||
zero |= (unsigned long) ( the_mutex->Priority_ceiling.priority >> 32 );
|
||||
zero |= (unsigned long) the_mutex->scheduler;
|
||||
|
||||
@@ -153,7 +153,7 @@ static void _RBTree_Remove( RBTree_Control *head, RBTree_Node *elm )
|
||||
|
||||
_RBTree_Set_parent( _RBTree_Left( old ), elm );
|
||||
color = _RBTree_Color( elm );
|
||||
elm->Node = old->Node;
|
||||
*elm = *old;
|
||||
}
|
||||
|
||||
_RBTree_Swap_child( head, old, elm );
|
||||
|
||||
Reference in new issue
Block a user