[rtems commit] score: Simplify red-black tree debug support
Sebastian Huber
sebh at rtems.org
Wed Sep 27 12:57:34 UTC 2017
Module: rtems
Branch: master
Commit: e2fe881a87331e7e20dab95126a8860e42cdddf0
Changeset: http://git.rtems.org/rtems/commit/?id=e2fe881a87331e7e20dab95126a8860e42cdddf0
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed Sep 27 14:37:07 2017 +0200
score: Simplify red-black tree debug support
Make the RBTree_Node layout independent of RTEMS_DEBUG (and all other
build configuration options). This allows the use of this structure in
Newlib.
Update #3112.
---
cpukit/libfs/src/jffs2/include/linux/rbtree.h | 3 ---
cpukit/score/include/rtems/score/rbtree.h | 8 --------
cpukit/score/src/rbtreeextract.c | 18 +++++++++++++++++-
cpukit/score/src/rbtreeinsert.c | 4 ----
4 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/cpukit/libfs/src/jffs2/include/linux/rbtree.h b/cpukit/libfs/src/jffs2/include/linux/rbtree.h
index f958e6d..2268434 100644
--- a/cpukit/libfs/src/jffs2/include/linux/rbtree.h
+++ b/cpukit/libfs/src/jffs2/include/linux/rbtree.h
@@ -22,9 +22,6 @@ struct rb_node {
struct rb_node *rb_right;
struct rb_node *rb_parent;
int rb_color;
-#if defined(RTEMS_DEBUG)
- const RBTree_Control *rb_tree;
-#endif
};
RTEMS_STATIC_ASSERT(
diff --git a/cpukit/score/include/rtems/score/rbtree.h b/cpukit/score/include/rtems/score/rbtree.h
index 371fe9f..15a3bc8 100644
--- a/cpukit/score/include/rtems/score/rbtree.h
+++ b/cpukit/score/include/rtems/score/rbtree.h
@@ -49,9 +49,6 @@ struct RBTree_Control;
*/
typedef struct RBTree_Node {
RB_ENTRY(RBTree_Node) Node;
-#if defined(RTEMS_DEBUG)
- const struct RBTree_Control *tree;
-#endif
} RBTree_Node;
/**
@@ -129,7 +126,6 @@ RTEMS_INLINE_ROUTINE void _RBTree_Initialize_node( RBTree_Node *the_node )
{
#if defined(RTEMS_DEBUG)
_RBTree_Set_off_tree( the_node );
- the_node->tree = NULL;
#else
(void) the_node;
#endif
@@ -408,10 +404,6 @@ RTEMS_INLINE_ROUTINE void _RBTree_Initialize_one(
)
{
_Assert( _RBTree_Is_node_off_tree( the_node ) );
-#if defined(RTEMS_DEBUG)
- _Assert( the_node->tree == NULL );
- the_node->tree = the_rbtree;
-#endif
RB_ROOT( the_rbtree ) = the_node;
RB_PARENT( the_node, Node ) = NULL;
RB_LEFT( the_node, Node ) = NULL;
diff --git a/cpukit/score/src/rbtreeextract.c b/cpukit/score/src/rbtreeextract.c
index 8a87b2d..e4eb8d8 100644
--- a/cpukit/score/src/rbtreeextract.c
+++ b/cpukit/score/src/rbtreeextract.c
@@ -16,12 +16,28 @@ RB_GENERATE_REMOVE_COLOR( RBTree_Control, RBTree_Node, Node, static )
RB_GENERATE_REMOVE( RBTree_Control, RBTree_Node, Node, static )
+#if defined(RTEMS_DEBUG)
+static RBTree_Node *_RBTree_Find_root( const RBTree_Node *the_node )
+{
+ while ( true ) {
+ const RBTree_Node *potential_root;
+
+ potential_root = the_node;
+ the_node = _RBTree_Parent( the_node );
+
+ if ( the_node == NULL ) {
+ return potential_root;
+ }
+ }
+}
+#endif
+
void _RBTree_Extract(
RBTree_Control *the_rbtree,
RBTree_Node *the_node
)
{
- _Assert( the_node->tree == the_rbtree );
+ _Assert( _RBTree_Find_root( the_node ) == _RBTree_Root( the_rbtree ) );
RB_REMOVE( RBTree_Control, the_rbtree, the_node );
_RBTree_Initialize_node( the_node );
}
diff --git a/cpukit/score/src/rbtreeinsert.c b/cpukit/score/src/rbtreeinsert.c
index 99dc2a2..c8bbef9 100644
--- a/cpukit/score/src/rbtreeinsert.c
+++ b/cpukit/score/src/rbtreeinsert.c
@@ -19,9 +19,5 @@ void _RBTree_Insert_color(
RBTree_Node *the_node
)
{
-#if defined(RTEMS_DEBUG)
- _Assert( the_node->tree == NULL );
- the_node->tree = the_rbtree;
-#endif
RBTree_Control_RB_INSERT_COLOR( the_rbtree, the_node );
}
More information about the vc
mailing list