51 #ifdef DEBUG |
52 #ifdef DEBUG |
52 #define PER_POOL_STATISTICS |
53 #define PER_POOL_STATISTICS |
53 #endif |
54 #endif |
54 |
55 |
55 /* Define POOL_GLOBAL_STATISTICS to get global pool statistics */ |
56 /* Define POOL_GLOBAL_STATISTICS to get global pool statistics */ |
56 #define POOL_GLOBAL_STATISTICS |
57 //define POOL_GLOBAL_STATISTICS // TODO: redefine |
57 |
58 |
58 /* |
59 /* |
59 * When POOL_ZERO_DEBUG is defined, overwrite the contents of freed |
60 * When POOL_ZERO_DEBUG is defined, overwrite the contents of freed |
60 * pool data structures and memory with the POOL_ZERO_DEBUG byte value. |
61 * pool data structures and memory with the POOL_ZERO_DEBUG byte value. |
61 */ |
62 */ |
107 }; |
108 }; |
108 #endif /* PER_POOL_STATISTICS */ |
109 #endif /* PER_POOL_STATISTICS */ |
109 |
110 |
110 typedef struct pool_config_t pool_config_t; |
111 typedef struct pool_config_t pool_config_t; |
111 struct pool_config_t { |
112 struct pool_config_t { |
112 PRUint32 block_size; /* size of blocks to allocate */ |
113 int32_t block_size; /* size of blocks to allocate */ |
113 PRUint32 retain_size; /* maximum bytes kept on per-pool free list */ |
114 int32_t retain_size; /* maximum bytes kept on per-pool free list */ |
114 PRUint32 retain_num; /* maximum blocks kept on per-pool free list */ |
115 int32_t retain_num; /* maximum blocks kept on per-pool free list */ |
115 }; |
116 }; |
116 |
117 |
117 #define POOL_CONFIG_INIT { \ |
118 #define POOL_CONFIG_INIT { \ |
118 DEFAULT_BLOCK_SIZE, /* block_size */ \ |
119 DEFAULT_BLOCK_SIZE, /* block_size */ \ |
119 DEFAULT_RETENTION_SIZE, /* retain_size */ \ |
120 DEFAULT_RETENTION_SIZE, /* retain_size */ \ |
147 typedef struct pool_t pool_t; |
148 typedef struct pool_t pool_t; |
148 struct pool_t { |
149 struct pool_t { |
149 block_t *curr_block; /* current block being used */ |
150 block_t *curr_block; /* current block being used */ |
150 block_t *used_blocks; /* blocks that are all used up */ |
151 block_t *used_blocks; /* blocks that are all used up */ |
151 block_t *free_blocks; /* blocks that are free */ |
152 block_t *free_blocks; /* blocks that are free */ |
152 PRUint32 free_size; /* number of bytes in free_blocks */ |
153 int32_t free_size; /* number of bytes in free_blocks */ |
153 PRUint32 free_num; /* number of blocks in free_blocks */ |
154 int32_t free_num; /* number of blocks in free_blocks */ |
154 size_t size; /* size of memory in pool */ |
155 size_t size; /* size of memory in pool */ |
155 pool_t *next; /* known_pools list */ |
156 pool_t *next; /* known_pools list */ |
156 #ifdef PER_POOL_STATISTICS |
157 #ifdef PER_POOL_STATISTICS |
157 pool_stats_t stats; /* statistics for this pool */ |
158 pool_stats_t stats; /* statistics for this pool */ |
158 #endif /* PER_POOL_STATISTICS */ |
159 #endif /* PER_POOL_STATISTICS */ |
159 }; |
160 }; |
160 |
161 |
161 typedef struct pool_global_stats_t pool_global_stats_t; |
162 typedef struct pool_global_stats_t pool_global_stats_t; |
162 struct pool_global_stats_t { |
163 struct pool_global_stats_t { |
163 PRLock *lock; /* lock for access to poolList */ |
164 //PRLock *lock; /* lock for access to poolList */ // TODO: remove |
164 pool_t *poolList; /* list of known pools */ |
165 pool_t *poolList; /* list of known pools */ |
165 PRUint32 createCnt; /* count of pools created */ |
166 int32_t createCnt; /* count of pools created */ |
166 PRUint32 destroyCnt; /* count of pools destroyed */ |
167 int32_t destroyCnt; /* count of pools destroyed */ |
167 #ifdef POOL_GLOBAL_STATISTICS |
168 #ifdef POOL_GLOBAL_STATISTICS |
168 PRUint32 blkAlloc; /* count of block allocations from heap */ |
169 PRUint32 blkAlloc; /* count of block allocations from heap */ |
169 PRUint32 blkFree; /* count of blocks freed to heap */ |
170 PRUint32 blkFree; /* count of blocks freed to heap */ |
170 #endif /* POOL_GLOBAL_STATISTICS */ |
171 #endif /* POOL_GLOBAL_STATISTICS */ |
171 }; |
172 }; |