cpukit/bsd-tree.h: prepend CPP with RTEMS_ scoping

This commit is contained in:
Gedare Bloom
2024-07-09 16:05:31 -06:00
committed by Chris Johns
parent c33ed55231
commit 88ca88f3fd
18 changed files with 1643 additions and 446 deletions

View File

@@ -76,8 +76,8 @@ RTEMS_STATIC_ASSERT(
rb_root_node
);
#undef RB_ROOT
#define RB_ROOT ( (struct rb_root) { NULL } )
#undef RTEMS_RB_ROOT
#define RTEMS_RB_ROOT ( (struct rb_root) { NULL } )
#define rb_entry( p, container, field ) RTEMS_CONTAINER_OF( p, container, field )

File diff suppressed because it is too large Load Diff

View File

@@ -71,7 +71,7 @@ struct RBTree_Control;
* tree.
*/
typedef struct RBTree_Node {
RB_ENTRY(RBTree_Node) Node;
RTEMS_RB_ENTRY(RBTree_Node) Node;
} RBTree_Node;
/**
@@ -80,13 +80,13 @@ typedef struct RBTree_Node {
* This is used to manage a red-black tree. A red-black tree consists of a
* tree of zero or more nodes.
*/
typedef RB_HEAD(RBTree_Control, RBTree_Node) RBTree_Control;
typedef RTEMS_RB_HEAD(RBTree_Control, RBTree_Node) RBTree_Control;
/**
* @brief Initializer for an empty red-black tree with designator @a name.
*/
#define RBTREE_INITIALIZER_EMPTY( name ) \
RB_INITIALIZER( name )
RTEMS_RB_INITIALIZER( name )
/**
* @brief Definition for an empty red-black tree with designator @a name.
@@ -105,7 +105,7 @@ typedef RB_HEAD(RBTree_Control, RBTree_Node) RBTree_Control;
*/
static inline void _RBTree_Set_off_tree( RBTree_Node *the_node )
{
RB_COLOR( the_node, Node ) = -1;
RTEMS_RB_COLOR( the_node, Node ) = -1;
}
/**
@@ -122,7 +122,7 @@ static inline bool _RBTree_Is_node_off_tree(
const RBTree_Node *the_node
)
{
return RB_COLOR( the_node, Node ) == -1;
return RTEMS_RB_COLOR( the_node, Node ) == -1;
}
/**
@@ -167,7 +167,7 @@ static inline void _RBTree_Add_child(
)
{
_Assert( _RBTree_Is_node_off_tree( child ) );
RB_SET( child, parent, Node );
RTEMS_RB_SET( child, parent, Node );
*link = child;
}
@@ -265,7 +265,7 @@ static inline RBTree_Node *_RBTree_Root(
const RBTree_Control *the_rbtree
)
{
return RB_ROOT( the_rbtree );
return RTEMS_RB_ROOT( the_rbtree );
}
/**
@@ -280,7 +280,7 @@ static inline RBTree_Node **_RBTree_Root_reference(
RBTree_Control *the_rbtree
)
{
return &RB_ROOT( the_rbtree );
return &RTEMS_RB_ROOT( the_rbtree );
}
/**
@@ -295,7 +295,7 @@ static inline RBTree_Node * const *_RBTree_Root_const_reference(
const RBTree_Control *the_rbtree
)
{
return &RB_ROOT( the_rbtree );
return &RTEMS_RB_ROOT( the_rbtree );
}
/**
@@ -314,7 +314,7 @@ static inline RBTree_Node *_RBTree_Parent(
const RBTree_Node *the_node
)
{
return RB_PARENT( the_node, Node );
return RTEMS_RB_PARENT( the_node, Node );
}
/**
@@ -330,7 +330,7 @@ static inline RBTree_Node *_RBTree_Left(
const RBTree_Node *the_node
)
{
return RB_LEFT( the_node, Node );
return RTEMS_RB_LEFT( the_node, Node );
}
/**
@@ -345,7 +345,7 @@ static inline RBTree_Node **_RBTree_Left_reference(
RBTree_Node *the_node
)
{
return &RB_LEFT( the_node, Node );
return &RTEMS_RB_LEFT( the_node, Node );
}
/**
@@ -361,7 +361,7 @@ static inline RBTree_Node *_RBTree_Right(
const RBTree_Node *the_node
)
{
return RB_RIGHT( the_node, Node );
return RTEMS_RB_RIGHT( the_node, Node );
}
/**
@@ -376,7 +376,7 @@ static inline RBTree_Node **_RBTree_Right_reference(
RBTree_Node *the_node
)
{
return &RB_RIGHT( the_node, Node );
return &RTEMS_RB_RIGHT( the_node, Node );
}
/**
@@ -394,7 +394,7 @@ static inline bool _RBTree_Is_empty(
const RBTree_Control *the_rbtree
)
{
return RB_EMPTY( the_rbtree );
return RTEMS_RB_EMPTY( the_rbtree );
}
/**
@@ -429,7 +429,7 @@ static inline void _RBTree_Initialize_empty(
RBTree_Control *the_rbtree
)
{
RB_INIT( the_rbtree );
RTEMS_RB_INIT( the_rbtree );
}
/**
@@ -445,11 +445,11 @@ static inline void _RBTree_Initialize_one(
)
{
_Assert( _RBTree_Is_node_off_tree( the_node ) );
RB_ROOT( the_rbtree ) = the_node;
RB_PARENT( the_node, Node ) = NULL;
RB_LEFT( the_node, Node ) = NULL;
RB_RIGHT( the_node, Node ) = NULL;
RB_COLOR( the_node, Node ) = RB_BLACK;
RTEMS_RB_ROOT( the_rbtree ) = the_node;
RTEMS_RB_PARENT( the_node, Node ) = NULL;
RTEMS_RB_LEFT( the_node, Node ) = NULL;
RTEMS_RB_RIGHT( the_node, Node ) = NULL;
RTEMS_RB_COLOR( the_node, Node ) = RTEMS_RB_BLACK;
}
/**

View File

@@ -161,13 +161,13 @@ void _Watchdog_Tick( struct Per_CPU_Control *cpu );
*
* @param the_watchdog The watchdog to get the state of.
*
* @return The RB_COLOR of @a the_watchdog.
* @return The RTEMS_RB_COLOR of @a the_watchdog.
*/
static inline Watchdog_State _Watchdog_Get_state(
const Watchdog_Control *the_watchdog
)
{
return (Watchdog_State) RB_COLOR( &the_watchdog->Node.RBTree, Node );
return (Watchdog_State) RTEMS_RB_COLOR( &the_watchdog->Node.RBTree, Node );
}
/**
@@ -181,7 +181,7 @@ static inline void _Watchdog_Set_state(
Watchdog_State state
)
{
RB_COLOR( &the_watchdog->Node.RBTree, Node ) = state;
RTEMS_RB_COLOR( &the_watchdog->Node.RBTree, Node ) = state;
}
/**
@@ -408,7 +408,7 @@ static inline void _Watchdog_Next_first(
right = _RBTree_Right( &first->Node.RBTree );
if ( right != NULL ) {
_Assert( RB_COLOR( right, Node ) == RB_RED );
_Assert( RTEMS_RB_COLOR( right, Node ) == RTEMS_RB_RED );
_Assert( _RBTree_Left( right ) == NULL );
_Assert( _RBTree_Right( right ) == NULL );
header->first = right;

View File

@@ -1650,7 +1650,7 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
{
/* These must be set manually to preserve other members */
f->highest_version = 0;
f->fragtree = RB_ROOT;
f->fragtree = RTEMS_RB_ROOT;
f->metadata = NULL;
f->dents = NULL;
f->target = NULL;

View File

@@ -474,7 +474,7 @@ static int jffs2_build_inode_fragtree(struct jffs2_sb_info *c,
struct jffs2_readinode_info *rii)
{
struct jffs2_tmp_dnode_info *pen, *last, *this;
struct rb_root ver_root = RB_ROOT;
struct rb_root ver_root = RTEMS_RB_ROOT;
uint32_t high_ver = 0;
if (rii->mdata_tn) {
@@ -571,7 +571,7 @@ static void jffs2_free_tmp_dnode_info_list(struct rb_root *list)
jffs2_free_tmp_dnode_info(tn);
}
*list = RB_ROOT;
*list = RTEMS_RB_ROOT;
}
static void jffs2_free_full_dirent_list(struct jffs2_full_dirent *fd)
@@ -1336,7 +1336,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
/* OK. We're happy */
f->metadata = frag_first(&f->fragtree)->node;
jffs2_free_node_frag(frag_first(&f->fragtree));
f->fragtree = RB_ROOT;
f->fragtree = RTEMS_RB_ROOT;
break;
}
if (f->inocache->state == INO_STATE_READING)

View File

@@ -40,9 +40,9 @@
#include <rtems/score/rbtreeimpl.h>
RB_GENERATE_REMOVE_COLOR( RBTree_Control, RBTree_Node, Node, static )
RTEMS_RB_GENERATE_REMOVE_COLOR( RBTree_Control, RBTree_Node, Node, static )
RB_GENERATE_REMOVE( RBTree_Control, RBTree_Node, Node, static )
RTEMS_RB_GENERATE_REMOVE( RBTree_Control, RBTree_Node, Node, static )
#if defined(RTEMS_DEBUG)
static const RBTree_Node *_RBTree_Find_root( const RBTree_Node *the_node )
@@ -66,6 +66,6 @@ void _RBTree_Extract(
)
{
_Assert( _RBTree_Find_root( the_node ) == _RBTree_Root( the_rbtree ) );
RB_REMOVE( RBTree_Control, the_rbtree, the_node );
RTEMS_RB_REMOVE( RBTree_Control, the_rbtree, the_node );
_RBTree_Initialize_node( the_node );
}

View File

@@ -40,12 +40,17 @@
#include <rtems/score/rbtreeimpl.h>
RB_GENERATE_INSERT_COLOR( RBTree_Control, RBTree_Node, Node, static inline )
RTEMS_RB_GENERATE_INSERT_COLOR(
RBTree_Control,
RBTree_Node,
Node,
static inline
)
void _RBTree_Insert_color(
RBTree_Control *the_rbtree,
RBTree_Node *the_node
)
{
RBTree_Control_RB_INSERT_COLOR( the_rbtree, the_node );
RBTree_Control_RTEMS_RB_INSERT_COLOR( the_rbtree, the_node );
}

View File

@@ -42,9 +42,13 @@
#include <rtems/score/rbtreeimpl.h>
#include <rtems/score/basedefs.h>
RB_GENERATE_NEXT( RBTree_Control, RBTree_Node, Node, static )
RTEMS_RB_GENERATE_NEXT( RBTree_Control, RBTree_Node, Node, static )
RBTree_Node *_RBTree_Successor( const RBTree_Node *node )
{
return RB_NEXT( RBTree_Control, NULL, RTEMS_DECONST( RBTree_Node *, node ) );
return RTEMS_RB_NEXT(
RBTree_Control,
NULL,
RTEMS_DECONST( RBTree_Node *, node )
);
}

View File

@@ -41,9 +41,13 @@
#include <rtems/score/rbtreeimpl.h>
#include <rtems/score/basedefs.h>
RB_GENERATE_PREV( RBTree_Control, RBTree_Node, Node, static inline )
RTEMS_RB_GENERATE_PREV( RBTree_Control, RBTree_Node, Node, static inline )
RBTree_Node *_RBTree_Predecessor( const RBTree_Node *node )
{
return RB_PREV( RBTree_Control, NULL, RTEMS_DECONST( RBTree_Node *, node ) );
return RTEMS_RB_PREV(
RBTree_Control,
NULL,
RTEMS_DECONST( RBTree_Node *, node )
);
}

View File

@@ -63,12 +63,12 @@ void _RBTree_Replace_node(
child = _RBTree_Left( victim );
if ( child != NULL ) {
RB_PARENT( child, Node ) = replacement;
RTEMS_RB_PARENT( child, Node ) = replacement;
}
child = _RBTree_Right( victim );
if ( child != NULL ) {
RB_PARENT( child, Node ) = replacement;
RTEMS_RB_PARENT( child, Node ) = replacement;
}
*replacement = *victim;

View File

@@ -450,6 +450,8 @@ links:
uid: sptls03
- role: build-dependency
uid: sptls04
- role: build-dependency
uid: sptree01
- role: build-dependency
uid: spunlimited01
- role: build-dependency

View File

@@ -0,0 +1,19 @@
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
build-type: test-program
cflags: []
copyrights:
- Copyright (C) 2024 Gedare Bloom
cppflags: []
cxxflags: []
enabled-by: true
features: c cprogram
includes: []
ldflags: []
links: []
source:
- testsuites/sptests/sptree01/init.c
stlib: []
target: testsuites/sptests/sptree01.exe
type: build
use-after: []
use-before: []

View File

@@ -80,13 +80,13 @@ typedef struct {
static test_node node_array[100];
#define RED RB_RED
#define RED RTEMS_RB_RED
#define BLACK RB_BLACK
#define BLACK RTEMS_RB_BLACK
static int rb_color( const rtems_rbtree_node *n )
{
return RB_COLOR( n, Node );
return RTEMS_RB_COLOR( n, Node );
}
static rtems_rbtree_compare_result test_compare_function (
@@ -1918,9 +1918,9 @@ static void postorder_tree_init(
const postorder_node_description *pnd;
pnd = &pt->tree[ i ];
RB_PARENT( TN( i ), Node) = pnd->parent;
RB_LEFT( TN( i ), Node) = pnd->left;
RB_RIGHT( TN( i ), Node) = pnd->right;
RTEMS_RB_PARENT( TN( i ), Node) = pnd->parent;
RTEMS_RB_LEFT( TN( i ), Node) = pnd->left;
RTEMS_RB_RIGHT( TN( i ), Node) = pnd->right;
}
}

View File

@@ -0,0 +1,63 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
* Copyright (c) 2024 Gedare Bloom.
*
* 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tmacros.h>
#include <rtems/rbtree.h>
#include <rtems/score/rbtreeimpl.h>
#include <linux/rbtree.h>
#include "sys/tree.h"
const char rtems_test_name[] = "SPTREE 1";
rtems_task Init( rtems_task_argument ignored )
{
TEST_BEGIN();
TEST_END();
rtems_test_exit(0);
}
/* configuration information */
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_MAXIMUM_TASKS 1
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* global variables */

View File

@@ -0,0 +1,36 @@
# SPDX-License-Identifier: BSD-2-Clause
# COPYRIGHT (c) 1989-2009.
# On-Line Applications Research Corporation (OAR).
#
# 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.
#
This file describes the directives and concepts tested by this test set.
test set name: sptree01
directives:
concepts:
+ Ensure that namespace for sys/tree.h is clean with rtems.

View File

@@ -0,0 +1,2 @@
*** BEGIN OF TEST SPTREE 1 ***
*** END OF TEST SPTREE 1 ***

File diff suppressed because it is too large Load Diff