changeset 265:104d0b27de12 Common_Ancestor

make DEBUG__printf variadic, add realloc, remove some dead code
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Thu, 27 Dec 2012 12:19:59 +0100
parents 094ad1bdeaec
children 68212347d1d8
files Defines/VMS_defs__HW_constants.h Services_Offered_by_VMS/Debugging/DEBUG__macros.h Services_Offered_by_VMS/Memory_Handling/vmalloc.c Services_Offered_by_VMS/Memory_Handling/vmalloc.h Services_Offered_by_VMS/Memory_Handling/vmalloc.supp VMS__startup_and_shutdown.c
diffstat 6 files changed, 87 insertions(+), 18 deletions(-) [+]
line diff
     1.1 --- a/Defines/VMS_defs__HW_constants.h	Mon Oct 29 17:02:43 2012 +0100
     1.2 +++ b/Defines/VMS_defs__HW_constants.h	Thu Dec 27 12:19:59 2012 +0100
     1.3 @@ -33,7 +33,7 @@
     1.4  #define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */
     1.5  
     1.6     // memory for VMS_int__malloc
     1.7 -#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x8000000 /* 128M */
     1.8 +#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x10000000 /* 256M */
     1.9  
    1.10     //Frequency of TS counts -- have to do tests to verify
    1.11     //NOTE: turn off (in BIOS)  TURBO-BOOST and SPEED-STEP else won't be const
     2.1 --- a/Services_Offered_by_VMS/Debugging/DEBUG__macros.h	Mon Oct 29 17:02:43 2012 +0100
     2.2 +++ b/Services_Offered_by_VMS/Debugging/DEBUG__macros.h	Thu Dec 27 12:19:59 2012 +0100
     2.3 @@ -15,10 +15,10 @@
     2.4  /*
     2.5   */
     2.6  #ifdef DEBUG__TURN_ON_DEBUG_PRINT
     2.7 -   #define DEBUG__printf(  bool, msg) \
     2.8 +   #define DEBUG__printf(  bool, msg, ...) \
     2.9        do{\
    2.10           if(bool)\
    2.11 -          { printf(msg);\
    2.12 +          { printf(msg, ##__VA_ARGS__);\
    2.13              printf(" | function: %s\n", __FUNCTION__);\
    2.14              fflush(stdin);\
    2.15            }\
    2.16 @@ -51,10 +51,30 @@
    2.17            }\
    2.18          }while(0);/*macro magic to isolate var-names*/
    2.19  
    2.20 +   #define DEBUG__printf_w_task(bool, taskStub, msg, ...) \
    2.21 +        do{\
    2.22 +        if(bool)\
    2.23 +          { printf("Task ");\
    2.24 +          if(taskStub->taskID) {\
    2.25 +                int i;\
    2.26 +                for(i=1;i<taskStub->taskID[0];i++)\
    2.27 +                {\
    2.28 +                   printf("%d,",taskStub->taskID[i]);\
    2.29 +                }\
    2.30 +                printf("%d: ",taskStub->taskID[i]);\
    2.31 +          } else {\
    2.32 +                printf("%p: ", taskStub);\
    2.33 +          }\
    2.34 +          printf(msg , ##__VA_ARGS__); \
    2.35 +          printf(" | function: %s\n", __FUNCTION__);\
    2.36 +            fflush(stdin);\
    2.37 +          }\
    2.38 +        }while(0)
    2.39  #else
    2.40 -   #define DEBUG__printf(  bool, msg)         
    2.41 +   #define DEBUG__printf(  bool, msg, ...)         
    2.42     #define DEBUG__printf1( bool, msg, param)  
    2.43     #define DEBUG__printf2( bool, msg, p1, p2) 
    2.44 +   #define DEBUG__printf_w_task(bool, taskStub, msg, ...)
    2.45  #endif
    2.46  
    2.47  //============================= ERROR MSGs ============================
     3.1 --- a/Services_Offered_by_VMS/Memory_Handling/vmalloc.c	Mon Oct 29 17:02:43 2012 +0100
     3.2 +++ b/Services_Offered_by_VMS/Memory_Handling/vmalloc.c	Thu Dec 27 12:19:59 2012 +0100
     3.3 @@ -301,7 +301,7 @@
     3.4   }
     3.5  
     3.6  void *
     3.7 -VMS_WL__malloc( int32 sizeRequested )
     3.8 +VMS_WL__malloc( size_t sizeRequested )
     3.9   { void *ret;
    3.10   
    3.11     VMS_int__get_master_lock();
    3.12 @@ -324,7 +324,7 @@
    3.13     MallocArrays* freeLists = _VMSMasterEnv->freeLists;
    3.14     MallocProlog *chunkToFree = (MallocProlog*)ptrToFree - 1;
    3.15     uint32 containerIdx;
    3.16 -   
    3.17 +      
    3.18     //Check for free neighbors
    3.19     if(chunkToFree->nextLowerInMem)
    3.20     {
    3.21 @@ -375,7 +375,39 @@
    3.22     VMS_int__get_master_lock();
    3.23     VMS_int__free( ptrToFree );
    3.24     VMS_int__release_master_lock();
    3.25 - }
    3.26 +}
    3.27 +
    3.28 +/*
    3.29 + * This is sequential code, meant to only be called from the Master, not from
    3.30 + * any slave Slvs.
    3.31 + */
    3.32 +void*
    3.33 +VMS_int__realloc(void *oldPtr, size_t sizeRequested) {
    3.34 +    
    3.35 +    
    3.36 +    void* newPtr = VMS_int__malloc(sizeRequested);
    3.37 +    
    3.38 +    if (oldPtr) {
    3.39 +        MallocProlog *chunkToFree = (MallocProlog*) oldPtr - 1;
    3.40 +        size_t chunkSize = getChunkSize(chunkToFree);
    3.41 +        
    3.42 +        memcpy(newPtr,oldPtr,chunkSize);
    3.43 +        
    3.44 +        VMS_int__free(oldPtr);
    3.45 +    }
    3.46 +   
    3.47 +    return newPtr;
    3.48 +}
    3.49 +
    3.50 +void*
    3.51 +VMS_WL__realloc(void *oldPtr, size_t sizeRequested)
    3.52 + {
    3.53 +    
    3.54 +   VMS_int__get_master_lock();
    3.55 +   void* newPtr = VMS_int__realloc(oldPtr, sizeRequested);
    3.56 +   VMS_int__release_master_lock();
    3.57 +   return newPtr;
    3.58 +}
    3.59  
    3.60  /*
    3.61   * Designed to be called from the main thread outside of VMS, during init
    3.62 @@ -452,7 +484,7 @@
    3.63   */
    3.64  void
    3.65  VMS_ext__free_free_list( MallocArrays *freeLists )
    3.66 - {    
    3.67 + { 
    3.68     free(freeLists->memSpace);
    3.69     free(freeLists->bigChunks);
    3.70     free(freeLists->smallChunks);
     4.1 --- a/Services_Offered_by_VMS/Memory_Handling/vmalloc.h	Mon Oct 29 17:02:43 2012 +0100
     4.2 +++ b/Services_Offered_by_VMS/Memory_Handling/vmalloc.h	Thu Dec 27 12:19:59 2012 +0100
     4.3 @@ -14,7 +14,7 @@
     4.4  
     4.5  #include "VMS_impl/VMS_primitive_data_types.h"
     4.6  
     4.7 -#define SERVICE__TURN_ON_VALGRIND
     4.8 +//#define SERVICE__TURN_ON_VALGRIND
     4.9  
    4.10  #ifdef SERVICE__TURN_ON_VALGRIND
    4.11  #include "../valgrind/memcheck.h"
    4.12 @@ -63,10 +63,18 @@
    4.13  #define VMS_PI__malloc  VMS_int__malloc
    4.14  
    4.15  void *
    4.16 -VMS_WL__malloc( int32  sizeRequested ); /*BUG: -- get master lock */
    4.17 +VMS_WL__malloc( size_t  sizeRequested ); /*BUG: -- get master lock */
    4.18  #define VMS_App__malloc  VMS_WL__malloc
    4.19  
    4.20  void *
    4.21 +VMS_int__realloc(void *oldPtr,  size_t sizeRequested );
    4.22 +#define VMS_PI__realloc  VMS_int__realloc
    4.23 +
    4.24 +void *
    4.25 +VMS_WL__realloc(void *oldPtr,  size_t  sizeRequested ); /*BUG: -- get master lock */
    4.26 +#define VMS_App__remalloc  VMS_WL__realloc
    4.27 +
    4.28 +void *
    4.29  VMS_int__malloc_aligned( size_t sizeRequested );
    4.30  #define VMS_PI__malloc_aligned VMS_int__malloc_aligned
    4.31  
     5.1 --- a/Services_Offered_by_VMS/Memory_Handling/vmalloc.supp	Mon Oct 29 17:02:43 2012 +0100
     5.2 +++ b/Services_Offered_by_VMS/Memory_Handling/vmalloc.supp	Thu Dec 27 12:19:59 2012 +0100
     5.3 @@ -27,3 +27,16 @@
     5.4     ...
     5.5     fun:VMS_int__malloc
     5.6  }
     5.7 +
     5.8 +{
     5.9 +   vmsmalloc
    5.10 +   Memcheck:Addr8
    5.11 +   ...
    5.12 +   fun:VMS_int__free
    5.13 +}
    5.14 +{
    5.15 +   vmsmalloc
    5.16 +   Memcheck:Addr4
    5.17 +   ...
    5.18 +   fun:VMS_int__free
    5.19 +}
     6.1 --- a/VMS__startup_and_shutdown.c	Mon Oct 29 17:02:43 2012 +0100
     6.2 +++ b/VMS__startup_and_shutdown.c	Thu Dec 27 12:19:59 2012 +0100
     6.3 @@ -271,7 +271,6 @@
     6.4  void
     6.5  create_masterEnv()
     6.6   { MasterEnv       *masterEnv;
     6.7 -   VMSQueueStruc  **readyToAnimateQs;
     6.8     int              coreIdx;
     6.9     SlaveVP        **masterVPs;
    6.10     AnimSlot     ***allAnimSlots; //ptr to array of ptrs
    6.11 @@ -289,8 +288,6 @@
    6.12     //===================== Only VMS__malloc after this ====================
    6.13     masterEnv     = (MasterEnv*)_VMSMasterEnv;
    6.14     
    6.15 -      //Make a readyToAnimateQ for each core controller
    6.16 -   readyToAnimateQs = VMS_int__malloc( NUM_CORES * sizeof(VMSQueueStruc *) );
    6.17     masterVPs        = VMS_int__malloc( NUM_CORES * sizeof(SlaveVP *) );
    6.18  
    6.19        //One array for each core, several in array, core's masterVP scheds all
    6.20 @@ -301,8 +298,6 @@
    6.21     _VMSMasterEnv->numSlavesCreated = 0;  //used by create slave to set ID
    6.22     for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ )
    6.23      {    
    6.24 -      readyToAnimateQs[ coreIdx ] = makeVMSQ();
    6.25 -      
    6.26           //Q: should give masterVP core-specific info as its init data?
    6.27        masterVPs[ coreIdx ] = VMS_int__create_slaveVP( (TopLevelFnPtr)&animationMaster, (void*)masterEnv );
    6.28        masterVPs[ coreIdx ]->coreAnimatedBy = coreIdx;
    6.29 @@ -547,6 +542,10 @@
    6.30  void
    6.31  VMS_SS__cleanup_at_end_of_shutdown()
    6.32   { 
    6.33 +   int              coreIdx;
    6.34 +   SlaveVP        **masterVPs;
    6.35 +   AnimSlot     ***allAnimSlots; //ptr to array of ptrs
    6.36 +   
    6.37        //Before getting rid of everything, print out any measurements made
    6.38     if( _VMSMasterEnv->measHistsInfo != NULL )
    6.39      { forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, (DynArrayFnPtr)&printHist );
    6.40 @@ -564,20 +563,17 @@
    6.41        //All the environment data has been allocated with VMS__malloc, so just
    6.42        // free its internal big-chunk and all inside it disappear.
    6.43  /*
    6.44 -   readyToAnimateQs = _VMSMasterEnv->readyToAnimateQs;
    6.45     masterVPs        = _VMSMasterEnv->masterVPs;
    6.46     allAnimSlots    = _VMSMasterEnv->allAnimSlots;
    6.47     
    6.48     for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ )
    6.49      {
    6.50 -      freeVMSQ( readyToAnimateQs[ coreIdx ] );
    6.51           //master Slvs were created external to VMS, so use external free
    6.52        VMS_int__dissipate_slaveVP( masterVPs[ coreIdx ] );
    6.53        
    6.54        freeAnimSlots( allAnimSlots[ coreIdx ] );
    6.55      }
    6.56     
    6.57 -   VMS_int__free( _VMSMasterEnv->readyToAnimateQs );
    6.58     VMS_int__free( _VMSMasterEnv->masterVPs );
    6.59     VMS_int__free( _VMSMasterEnv->allAnimSlots );
    6.60