00001 /** \file node.h 00002 * \brief Node. 00003 * 00004 * $Id: internal.h,v 1.17 2009-08-01 10:47:31 stephens Exp $ 00005 */ 00006 #ifndef _tredmill_NODE_H 00007 #define _tredmill_NODE_H 00008 00009 #include "tredmill/list.h" 00010 00011 /****************************************************************************/ 00012 /*! \defgroup node Node */ 00013 /*@{*/ 00014 00015 00016 /** 00017 * An allocation node representing the data ptr returned from tm_alloc(). 00018 * 00019 * The data ptr return by tm_alloc() from a tm_node is immediately after its tm_list header. 00020 * 00021 * tm_nodes are parceled from tm_blocks. 00022 * Each tm_node has a color, which places it on 00023 * a colored list for the tm_node's tm_type. 00024 * 00025 * A tm_node's tm_block is determined by the tm_node's address. 00026 * 00027 * A tm_node's tm_type is determined by the tm_block it resides in. 00028 * 00029 */ 00030 typedef struct tm_node { 00031 /*! The current type list for the node. */ 00032 /*! tm_type.color_list[tm_node_color(this)] list. */ 00033 tm_list list; 00034 } tm_node; 00035 00036 /*! The color of a tm_node. */ 00037 #define tm_node_color(n) ((tm_color) tm_list_color(n)) 00038 00039 /*! A pointer to the data of a tm_node. */ 00040 #define tm_node_ptr(n) ((void*)(((tm_node*) n) + 1)) 00041 00042 /*! Return the tm_node's tm_type. */ 00043 #define tm_node_type(n) tm_block_type(tm_node_to_block(n)) 00044 00045 /** 00046 * An allocation for a large node. 00047 */ 00048 typedef struct tm_node_large { 00049 /*! The current type list for the node. */ 00050 /*! tm_type.color_list[tm_node_color(this)] list. */ 00051 tm_list list; 00052 00053 /*! The large buffer for the data of this node. */ 00054 void *ptr; 00055 } tm_node_large; 00056 00057 00058 /** 00059 * Colored Node Iterator. 00060 */ 00061 typedef struct tm_node_iterator { 00062 /*! The color of nodes to iterate on. */ 00063 int color; 00064 /*! The next tm_node. */ 00065 tm_node *node_next; 00066 /*! The current tm_type. */ 00067 struct tm_type *type; 00068 /*! The current tm_node. */ 00069 tm_node *node; 00070 00071 /*! The node scheduled for interior scanning. */ 00072 void *scan_node; 00073 /*! The current scanning position in the tm_node_ptr() data region. */ 00074 void *scan_ptr; 00075 /*! End of scan region. */ 00076 void *scan_end; 00077 /*! Size of scan region. */ 00078 size_t scan_size; 00079 } tm_node_iterator; 00080 00081 00082 /*@}*/ 00083 00084 #endif