00001
00002
00003
00004
00005
00006
00007
00008 #undef BLOCK_ALLOC
00009 #undef PTR_HASH_ALLOC
00010 #undef PTR_HASH_ALLOC_FIXED
00011 #undef BLOCK_ALLOC_FILL_PAGES
00012 #undef PTR_HASH_ALLOC_FILL_PAGES
00013 #undef PTR_HASH_ALLOC_FIXED_FILL_PAGES
00014
00015 #ifndef PIKE_HASH_T
00016 #define PIKE_HASH_T size_t
00017 #endif
00018
00019 #ifdef BLOCK_ALLOC_USED
00020 #error "block_alloc.h must be included after all uses of block_alloc_h.h"
00021 #endif
00022
00023 #define BLOCK_ALLOC(DATA,SIZE) \
00024 struct DATA *PIKE_CONCAT(alloc_,DATA)(void); \
00025 void PIKE_CONCAT3(new_,DATA,_context)(void); \
00026 void PIKE_CONCAT3(really_free_,DATA,_unlocked)(struct DATA *d); \
00027 void PIKE_CONCAT(really_free_,DATA)(struct DATA *d); \
00028 void PIKE_CONCAT3(free_all_,DATA,_blocks)(void); \
00029 void PIKE_CONCAT3(count_memory_in_,DATA,s)(INT32 *num, INT32 *size); \
00030 void PIKE_CONCAT3(init_,DATA,_blocks)(void)
00031
00032
00033 #define PTR_HASH_ALLOC(DATA,BSIZE) \
00034 BLOCK_ALLOC(DATA,BSIZE); \
00035 extern struct DATA **PIKE_CONCAT(DATA,_hash_table); \
00036 extern size_t PIKE_CONCAT(DATA,_hash_table_size); \
00037 struct DATA *PIKE_CONCAT(find_,DATA)(void *ptr); \
00038 struct DATA *PIKE_CONCAT3(make_,DATA,_unlocked) \
00039 (void *ptr, PIKE_HASH_T hval); \
00040 struct DATA *PIKE_CONCAT(make_,DATA)(void *ptr); \
00041 struct DATA *PIKE_CONCAT(get_,DATA)(void *ptr); \
00042 int PIKE_CONCAT3(check_,DATA,_semafore)(void *ptr); \
00043 void PIKE_CONCAT(move_,DATA)(struct DATA *block, void *new_ptr); \
00044 int PIKE_CONCAT(remove_,DATA)(void *ptr); \
00045 void PIKE_CONCAT3(low_init_,DATA,_hash)(size_t); \
00046 void PIKE_CONCAT3(init_,DATA,_hash)(void); \
00047 void PIKE_CONCAT3(exit_,DATA,_hash)(void)
00048
00049 #define PTR_HASH_ALLOC_FIXED(DATA,BSIZE) \
00050 PTR_HASH_ALLOC(DATA,BSIZE)
00051
00052 #define BLOCK_ALLOC_FILL_PAGES(DATA,PAGES) BLOCK_ALLOC(DATA, n/a)
00053 #define PTR_HASH_ALLOC_FILL_PAGES(DATA,PAGES) PTR_HASH_ALLOC(DATA, n/a)
00054 #define PTR_HASH_ALLOC_FIXED_FILL_PAGES(DATA,PAGES) PTR_HASH_ALLOC_FIXED(DATA, n/a)
00055
00056 #define PTR_HASH_LOOP(DATA,HVAL,PTR) \
00057 for ((HVAL) = (PIKE_HASH_T)PIKE_CONCAT(DATA,_hash_table_size); (HVAL)-- > 0;) \
00058 for ((PTR) = PIKE_CONCAT(DATA,_hash_table)[HVAL]; \
00059 (PTR); (PTR) = (PTR)->BLOCK_ALLOC_NEXT)
00060
00061
00062
00063 #define BLOCK_ALLOC_NEXT next
00064
00065
00066
00067 #define PTR_HASH_ALLOC_DATA data