Me@50: /* Me@50: * Copyright 2009 OpenSourceCodeStewardshipFoundation.org Me@50: * Licensed under GNU General Public License version 2 Me@50: * Me@50: * Author: seanhalle@yahoo.com Me@50: * Me@50: * Created on November 14, 2009, 9:07 PM Me@50: */ Me@65: #ifndef _VMALLOC_H Me@65: #define _VMALLOC_H Me@65: Me@50: #include msach@76: #include Me@50: #include "VMS_primitive_data_types.h" msach@132: #include "ProcrContext.h" Me@50: msach@101: #define SMALL_CHUNK_SIZE 32 msach@101: #define SMALL_CHUNK_COUNT 4 msach@125: #define LOWER_BOUND 128 //Biggest chunk size that is created for the small chunks msach@125: #define BIG_LOWER_BOUND 160 //Smallest chunk size that is created for the big chunks msach@101: msach@118: #define LOG54 0.3219280948873623 msach@118: #define LOG128 7 msach@101: Me@50: typedef struct _MallocProlog MallocProlog; Me@50: Me@50: struct _MallocProlog Me@50: { Me@50: MallocProlog *nextChunkInFreeList; Me@50: MallocProlog *prevChunkInFreeList; Me@50: MallocProlog *nextHigherInMem; Me@50: MallocProlog *nextLowerInMem; msach@132: }; Me@50: //MallocProlog msach@147: typedef struct MallocArrays MallocArrays; msach@147: msach@147: typedef struct msach@147: { msach@147: uintptr_t procrID; msach@147: MallocProlog *prevChunkInFreeList; msach@147: MallocProlog *nextHigherInMem; msach@147: MallocProlog *nextLowerInMem; msach@147: } MallocPrologAllocated; msach@101: msach@139: struct MallocArrays msach@101: { msach@101: MallocProlog **smallChunks; msach@101: MallocProlog **bigChunks; msach@116: uint64 bigChunksSearchVector[2]; msach@102: void *memSpace; msach@101: uint32 containerCount; msach@101: }; msach@139: //MallocArray msach@139: Me@50: typedef struct Me@50: { Me@50: MallocProlog *firstChunkInFreeList; msach@76: int32 numInList; //TODO not used msach@132: } FreeListHead; Me@50: Me@50: void * msach@132: VMS__malloc_on_core(size_t sizeRequested, int procrID); Me@50: msach@78: void * msach@132: VMS__malloc(size_t sizeRequested); msach@132: msach@132: void * msach@132: VMS__malloc_in_lib(size_t sizeRequested, VirtProcr *VProc); msach@78: Me@50: void Me@50: VMS__free( void *ptrToFree ); Me@50: msach@132: void msach@132: VMS__free_in_lib(void *ptrToFree, VirtProcr *VProc); msach@132: msach@132: void msach@132: VMS__free_on_core(void *ptrToFree, int procrID); msach@132: Me@53: /*Allocates memory from the external system -- higher overhead Me@53: */ Me@53: void * msach@76: VMS__malloc_in_ext( size_t sizeRequested ); Me@53: Me@53: /*Frees memory that was allocated in the external system -- higher overhead Me@53: */ Me@53: void Me@53: VMS__free_in_ext( void *ptrToFree ); Me@53: msach@101: MallocArrays * Me@53: VMS_ext__create_free_list(); Me@50: Me@50: void msach@102: VMS_ext__free_free_list(MallocArrays *freeLists ); Me@65: Me@65: #endif