summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-09-27 14:37:07 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-09-27 14:56:47 +0200
commite2fe881a87331e7e20dab95126a8860e42cdddf0 (patch)
treee792e1a31bc4e55a51606ab3526d191badb37da3
parentposix: Remove superfluous includes (diff)
downloadrtems-e2fe881a87331e7e20dab95126a8860e42cdddf0.tar.bz2
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.
-rw-r--r--cpukit/libfs/src/jffs2/include/linux/rbtree.h3
-rw-r--r--cpukit/score/include/rtems/score/rbtree.h8
-rw-r--r--cpukit/score/src/rbtreeextract.c18
-rw-r--r--cpukit/score/src/rbtreeinsert.c4
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 f958e6daae..2268434939 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 371fe9f5f8..15a3bc8913 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 8a87b2d56c..e4eb8d88de 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 99dc2a233f..c8bbef9aad 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 );
}