Main Page | Class List | Directories | File List | Class Members | File Members

block_alloc_h.h

Go to the documentation of this file.
00001 /*
00002 || This file is part of Pike. For copyright information see COPYRIGHT.
00003 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
00004 || for more information.
00005 || $Id: block_alloc_h.h,v 1.23 2005/04/08 16:52:29 grubba Exp $
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 /* !PIKE_HASH_T */
00018 
00019 #ifdef BLOCK_ALLOC_USED
00020 #error "block_alloc.h must be included after all uses of block_alloc_h.h"
00021 #endif /* BLOCK_ALLOC_USED */
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 /* The name of a member in the BLOCK_ALLOC struct big enough to
00062  * contain a void * (used for the free list). */
00063 #define BLOCK_ALLOC_NEXT next
00064 
00065 /* The name of a void * member in the PTR_HASH_ALLOC struct containing
00066  * the key. */
00067 #define PTR_HASH_ALLOC_DATA data

Generated on Fri Jul 22 23:44:24 2005 for Pike by  doxygen 1.3.9.1