Node: Iterator

Defines

#define tm_node_LOOP_INIT(C)   tm_node_iterator_init(&tm.node_color_iter[C])
 Initialize the iterator of all nodes of a given color.
#define tm_node_LOOP(C)
 Begin a loop over all nodes of a given color.
#define tm_node_LOOP_BREAK(C)   break
 Break out of a loop over all nodes of a given color.
#define tm_node_LOOP_END(C)
 End a loop over all nodes of a given color.

Functions

static __inline void tm_node_iterator_init (tm_node_iterator *ni)
 Initializes a colored node iterator.
static __inline tm_nodetm_node_iterator_next (tm_node_iterator *ni)
 Returns the next node from the iterator.

Define Documentation

#define tm_node_LOOP (  ) 
Value:
{                                               \
  tm_node *n;                                                           \
  tm_type *t = 0;                                                       \
  while ( (n = tm_node_iterator_next(&tm.node_color_iter[C])) ) {       \
    t = tm.node_color_iter[C].type;                                     \
    {

Begin a loop over all nodes of a given color.

Definition at line 395 of file internal.h.

Referenced by _tm_node_sweep_some(), and _tm_node_unmark_some().

#define tm_node_LOOP_BREAK (  )     break

Break out of a loop over all nodes of a given color.

Definition at line 403 of file internal.h.

Referenced by _tm_node_sweep_some(), and _tm_node_unmark_some().

#define tm_node_LOOP_END (  ) 
Value:
}                                               \
  }                                             \
}

End a loop over all nodes of a given color.

Definition at line 406 of file internal.h.

Referenced by _tm_node_sweep_some(), and _tm_node_unmark_some().

#define tm_node_LOOP_INIT (  )     tm_node_iterator_init(&tm.node_color_iter[C])

Initialize the iterator of all nodes of a given color.

Definition at line 391 of file internal.h.

Referenced by _tm_node_scan_all(), _tm_node_sweep_all(), _tm_node_unmark_all(), and _tm_phase_init().


Function Documentation

static __inline void tm_node_iterator_init ( tm_node_iterator ni  )  [static]

Initializes a colored node iterator.

Definition at line 315 of file internal.h.

References tm_node_iterator::color, tm_type::color_list, tm_node_iterator::node, tm_node_iterator::node_next, tm_node_iterator::scan_end, tm_node_iterator::scan_node, tm_node_iterator::scan_ptr, tm_node_iterator::scan_size, tm, tm_node_iterator::type, and tm_data::types.

00316 {
00317   ni->type = (void *) &tm.types;
00318   ni->node_next = (void *) &ni->type->color_list[ni->color];
00319   ni->node = 0;
00320   ni->scan_node = 0;
00321   ni->scan_ptr = 0;
00322   ni->scan_end = 0;
00323   ni->scan_size = 0;
00324 }

static __inline tm_node* tm_node_iterator_next ( tm_node_iterator ni  )  [static]

Returns the next node from the iterator.

Definition at line 328 of file internal.h.

References tm_node_iterator::color, tm_type::color_list, tm_type::id, tm_data::n, tm_node_iterator::node, tm_node_iterator::node_next, tm, tm_abort(), tm_assert, tm_color_name, tm_list_color, tm_list_next, tm_node_color, tm_node_iterator::type, and tm_data::types.

Referenced by _tm_node_scan_some().

00329 {
00330   size_t i = 0;
00331 
00332   while ( i ++ < tm.n[ni->color] ) {
00333     // fprintf(stderr, "  t%p n%p i%ul\n", ni->type, ni->node_next, i);
00334   
00335     /* Wrap around on types? */
00336     if ( (void *) ni->type == (void *) &tm.types ) {
00337       ni->type = (void*) tm_list_next(ni->type);
00338 
00339       /*
00340        * There are no tm_type objects at all.
00341        * This should never happen!
00342        */
00343       if ( (void *) ni->type == (void *) &tm.types ) {
00344         tm_abort();
00345         return 0;
00346       }
00347       
00348     next_type:
00349       /* Start on type node color_list. */
00350       ni->node_next = (void *) &ni->type->color_list[ni->color];
00351 
00352       tm_assert(tm_list_color(ni->node_next) == ni->color);
00353 
00354       /* Move iterator to first node. */
00355       ni->node_next = (void *) tm_list_next(ni->node_next);
00356     }
00357 
00358     /* At end of type color list? */
00359     if ( ! ni->node_next || (void *) ni->node_next == (void *) &ni->type->color_list[ni->color] ) {
00360       ni->type = (void*) tm_list_next(ni->type);
00361       goto next_type;
00362     }
00363 
00364     if ( tm_node_color(ni->node_next) != ni->color ) {
00365       fprintf(stderr, "  tm_node_iterator %p: node_color_iter[%s] derailed at node_next %p color %s, t#%d\n",
00366               ni, 
00367               tm_color_name[ni->color], 
00368               ni->node_next, 
00369               tm_color_name[tm_node_color(ni->node_next)],
00370               ni->type->id
00371               );
00372       // tm_abort();
00373       ni->type = (void*) tm_list_next(ni->type);
00374       goto next_type;
00375     }
00376     else {
00377       /* Return current node. */
00378       ni->node = ni->node_next;
00379       
00380       /* Move iterator to next node. */
00381       ni->node_next = (void*) tm_list_next(ni->node_next);
00382       
00383       return ni->node;
00384     }
00385   }
00386 
00387   return 0;
00388 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Mon Jan 25 06:33:12 2010 for TM(tredmill) by  doxygen 1.6.1