source: rtems/cpukit/score/src/rbtreeinsert.c @ 99fc1d1d

5
Last change on this file since 99fc1d1d was 00dbecb8, checked in by Sebastian Huber <sebastian.huber@…>, on 12/11/15 at 08:48:09

score: Help GCC to inline a function

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 *  Copyright (c) 2010-2012 Gedare Bloom.
3 *
4 *  The license and distribution terms for this file may be
5 *  found in the file LICENSE in this distribution or at
6 *  http://www.rtems.org/license/LICENSE.
7 */
8
9#if HAVE_CONFIG_H
10#include "config.h"
11#endif
12
13#include <rtems/score/rbtreeimpl.h>
14
15RTEMS_STATIC_ASSERT(
16  sizeof( RBTree_Compare_result ) >= sizeof( intptr_t ),
17  RBTree_Compare_result_intptr_t
18);
19
20RTEMS_STATIC_ASSERT(
21  sizeof( RBTree_Compare_result ) >= sizeof( int32_t ),
22  RBTree_Compare_result_int32_t
23);
24
25RBTree_Node *_RBTree_Insert(
26  RBTree_Control *the_rbtree,
27  RBTree_Node    *the_node,
28  RBTree_Compare  compare,
29  bool            is_unique
30)
31{
32  RBTree_Node **which = _RBTree_Root_reference( the_rbtree );
33  RBTree_Node  *parent = NULL;
34
35  while ( *which != NULL ) {
36    RBTree_Compare_result compare_result;
37
38    parent = *which;
39    compare_result = ( *compare )( the_node, parent );
40
41    if ( is_unique && _RBTree_Is_equal( compare_result ) ) {
42      return parent;
43    }
44
45    if ( _RBTree_Is_lesser( compare_result ) ) {
46      which = _RBTree_Left_reference( parent );
47    } else {
48      which = _RBTree_Right_reference( parent );
49    }
50  }
51
52  _RBTree_Add_child( the_node, parent, which );
53  _RBTree_Insert_color( the_rbtree, the_node );
54
55  return NULL;
56}
57
58RB_GENERATE_INSERT_COLOR( RBTree_Control, RBTree_Node, Node, static inline )
59
60void _RBTree_Insert_color(
61  RBTree_Control *the_rbtree,
62  RBTree_Node    *the_node
63)
64{
65  RBTree_Control_RB_INSERT_COLOR( the_rbtree, the_node );
66}
Note: See TracBrowser for help on using the repository browser.