e576bb2002-10-11Martin Nilsson /* || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information.
7b62e22011-04-25Martin Stjernholm || $Id$
e576bb2002-10-11Martin Nilsson */
4218011999-01-31Fredrik Hübinette (Hubbe) #undef BLOCK_ALLOC
fc2c831999-04-01Fredrik Hübinette (Hubbe) #undef PTR_HASH_ALLOC
afbc722001-09-06Fredrik Hübinette (Hubbe) #undef PTR_HASH_ALLOC_FIXED
db1aac2002-11-24Martin Stjernholm #undef BLOCK_ALLOC_FILL_PAGES #undef PTR_HASH_ALLOC_FILL_PAGES #undef PTR_HASH_ALLOC_FIXED_FILL_PAGES
fc2c831999-04-01Fredrik Hübinette (Hubbe) 
bee7632003-02-24Henrik Grubbström (Grubba) #ifndef PIKE_HASH_T
966c222003-06-30Martin Stjernholm #define PIKE_HASH_T size_t
bee7632003-02-24Henrik Grubbström (Grubba) #endif /* !PIKE_HASH_T */
9977882004-02-06Henrik Grubbström (Grubba) #ifdef BLOCK_ALLOC_USED #error "block_alloc.h must be included after all uses of block_alloc_h.h" #endif /* BLOCK_ALLOC_USED */
99b58b1999-09-26Henrik Grubbström (Grubba) #define BLOCK_ALLOC(DATA,SIZE) \ struct DATA *PIKE_CONCAT(alloc_,DATA)(void); \
25bdc72001-08-31Martin Stjernholm void PIKE_CONCAT3(really_free_,DATA,_unlocked)(struct DATA *d); \
99b58b1999-09-26Henrik Grubbström (Grubba) void PIKE_CONCAT(really_free_,DATA)(struct DATA *d); \ void PIKE_CONCAT3(free_all_,DATA,_blocks)(void); \ void PIKE_CONCAT3(count_memory_in_,DATA,s)(INT32 *num, INT32 *size); \
25bdc72001-08-31Martin Stjernholm void PIKE_CONCAT3(init_,DATA,_blocks)(void); \
fc2c831999-04-01Fredrik Hübinette (Hubbe)  #define PTR_HASH_ALLOC(DATA,BSIZE) \ BLOCK_ALLOC(DATA,BSIZE) \
3f84322000-04-23Martin Stjernholm extern struct DATA **PIKE_CONCAT(DATA,_hash_table); \
59e0112001-07-03Fredrik Hübinette (Hubbe) extern size_t PIKE_CONCAT(DATA,_hash_table_size); \
fc2c831999-04-01Fredrik Hübinette (Hubbe) struct DATA *PIKE_CONCAT(find_,DATA)(void *ptr); \
bee7632003-02-24Henrik Grubbström (Grubba) struct DATA *PIKE_CONCAT3(make_,DATA,_unlocked) \ (void *ptr, PIKE_HASH_T hval); \
d77bd52002-12-01Martin Stjernholm struct DATA *PIKE_CONCAT(make_,DATA)(void *ptr); \
fc2c831999-04-01Fredrik Hübinette (Hubbe) struct DATA *PIKE_CONCAT(get_,DATA)(void *ptr); \ int PIKE_CONCAT3(check_,DATA,_semafore)(void *ptr); \
e13e712002-12-01Martin Stjernholm void PIKE_CONCAT(move_,DATA)(struct DATA *block, void *new_ptr); \
e6a9051999-09-26Henrik Grubbström (Grubba) int PIKE_CONCAT(remove_,DATA)(void *ptr); \
afbc722001-09-06Fredrik Hübinette (Hubbe) void PIKE_CONCAT3(low_init_,DATA,_hash)(size_t); \
fc2c831999-04-01Fredrik Hübinette (Hubbe) void PIKE_CONCAT3(init_,DATA,_hash)(void); \ void PIKE_CONCAT3(exit_,DATA,_hash)(void); \
afbc722001-09-06Fredrik Hübinette (Hubbe) #define PTR_HASH_ALLOC_FIXED(DATA,BSIZE) \
e1ee312002-11-25Martin Stjernholm PTR_HASH_ALLOC(DATA,BSIZE);
afbc722001-09-06Fredrik Hübinette (Hubbe) 
db1aac2002-11-24Martin Stjernholm #define BLOCK_ALLOC_FILL_PAGES(DATA,PAGES) BLOCK_ALLOC(DATA, n/a) #define PTR_HASH_ALLOC_FILL_PAGES(DATA,PAGES) PTR_HASH_ALLOC(DATA, n/a) #define PTR_HASH_ALLOC_FIXED_FILL_PAGES(DATA,PAGES) PTR_HASH_ALLOC_FIXED(DATA, n/a)
3f84322000-04-23Martin Stjernholm #define PTR_HASH_LOOP(DATA,HVAL,PTR) \
bee7632003-02-24Henrik Grubbström (Grubba)  for ((HVAL) = (PIKE_HASH_T)PIKE_CONCAT(DATA,_hash_table_size); (HVAL)-- > 0;) \
3f84322000-04-23Martin Stjernholm  for ((PTR) = PIKE_CONCAT(DATA,_hash_table)[HVAL]; \ (PTR); (PTR) = (PTR)->BLOCK_ALLOC_NEXT)
fc2c831999-04-01Fredrik Hübinette (Hubbe) 
db1aac2002-11-24Martin Stjernholm /* The name of a member in the BLOCK_ALLOC struct big enough to * contain a void * (used for the free list). */
3f84322000-04-23Martin Stjernholm #define BLOCK_ALLOC_NEXT next
db1aac2002-11-24Martin Stjernholm  /* The name of a void * member in the PTR_HASH_ALLOC struct containing * the key. */ #define PTR_HASH_ALLOC_DATA data