annotate vmalloc.h @ 209:0c83ea8adefc

Close to compilable version of common_ancestor -- still includes HW dep stuff
author Some Random Person <seanhalle@yahoo.com>
date Sun, 04 Mar 2012 14:26:35 -0800
parents eaf7e4c58c9e
children
rev   line source
seanhalle@208 1 /*
seanhalle@208 2 * Copyright 2009 OpenSourceCodeStewardshipFoundation.org
seanhalle@208 3 * Licensed under GNU General Public License version 2
seanhalle@208 4 *
seanhalle@208 5 * Author: seanhalle@yahoo.com
seanhalle@208 6 *
seanhalle@208 7 * Created on November 14, 2009, 9:07 PM
seanhalle@208 8 */
seanhalle@208 9
seanhalle@208 10 #ifndef _VMALLOC_H
seanhalle@208 11 #define _VMALLOC_H
seanhalle@208 12
seanhalle@208 13 #include <malloc.h>
seanhalle@208 14 #include <inttypes.h>
seanhalle@208 15 #include "VMS_primitive_data_types.h"
seanhalle@208 16
seanhalle@209 17 #define SMALL_CHUNK_SIZE 32
seanhalle@209 18 #define SMALL_CHUNK_COUNT 4
seanhalle@209 19 #define LOWER_BOUND 128 //Biggest chunk size that is created for the small chunks
seanhalle@209 20 #define BIG_LOWER_BOUND 160 //Smallest chunk size that is created for the big chunks
seanhalle@209 21
seanhalle@209 22 #define LOG54 0.3219280948873623
seanhalle@209 23 #define LOG128 7
seanhalle@209 24
seanhalle@208 25 typedef struct _MallocProlog MallocProlog;
seanhalle@208 26
seanhalle@208 27 struct _MallocProlog
seanhalle@208 28 {
seanhalle@208 29 MallocProlog *nextChunkInFreeList;
seanhalle@208 30 MallocProlog *prevChunkInFreeList;
seanhalle@208 31 MallocProlog *nextHigherInMem;
seanhalle@208 32 MallocProlog *nextLowerInMem;
seanhalle@208 33 };
seanhalle@208 34 //MallocProlog
seanhalle@209 35
seanhalle@209 36 typedef struct MallocArrays MallocArrays;
seanhalle@209 37
seanhalle@209 38 struct MallocArrays
seanhalle@209 39 {
seanhalle@209 40 MallocProlog **smallChunks;
seanhalle@209 41 MallocProlog **bigChunks;
seanhalle@209 42 uint64 bigChunksSearchVector[2];
seanhalle@209 43 void *memSpace;
seanhalle@209 44 uint32 containerCount;
seanhalle@209 45 };
seanhalle@209 46 //MallocArrays
seanhalle@208 47
seanhalle@208 48 typedef struct
seanhalle@208 49 {
seanhalle@208 50 MallocProlog *firstChunkInFreeList;
seanhalle@208 51 int32 numInList; //TODO not used
seanhalle@208 52 }
seanhalle@208 53 FreeListHead;
seanhalle@208 54
seanhalle@208 55 void *
seanhalle@208 56 VMS_int__malloc( size_t sizeRequested );
seanhalle@209 57 #define VMS_PI__malloc VMS_int__malloc
seanhalle@209 58 #define VMS_WL__malloc VMS_int__malloc /*TODO: Bug -- Not protected!! */
seanhalle@209 59 #define VMS_App__malloc VMS_int__malloc /*TODO: Bug -- Not protected!! */
seanhalle@208 60
seanhalle@208 61 void *
seanhalle@208 62 VMS_int__malloc_aligned( size_t sizeRequested );
seanhalle@209 63 #define VMS_PI__malloc_aligned VMS_int__malloc_aligned
seanhalle@209 64 #define VMS_WL__malloc_aligned VMS_int__malloc_aligned
seanhalle@208 65
seanhalle@208 66 void
seanhalle@208 67 VMS_int__free( void *ptrToFree );
seanhalle@209 68 #define VMS_PI__free VMS_int__free
seanhalle@209 69 #define VMS_WL__free VMS_int__free /*TODO: Bug -- Not protected!! */
seanhalle@209 70 #define VMS_App__free VMS_int__free /*TODO: Bug -- Not protected!! */
seanhalle@208 71
seanhalle@208 72
seanhalle@208 73
seanhalle@208 74 /*Allocates memory from the external system -- higher overhead
seanhalle@208 75 */
seanhalle@208 76 void *
seanhalle@209 77 VMS_ext__malloc_in_ext( size_t sizeRequested );
seanhalle@208 78
seanhalle@208 79 /*Frees memory that was allocated in the external system -- higher overhead
seanhalle@208 80 */
seanhalle@208 81 void
seanhalle@209 82 VMS_ext__free_in_ext( void *ptrToFree );
seanhalle@208 83
seanhalle@208 84
seanhalle@209 85 MallocArrays *
seanhalle@208 86 VMS_ext__create_free_list();
seanhalle@208 87
seanhalle@208 88 void
seanhalle@209 89 VMS_ext__free_free_list(MallocArrays *freeLists );
seanhalle@208 90
seanhalle@208 91 #endif