File indexing completed on 2025-05-11 08:24:11
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #ifndef _LINUX_RBTREE_H
0029 #define _LINUX_RBTREE_H
0030
0031 #include <rtems/score/rbtree.h>
0032
0033 #ifdef __cplusplus
0034 extern "C" {
0035 #endif
0036
0037 #define rb_node RBTree_Node
0038
0039 #define rb_left Node.rbe_left
0040
0041 #define rb_right Node.rbe_right
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065 struct rb_root {
0066 RBTree_Node *rb_node;
0067 };
0068
0069 RTEMS_STATIC_ASSERT(
0070 sizeof( struct rb_root ) == sizeof( RBTree_Control ),
0071 rb_root_size
0072 );
0073
0074 RTEMS_STATIC_ASSERT(
0075 offsetof( struct rb_root, rb_node ) == offsetof( RBTree_Control, rbh_root ),
0076 rb_root_node
0077 );
0078
0079 #undef RTEMS_RB_ROOT
0080 #define RTEMS_RB_ROOT ( (struct rb_root) { NULL } )
0081
0082 #define rb_entry( p, container, field ) RTEMS_CONTAINER_OF( p, container, field )
0083
0084 static inline void rb_insert_color( struct rb_node *node, struct rb_root *root)
0085 {
0086 _RBTree_Insert_color( (RBTree_Control *) root, node );
0087 }
0088
0089 static inline void rb_erase( struct rb_node *node, struct rb_root *root )
0090 {
0091 _RBTree_Extract( (RBTree_Control *) root, node );
0092 }
0093
0094 static inline struct rb_node *rb_next( struct rb_node *node )
0095 {
0096 return _RBTree_Successor( node );
0097 }
0098
0099 static inline struct rb_node *rb_prev( struct rb_node *node )
0100 {
0101 return _RBTree_Predecessor( node );
0102 }
0103
0104 static inline struct rb_node *rb_first( struct rb_root *root )
0105 {
0106 return _RBTree_Minimum( (RBTree_Control *) root );
0107 }
0108
0109 static inline struct rb_node *rb_last( struct rb_root *root )
0110 {
0111 return _RBTree_Maximum( (RBTree_Control *) root );
0112 }
0113
0114 static inline void rb_replace_node(
0115 struct rb_node *victim,
0116 struct rb_node *replacement,
0117 struct rb_root *root
0118 )
0119 {
0120 _RBTree_Replace_node(
0121 (RBTree_Control *) root,
0122 victim,
0123 replacement
0124 );
0125 }
0126
0127 static inline void rb_link_node(
0128 struct rb_node *node,
0129 struct rb_node *parent,
0130 struct rb_node **link
0131 )
0132 {
0133 _RBTree_Initialize_node( node );
0134 _RBTree_Add_child( node, parent, link );
0135 }
0136
0137 static inline struct rb_node *rb_parent( struct rb_node *node )
0138 {
0139 return _RBTree_Parent( node );
0140 }
0141
0142 #define rbtree_postorder_for_each_entry_safe( node, next, root, field ) \
0143 for ( \
0144 node = _RBTree_Postorder_first( \
0145 (RBTree_Control *) root, \
0146 offsetof( __typeof__( *node ), field ) \
0147 ); \
0148 node != NULL && ( \
0149 next = _RBTree_Postorder_next( \
0150 &node->field, \
0151 offsetof( __typeof__( *node ), field ) \
0152 ), \
0153 node != NULL \
0154 ); \
0155 node = next \
0156 )
0157
0158 #ifdef __cplusplus
0159 }
0160 #endif
0161
0162 #endif