Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
annotate vmalloc.h @ 118:e29bb31df078
changed log10 to log2
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Tue, 30 Aug 2011 17:45:14 +0200 |
| parents | 07e679ee2095 |
| children | 9b2b9bc2c362 |
| rev | line source |
|---|---|
| Me@50 | 1 /* |
| Me@50 | 2 * Copyright 2009 OpenSourceCodeStewardshipFoundation.org |
| Me@50 | 3 * Licensed under GNU General Public License version 2 |
| Me@50 | 4 * |
| Me@50 | 5 * Author: seanhalle@yahoo.com |
| Me@50 | 6 * |
| Me@50 | 7 * Created on November 14, 2009, 9:07 PM |
| Me@50 | 8 */ |
| Me@50 | 9 |
| Me@65 | 10 #ifndef _VMALLOC_H |
| Me@65 | 11 #define _VMALLOC_H |
| Me@65 | 12 |
| Me@50 | 13 #include <malloc.h> |
| msach@76 | 14 #include <inttypes.h> |
| Me@50 | 15 #include "VMS_primitive_data_types.h" |
| Me@50 | 16 |
| msach@101 | 17 #define SMALL_CHUNK_SIZE 32 |
| msach@101 | 18 #define SMALL_CHUNK_COUNT 4 |
| msach@101 | 19 #define LOWER_BOUND 128 |
| msach@101 | 20 #define CHUNK_INCREASE_RATE 1.25 |
| msach@102 | 21 #define MAX_SMALL_CHUNKS 20 |
| msach@102 | 22 #define SMALL_CHUNKS_ALLOCATION 5 |
| msach@101 | 23 |
| msach@118 | 24 #define LOG54 0.3219280948873623 |
| msach@118 | 25 #define LOG128 7 |
| msach@101 | 26 |
| Me@50 | 27 typedef struct _MallocProlog MallocProlog; |
| Me@50 | 28 |
| Me@50 | 29 struct _MallocProlog |
| Me@50 | 30 { |
| Me@50 | 31 MallocProlog *nextChunkInFreeList; |
| Me@50 | 32 MallocProlog *prevChunkInFreeList; |
| Me@50 | 33 MallocProlog *nextHigherInMem; |
| Me@50 | 34 MallocProlog *nextLowerInMem; |
| Me@50 | 35 }; |
| Me@50 | 36 //MallocProlog |
| msach@101 | 37 |
| msach@101 | 38 typedef struct MallocArrays MallocArrays; |
| msach@101 | 39 |
| msach@101 | 40 struct MallocArrays |
| msach@101 | 41 { |
| msach@101 | 42 MallocProlog **smallChunks; |
| msach@101 | 43 MallocProlog **bigChunks; |
| msach@116 | 44 uint64 bigChunksSearchVector[2]; |
| msach@102 | 45 void *memSpace; |
| msach@101 | 46 uint32 containerCount; |
| msach@101 | 47 }; |
| msach@101 | 48 //MallocArrays |
| Me@50 | 49 |
| Me@50 | 50 typedef struct |
| Me@50 | 51 { |
| Me@50 | 52 MallocProlog *firstChunkInFreeList; |
| msach@76 | 53 int32 numInList; //TODO not used |
| Me@50 | 54 } |
| Me@50 | 55 FreeListHead; |
| Me@50 | 56 |
| Me@50 | 57 void * |
| msach@76 | 58 VMS__malloc( size_t sizeRequested ); |
| Me@50 | 59 |
| msach@78 | 60 void * |
| msach@78 | 61 VMS__malloc_aligned( size_t sizeRequested ); |
| msach@78 | 62 |
| Me@50 | 63 void |
| Me@50 | 64 VMS__free( void *ptrToFree ); |
| Me@50 | 65 |
| Me@53 | 66 /*Allocates memory from the external system -- higher overhead |
| Me@53 | 67 */ |
| Me@53 | 68 void * |
| msach@76 | 69 VMS__malloc_in_ext( size_t sizeRequested ); |
| Me@53 | 70 |
| Me@53 | 71 /*Frees memory that was allocated in the external system -- higher overhead |
| Me@53 | 72 */ |
| Me@53 | 73 void |
| Me@53 | 74 VMS__free_in_ext( void *ptrToFree ); |
| Me@53 | 75 |
| Me@53 | 76 |
| msach@101 | 77 MallocArrays * |
| Me@53 | 78 VMS_ext__create_free_list(); |
| Me@50 | 79 |
| Me@50 | 80 void |
| msach@102 | 81 VMS_ext__free_free_list(MallocArrays *freeLists ); |
| Me@65 | 82 |
| Me@65 | 83 #endif |
