pike.git / src / rbtree_low.h

version» Context lines:

pike.git/src/rbtree_low.h:1:   /* The lower level api for using rbtree. This is in a separate file    * since it's quite macro heavy.    *    * Created 2001-04-27 by Martin Stjernholm    * -  * $Id: rbtree_low.h,v 1.1 2001/12/10 00:58:44 mast Exp $ +  * $Id: rbtree_low.h,v 1.2 2002/08/15 14:49:25 marcus Exp $    */      #ifndef RBTREE_LOW_H   #define RBTREE_LOW_H      #include "rbtree.h"      /* A sliced stack is used to track the way down in a tree, so we can    * back up again easily while rebalancing it. The first slice is    * allocated on the C stack. */
pike.git/src/rbtree_low.h:101:      #define RBSTACK_UP_IGNORE(rbstack) do { \    if ((rbstack).ssp && !--(rbstack).ssp && (rbstack).slice->up) \    rbstack_up (&(rbstack)); \    } while (0)      #define RBSTACK_PEEK(rbstack) \    ((rbstack).ssp ? (rbstack).slice->stack[(rbstack).ssp - 1] : NULL)      #define RBSTACK_POKE(rbstack, node) do { \ -  DO_IF_DEBUG (if (!(rbstack).ssp) fatal ("Using free stack pointer.\n")); \ +  DO_IF_DEBUG (if (!(rbstack).ssp) Pike_fatal ("Using free stack pointer.\n")); \    (rbstack).slice->stack[(rbstack).ssp - 1] = (node); \    } while (0)      #define RBSTACK_UP_TO_ROOT(rbstack, node) do { \    if ((rbstack).ssp) { \    rbstack_up_to_root (&(rbstack)); \    (node) = (rbstack).slice->stack[0]; \    } \    } while (0)   
pike.git/src/rbtree_low.h:248:   /* The `cmp' code should set the variable cmp_res to the result of the    * comparison between the key and the current node `node'. */   #define LOW_RB_FIND(node, cmp, got_lt, got_eq, got_gt) \    do { \    int cmp_res, found_eq_ = 0; \    DO_IF_RB_STATS ( \    size_t stat_depth_count_ = 0; \    rb_num_finds++; \    ); \    while (1) { \ -  DO_IF_DEBUG (if (!node) fatal ("Recursing into null node.\n")); \ +  DO_IF_DEBUG (if (!node) Pike_fatal ("Recursing into null node.\n")); \    DO_IF_RB_STATS ( \    if (++stat_depth_count_ > rb_max_depth) \    rb_max_depth = stat_depth_count_; \    rb_find_depth++; \    ); \    {cmp;} \    if (cmp_res < 0) \    if ((node)->flags & RB_THREAD_PREV) \    if (found_eq_) \    (node) = (node)->prev; \
pike.git/src/rbtree_low.h:294:      /* Variant of LOW_RB_FIND that assumes that `cmp' never returns 0. */   #define LOW_RB_FIND_NEQ(node, cmp, got_lt, got_gt) \    do { \    int cmp_res; \    DO_IF_RB_STATS ( \    size_t stat_depth_count_ = 0; \    rb_num_finds++; \    ); \    while (1) { \ -  DO_IF_DEBUG (if (!node) fatal ("Recursing into null node.\n")); \ +  DO_IF_DEBUG (if (!node) Pike_fatal ("Recursing into null node.\n")); \    DO_IF_RB_STATS ( \    if (++stat_depth_count_ > rb_max_depth) \    rb_max_depth = stat_depth_count_; \    rb_find_depth++; \    ); \    {cmp;} \    if (cmp_res < 0) { \    if ((node)->flags & RB_THREAD_PREV) { \    {got_gt;} \    break; \    } \    (node) = (node)->prev; \    } \    else { \ -  DO_IF_DEBUG (if (!cmp_res) fatal ("cmp_res 0 not expected.\n")); \ +  DO_IF_DEBUG (if (!cmp_res) Pike_fatal ("cmp_res 0 not expected.\n")); \    if ((node)->flags & RB_THREAD_NEXT) { \    {got_lt;} \    break; \    } \    (node) = (node)->next; \    } \    } \    } while (0)      /* Tracks the way down a tree to a specific node and updates the stack    * as necessary for low_rb_link_* and low_rb_unlink_*. */   #define LOW_RB_TRACK(rbstack, node, cmp, got_lt, got_eq, got_gt) \    do { \    DO_IF_DEBUG ( \ -  if (RBSTACK_PEEK (rbstack)) fatal ("The stack is not empty.\n"); \ +  if (RBSTACK_PEEK (rbstack)) Pike_fatal ("The stack is not empty.\n"); \    ); \    DO_IF_RB_STATS (rb_num_finds--); \    LOW_RB_FIND ( \    node, \    { \    DO_IF_RB_STATS (rb_find_depth--); \    RBSTACK_PUSH (rbstack, node); \    {cmp;} \    }, \    got_lt, \    { \    while ((node) != RBSTACK_PEEK (rbstack)) \    RBSTACK_POP_IGNORE (rbstack); \    {got_eq;} \    }, got_gt); \    } while (0)      #define LOW_RB_TRACK_NEQ(rbstack, node, cmp, got_lt, got_gt) \    do { \    DO_IF_DEBUG ( \ -  if (RBSTACK_PEEK (rbstack)) fatal ("The stack is not empty.\n"); \ +  if (RBSTACK_PEEK (rbstack)) Pike_fatal ("The stack is not empty.\n"); \    ); \    DO_IF_RB_STATS (rb_num_finds--); \    LOW_RB_FIND_NEQ ( \    node, \    { \    DO_IF_RB_STATS (rb_find_depth--); \    RBSTACK_PUSH (rbstack, node); \    {cmp;} \    }, \    got_lt, got_gt); \    } while (0)      /* Goes to the first node in a tree while keeping the stack updated. */   #define LOW_RB_TRACK_FIRST(rbstack, node) \    do { \    DO_IF_DEBUG ( \ -  if (RBSTACK_PEEK (rbstack)) fatal ("The stack is not empty.\n"); \ +  if (RBSTACK_PEEK (rbstack)) Pike_fatal ("The stack is not empty.\n"); \    ); \    DO_IF_RB_STATS (rb_num_sidetracks++); \    if (node) { \    struct rb_node_hdr *rb_prev_ = node->prev; \    RBSTACK_PUSH (rbstack, node); \    DO_IF_RB_STATS (rb_num_sidetrack_ops++); \    while (rb_prev_) { \    RBSTACK_PUSH (rbstack, node = rb_prev_); \    DO_IF_RB_STATS (rb_num_sidetrack_ops++); \    rb_prev_ = node->prev; \    } \    } \    } while (0)      /* Goes to the next node in order while keeping the stack updated. */   #define LOW_RB_TRACK_NEXT(rbstack, node) \    do { \    DO_IF_DEBUG ( \    if (node != RBSTACK_PEEK (rbstack)) \ -  fatal ("Given node is not on top of stack.\n"); \ +  Pike_fatal ("Given node is not on top of stack.\n"); \    ); \    DO_IF_RB_STATS (rb_num_sidetracks++); \    if (node->flags & RB_THREAD_NEXT) { \    struct rb_node_hdr *rb_next_ = node->next; \    while ((node = RBSTACK_PEEK (rbstack)) != rb_next_) { \    RBSTACK_POP_IGNORE (rbstack); \    DO_IF_RB_STATS (rb_num_sidetrack_ops++); \    } \    } \    else { \
pike.git/src/rbtree_low.h:408:    node = node->prev; \    } \    } \    } while (0)      /* Goes to the previous node in order while keeping the stack updated. */   #define LOW_RB_TRACK_PREV(rbstack, node) \    do { \    DO_IF_DEBUG ( \    if (node != RBSTACK_PEEK (rbstack)) \ -  fatal ("Given node is not on top of stack.\n"); \ +  Pike_fatal ("Given node is not on top of stack.\n"); \    ); \    DO_IF_RB_STATS (rb_num_sidetracks++); \    if (node->flags & RB_THREAD_PREV) { \    struct rb_node_hdr *rb_prev_ = node->prev; \    while ((node = RBSTACK_PEEK (rbstack)) != rb_prev_) { \    RBSTACK_POP_IGNORE (rbstack); \    DO_IF_RB_STATS (rb_num_sidetrack_ops++); \    } \    } \    else { \