diff 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
line diff
     1.1 --- a/vmalloc.h	Wed Feb 22 11:39:12 2012 -0800
     1.2 +++ b/vmalloc.h	Sun Mar 04 14:26:35 2012 -0800
     1.3 @@ -14,6 +14,14 @@
     1.4  #include <inttypes.h>
     1.5  #include "VMS_primitive_data_types.h"
     1.6  
     1.7 +#define SMALL_CHUNK_SIZE 32
     1.8 +#define SMALL_CHUNK_COUNT 4
     1.9 +#define LOWER_BOUND     128  //Biggest chunk size that is created for the small chunks
    1.10 +#define BIG_LOWER_BOUND 160  //Smallest chunk size that is created for the big chunks
    1.11 +
    1.12 +#define LOG54 0.3219280948873623
    1.13 +#define LOG128 7
    1.14 +
    1.15  typedef struct _MallocProlog MallocProlog;
    1.16  
    1.17  struct _MallocProlog
    1.18 @@ -24,6 +32,18 @@
    1.19     MallocProlog *nextLowerInMem;
    1.20   };
    1.21  //MallocProlog
    1.22 + 
    1.23 + typedef struct MallocArrays MallocArrays;
    1.24 +
    1.25 + struct MallocArrays
    1.26 + {
    1.27 +     MallocProlog **smallChunks;
    1.28 +     MallocProlog **bigChunks;
    1.29 +     uint64       bigChunksSearchVector[2];
    1.30 +     void         *memSpace;
    1.31 +     uint32       containerCount;
    1.32 + };
    1.33 + //MallocArrays
    1.34  
    1.35  typedef struct
    1.36   {
    1.37 @@ -34,57 +54,38 @@
    1.38  
    1.39  void *
    1.40  VMS_int__malloc( size_t sizeRequested );
    1.41 +#define VMS_PI__malloc  VMS_int__malloc
    1.42 +#define VMS_WL__malloc  VMS_int__malloc /*TODO: Bug -- Not protected!! */
    1.43 +#define VMS_App__malloc VMS_int__malloc /*TODO: Bug -- Not protected!! */
    1.44  
    1.45  void *
    1.46  VMS_int__malloc_aligned( size_t sizeRequested );
    1.47 +#define VMS_PI__malloc_aligned VMS_int__malloc_aligned
    1.48 +#define VMS_WL__malloc_aligned VMS_int__malloc_aligned
    1.49  
    1.50  void
    1.51  VMS_int__free( void *ptrToFree );
    1.52 +#define VMS_PI__free  VMS_int__free
    1.53 +#define VMS_WL__free  VMS_int__free /*TODO: Bug -- Not protected!! */
    1.54 +#define VMS_App__free VMS_int__free /*TODO: Bug -- Not protected!! */
    1.55  
    1.56 -#define VMS_PI__malloc VMS_int__malloc
    1.57 -#define VMS_PI__malloc_aligned VMS_int__malloc_aligned
    1.58 -#define VMS_PI__free VMS_int__free
    1.59 -/* For now, the PI is protected by master lock, so int malloc fine
    1.60 -void *
    1.61 -VMS_PI__malloc( size_t sizeRequested );
    1.62  
    1.63 -void *
    1.64 -VMS_PI__malloc_aligned( size_t sizeRequested );
    1.65 -
    1.66 -void
    1.67 -VMS_PI__free( void *ptrToFree );
    1.68 -*/
    1.69 -
    1.70 -//TODO: protect WL malloc from concurrency!! shared freelist can be corrupted
    1.71 -#define VMS_WL__malloc VMS_int__malloc
    1.72 -#define VMS_WL__malloc_aligned VMS_int__malloc_aligned
    1.73 -#define VMS_WL__free VMS_int__free
    1.74 -/*
    1.75 -void *
    1.76 -VMS_WL__malloc( size_t sizeRequested );
    1.77 -
    1.78 -void *
    1.79 -VMS_WL__malloc_aligned( size_t sizeRequested );
    1.80 -
    1.81 -void
    1.82 -VMS_WL__free( void *ptrToFree );
    1.83 -*/
    1.84  
    1.85  /*Allocates memory from the external system -- higher overhead
    1.86   */
    1.87  void *
    1.88 -VMS__malloc_in_ext( size_t sizeRequested );
    1.89 +VMS_ext__malloc_in_ext( size_t sizeRequested );
    1.90  
    1.91  /*Frees memory that was allocated in the external system -- higher overhead
    1.92   */
    1.93  void
    1.94 -VMS__free_in_ext( void *ptrToFree );
    1.95 +VMS_ext__free_in_ext( void *ptrToFree );
    1.96  
    1.97  
    1.98 -MallocProlog *
    1.99 +MallocArrays *
   1.100  VMS_ext__create_free_list();
   1.101  
   1.102  void
   1.103 -VMS_ext__free_free_list( MallocProlog *freeListHead );
   1.104 +VMS_ext__free_free_list(MallocArrays *freeLists );
   1.105  
   1.106  #endif
   1.107 \ No newline at end of file