1 /*Contains declarations used by memory-isomalloc.c to provide
2 migratable heap allocation to arbitrary clients.
4 #ifndef CMK_MEMORY_ISOMALLOC_H
5 #define CMK_MEMORY_ISOMALLOC_H
7 /*Grab CmiIsomalloc* protoypes, and CmiIsomallocBlock*/
9 #include "conv-config.h"
15 /****** Isomalloc: Migratable Memory Allocation ********/
16 /*Simple block-by-block interface:*/
17 void CmiIsomallocPup(pup_er p
,void **block
);
18 void CmiIsomallocFree(void *block
);
19 int CmiIsomallocEnabled();
20 void CmiEnableIsomalloc();
21 void CmiDisableIsomalloc();
23 CmiInt8
CmiIsomallocLength(void *block
);
24 int CmiIsomallocInRange(void *addr
);
26 #if CMK_USE_MEMPOOL_ISOMALLOC
30 /*List-of-blocks interface:*/
31 struct CmiIsomallocBlockList
{/*Circular doubly-linked list of blocks:*/
32 struct CmiIsomallocBlockList
*prev
, *next
;
33 #if CMK_USE_MEMPOOL_ISOMALLOC
34 struct mempool_type
*pool
;
36 /*actual data of block follows here...*/
38 typedef struct CmiIsomallocBlockList CmiIsomallocBlockList
;
40 /*Build/pup/destroy an entire blockList.*/
41 CmiIsomallocBlockList
*CmiIsomallocBlockListNew(void);
42 void CmiIsomallocBlockListPup(pup_er p
, CmiIsomallocBlockList
**l
);
43 void CmiIsomallocBlockListDelete(CmiIsomallocBlockList
*l
);
45 /*Allocate/free a block from this blockList*/
46 void *CmiIsomallocBlockListMalloc(CmiIsomallocBlockList
*l
,size_t nBytes
);
47 void *CmiIsomallocBlockListMallocAlign(CmiIsomallocBlockList
*l
,size_t align
,size_t nBytes
);
48 void CmiIsomallocBlockListFree(void *doomedMallocedBlock
);
50 /* Allocate a block from the blockList associated with a thread */
51 void *CmiIsomallocMallocForThread(CthThread th
, size_t nBytes
);
52 void *CmiIsomallocMallocAlignForThread(CthThread th
, size_t align
, size_t nBytes
);
54 /*Allocate non-migratable memory*/
55 void *malloc_nomigrate(size_t size
);
56 void free_nomigrate(void *mem
);
58 /*Reentrant versions of memory routines, used inside isomalloc*/
59 void *malloc_reentrant(size_t size
);
60 void free_reentrant(void *mem
);
62 /*Make this blockList active (returns the old blocklist).*/
63 CmiIsomallocBlockList
*CmiIsomallocBlockListActivate(CmiIsomallocBlockList
*l
);
64 CmiIsomallocBlockList
*CmiIsomallocBlockListCurrent();