00001 /*Contains declarations used by memory-isomalloc.C to provide 00002 migratable heap allocation to arbitrary clients. 00003 */ 00004 #ifndef CMK_MEMORY_ISOMALLOC_H 00005 #define CMK_MEMORY_ISOMALLOC_H 00006 00007 /*Grab CmiIsomalloc* protoypes, and CmiIsomallocBlock*/ 00008 #include <stddef.h> 00009 #include "conv-config.h" 00010 00011 #ifdef __cplusplus 00012 extern "C" { 00013 #endif 00014 00015 /****** Isomalloc: Migratable Memory Allocation ********/ 00016 /*Simple block-by-block interface:*/ 00017 void CmiIsomallocPup(pup_er p,void **block); 00018 void CmiIsomallocFree(void *block); 00019 int CmiIsomallocEnabled(); 00020 void CmiEnableIsomalloc(); 00021 void CmiDisableIsomalloc(); 00022 00023 CmiInt8 CmiIsomallocLength(void *block); 00024 int CmiIsomallocInRange(void *addr); 00025 00026 #if CMK_USE_MEMPOOL_ISOMALLOC 00027 struct mempool_type; 00028 #endif 00029 00030 /*List-of-blocks interface:*/ 00031 struct CmiIsomallocBlockList {/*Circular doubly-linked list of blocks:*/ 00032 struct CmiIsomallocBlockList *prev, *next; 00033 #if CMK_USE_MEMPOOL_ISOMALLOC 00034 struct mempool_type *pool; 00035 #endif 00036 /*actual data of block follows here...*/ 00037 }; 00038 typedef struct CmiIsomallocBlockList CmiIsomallocBlockList; 00039 00040 /*Build/pup/destroy an entire blockList.*/ 00041 CmiIsomallocBlockList *CmiIsomallocBlockListNew(void); 00042 void CmiIsomallocBlockListPup(pup_er p, CmiIsomallocBlockList **l); 00043 void CmiIsomallocBlockListDelete(CmiIsomallocBlockList *l); 00044 00045 /*Allocate/free a block from this blockList*/ 00046 void *CmiIsomallocBlockListMalloc(CmiIsomallocBlockList *l,size_t nBytes); 00047 void *CmiIsomallocBlockListMallocAlign(CmiIsomallocBlockList *l,size_t align,size_t nBytes); 00048 void CmiIsomallocBlockListFree(void *doomedMallocedBlock); 00049 00050 /* Allocate a block from the blockList associated with a thread */ 00051 void *CmiIsomallocMallocForThread(CthThread th, size_t nBytes); 00052 void *CmiIsomallocMallocAlignForThread(CthThread th, size_t align, size_t nBytes); 00053 00054 /*Allocate non-migratable memory*/ 00055 void *malloc_nomigrate(size_t size); 00056 void free_nomigrate(void *mem); 00057 00058 /*Reentrant versions of memory routines, used inside isomalloc*/ 00059 void *malloc_reentrant(size_t size); 00060 void free_reentrant(void *mem); 00061 00062 /*Make this blockList active (returns the old blocklist).*/ 00063 CmiIsomallocBlockList *CmiIsomallocBlockListActivate(CmiIsomallocBlockList *l); 00064 CmiIsomallocBlockList *CmiIsomallocBlockListCurrent(); 00065 00066 #ifdef __cplusplus 00067 } 00068 #endif 00069 00070 #endif 00071