00001 /** \file mark.h 00002 * \brief Marking Primitives. 00003 */ 00004 #ifndef tm_MARK_H 00005 #define tm_MARK_H 00006 00007 00008 /***************************************************************************/ 00009 /*! \defgroup marking Marking */ 00010 /*@}*/ 00011 00012 /** 00013 * Marks a node as in-use. 00014 */ 00015 static __inline 00016 int _tm_node_mark(tm_node *n) 00017 { 00018 switch ( tm_node_color(n) ) { 00019 case tm_WHITE: 00020 /** If tm_WHITE, we have a spurious pointer into a free node? 00021 * ABORT! 00022 */ 00023 tm_abort(); 00024 break; 00025 00026 case tm_ECRU: 00027 /** 00028 * If tm_ECRU, 00029 * the node has not been scheduled for marking; 00030 * So schedule it for marking. 00031 * Return true to alert caller that work is to be done. 00032 */ 00033 tm_node_set_color(n, tm_node_to_block(n), tm_GREY); 00034 #if 0 00035 tm_msg("m n%p\n", n); 00036 #endif 00037 return 1; 00038 break; 00039 00040 case tm_GREY: 00041 /** 00042 * If tm_GREY, 00043 * the node has already been scheduled for marking. 00044 * DO NOTHING. 00045 */ 00046 break; 00047 00048 case tm_BLACK: 00049 /** 00050 * If tm_BLACK, 00051 * the node has already been marked. 00052 * DO NOTHING. 00053 */ 00054 break; 00055 00056 default: 00057 tm_abort(); 00058 break; 00059 } 00060 00061 /*! Otherwise, return false: there is nothing to do. */ 00062 return 0; 00063 } 00064 00065 00066 /** 00067 * Mark a potential pointer. 00068 * Returns true if something was marked. 00069 */ 00070 static __inline 00071 tm_node * _tm_mark_possible_ptr(void *p) 00072 { 00073 tm_node *n; 00074 00075 if ( p && (n = tm_ptr_to_node(p)) && _tm_node_mark(n) ) 00076 return n; 00077 00078 return 0; 00079 } 00080 00081 void _tm_root_loop_init(); 00082 00083 void _tm_register_scan(); 00084 00085 void _tm_set_stack_ptr(void *stackvar); 00086 void _tm_stack_scan(); 00087 00088 void _tm_root_scan_all(); 00089 int _tm_root_scan_some(); 00090 00091 __inline 00092 void _tm_range_scan(const void *b, const void *e); 00093 00094 size_t _tm_node_scan_some(size_t amount); 00095 void _tm_node_scan_all(); 00096 00097 /*@}*/ 00098 00099 #endif