Changeset 69a6802b in rtems


Ignore:
Timestamp:
Jun 17, 2016, 5:50:01 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
9bfad8c
Parents:
768c483b
git-author:
Sebastian Huber <sebastian.huber@…> (06/17/16 05:50:01)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/22/16 12:37:11)
Message:

score: Move _RBTree_Find()

The _RBTree_Find() is no longer used in the score. Move it to sapi and
make it rtems_rbtree_find(). Move corresponding types and support
functions to sapi.

Location:
cpukit
Files:
1 added
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • cpukit/sapi/Makefile.am

    r768c483b r69a6802b  
    4141libsapi_a_SOURCES += src/delaynano.c
    4242libsapi_a_SOURCES += src/rbtree.c
     43libsapi_a_SOURCES += src/rbtreefind.c
    4344libsapi_a_SOURCES += src/rbtreeinsert.c
    4445libsapi_a_SOURCES += src/profilingiterate.c
  • cpukit/sapi/include/rtems/rbtree.h

    r768c483b r69a6802b  
    5656
    5757/**
    58  * @copydoc RBTree_Compare_result
    59  */
    60 typedef RBTree_Compare_result rtems_rbtree_compare_result;
    61 
    62 /**
    63  * @copydoc RBTree_Compare
    64  */
    65 typedef RBTree_Compare rtems_rbtree_compare;
     58 * @brief Integer type for compare results.
     59 *
     60 * The type is large enough to represent pointers and 32-bit signed integers.
     61 *
     62 * @see rtems_rbtree_compare.
     63 */
     64typedef long rtems_rbtree_compare_result;
     65
     66/**
     67 * @brief Compares two red-black tree nodes.
     68 *
     69 * @param[in] first The first node.
     70 * @param[in] second The second node.
     71 *
     72 * @retval positive The key value of the first node is greater than the one of
     73 *   the second node.
     74 * @retval 0 The key value of the first node is equal to the one of the second
     75 *   node.
     76 * @retval negative The key value of the first node is less than the one of the
     77 *   second node.
     78 */
     79typedef rtems_rbtree_compare_result ( *rtems_rbtree_compare )(
     80  const RBTree_Node *first,
     81  const RBTree_Node *second
     82);
    6683
    6784/**
     
    256273}
    257274
    258 /**
    259  * @copydoc _RBTree_Find()
    260  */
    261 RTEMS_INLINE_ROUTINE rtems_rbtree_node* rtems_rbtree_find(
     275RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_equal(
     276  rtems_rbtree_compare_result compare_result
     277)
     278{
     279  return compare_result == 0;
     280}
     281
     282RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_greater(
     283  rtems_rbtree_compare_result compare_result
     284)
     285{
     286  return compare_result > 0;
     287}
     288
     289RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_lesser(
     290  rtems_rbtree_compare_result compare_result
     291)
     292{
     293  return compare_result < 0;
     294}
     295
     296/**
     297 * @brief Tries to find a node for the specified key in the tree.
     298 *
     299 * @param[in] the_rbtree The red-black tree control.
     300 * @param[in] the_node A node specifying the key.
     301 * @param[in] compare The node compare function.
     302 * @param[in] is_unique If true, then return the first node with a key equal to
     303 *   the one of the node specified if it exits, else return the last node if it
     304 *   exists.
     305 *
     306 * @retval node A node corresponding to the key.  If the tree is not unique
     307 * and contains duplicate keys, the set of duplicate keys acts as FIFO.
     308 * @retval NULL No node exists in the tree for the key.
     309 */
     310rtems_rbtree_node* rtems_rbtree_find(
    262311  const rtems_rbtree_control *the_rbtree,
    263312  const rtems_rbtree_node    *the_node,
    264   rtems_rbtree_compare        compare,
     313  rtems_rbtree_compare              compare,
    265314  bool                        is_unique
    266 )
    267 {
    268   return _RBTree_Find( the_rbtree, the_node, compare, is_unique );
    269 }
     315);
    270316
    271317/**
     
    397443  RBTree_Control *the_rbtree,
    398444  RBTree_Node    *the_node,
    399   RBTree_Compare  compare,
     445  rtems_rbtree_compare  compare,
    400446  bool            is_unique
    401447);
  • cpukit/sapi/src/rbtreeinsert.c

    r768c483b r69a6802b  
    1515
    1616RTEMS_STATIC_ASSERT(
    17   sizeof( RBTree_Compare_result ) >= sizeof( intptr_t ),
    18   RBTree_Compare_result_intptr_t
     17  sizeof( rtems_rbtree_compare_result ) >= sizeof( intptr_t ),
     18  rtems_rbtree_compare_result_intptr_t
    1919);
    2020
    2121RTEMS_STATIC_ASSERT(
    22   sizeof( RBTree_Compare_result ) >= sizeof( int32_t ),
    23   RBTree_Compare_result_int32_t
     22  sizeof( rtems_rbtree_compare_result ) >= sizeof( int32_t ),
     23  rtems_rbtree_compare_result_int32_t
    2424);
    2525
     
    2727  rtems_rbtree_control *the_rbtree,
    2828  rtems_rbtree_node    *the_node,
    29   RBTree_Compare        compare,
     29  rtems_rbtree_compare  compare,
    3030  bool                  is_unique
    3131)
     
    3535
    3636  while ( *which != NULL ) {
    37     RBTree_Compare_result compare_result;
     37    rtems_rbtree_compare_result compare_result;
    3838
    3939    parent = *which;
    4040    compare_result = ( *compare )( the_node, parent );
    4141
    42     if ( is_unique && _RBTree_Is_equal( compare_result ) ) {
     42    if ( is_unique && rtems_rbtree_is_equal( compare_result ) ) {
    4343      return parent;
    4444    }
    4545
    46     if ( _RBTree_Is_lesser( compare_result ) ) {
     46    if ( rtems_rbtree_is_lesser( compare_result ) ) {
    4747      which = _RBTree_Left_reference( parent );
    4848    } else {
  • cpukit/score/Makefile.am

    r768c483b r69a6802b  
    293293## RBTREE_C_FILES
    294294libscore_a_SOURCES += \
    295     src/rbtreeextract.c src/rbtreefind.c \
     295    src/rbtreeextract.c \
    296296    src/rbtreeinsert.c src/rbtreeiterate.c src/rbtreenext.c
    297297libscore_a_SOURCES += src/rbtreereplace.c
  • cpukit/score/include/rtems/score/rbtree.h

    r768c483b r69a6802b  
    5858
    5959/**
    60  * @brief Integer type for compare results.
    61  *
    62  * The type is large enough to represent pointers and 32-bit signed integers.
    63  *
    64  * @see RBTree_Compare.
    65  */
    66 typedef long RBTree_Compare_result;
    67 
    68 /**
    69  * @brief Compares two red-black tree nodes.
    70  *
    71  * @param[in] first The first node.
    72  * @param[in] second The second node.
    73  *
    74  * @retval positive The key value of the first node is greater than the one of
    75  *   the second node.
    76  * @retval 0 The key value of the first node is equal to the one of the second
    77  *   node.
    78  * @retval negative The key value of the first node is less than the one of the
    79  *   second node.
    80  */
    81 typedef RBTree_Compare_result ( *RBTree_Compare )(
    82   const RBTree_Node *first,
    83   const RBTree_Node *second
    84 );
    85 
    86 /**
    8760 * @brief Initializer for an empty red-black tree with designator @a name.
    8861 */
     
    9568#define RBTREE_DEFINE_EMPTY( name ) \
    9669  RBTree_Control name = RBTREE_INITIALIZER_EMPTY( name )
    97 
    98 /**
    99  * @brief Tries to find a node for the specified key in the tree.
    100  *
    101  * @param[in] the_rbtree The red-black tree control.
    102  * @param[in] the_node A node specifying the key.
    103  * @param[in] compare The node compare function.
    104  * @param[in] is_unique If true, then return the first node with a key equal to
    105  *   the one of the node specified if it exits, else return the last node if it
    106  *   exists.
    107  *
    108  * @retval node A node corresponding to the key.  If the tree is not unique
    109  * and contains duplicate keys, the set of duplicate keys acts as FIFO.
    110  * @retval NULL No node exists in the tree for the key.
    111  */
    112 RBTree_Node *_RBTree_Find(
    113   const RBTree_Control *the_rbtree,
    114   const RBTree_Node    *the_node,
    115   RBTree_Compare        compare,
    116   bool                  is_unique
    117 );
    11870
    11971/**
  • cpukit/score/include/rtems/score/rbtreeimpl.h

    r768c483b r69a6802b  
    6363);
    6464
    65 RTEMS_INLINE_ROUTINE bool _RBTree_Is_equal(
    66   RBTree_Compare_result compare_result
    67 )
    68 {
    69   return compare_result == 0;
    70 }
    71 
    72 RTEMS_INLINE_ROUTINE bool _RBTree_Is_greater(
    73   RBTree_Compare_result compare_result
    74 )
    75 {
    76   return compare_result > 0;
    77 }
    78 
    79 RTEMS_INLINE_ROUTINE bool _RBTree_Is_lesser(
    80   RBTree_Compare_result compare_result
    81 )
    82 {
    83   return compare_result < 0;
    84 }
    85 
    8665/** @} */
    8766
Note: See TracChangeset for help on using the changeset viewer.