Main Page Modules Class Hierarchy Data Structures File List Data Fields Globals Related Pages

# oscl_mem_audit_internals.h

Go to the documentation of this file.

    00001 /* -*- c++ -*- */
    00002 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
    00003
    00004 //           O S C L _ M E M _ A U D I T _ I N T E R N A L S
    00005
    00006 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
    00007
    00019 #ifndef OSCL_MEM_AUDIT_INTERNALS_H
    00020 #define OSCL_MEM_AUDIT_INTERNALS_H
    00021
    00022
    00023 #include "oscl_base.h"
    00024 #include "oscl_mem_audit.h"
    00025 #include "oscl_mem_inst.h"
    00026
    00027 #define OSCL_DISABLE_WARNING_TRUNCATE_DEBUG_MESSAGE
    00028 #include "osclconfig_compiler_warnings.h"
    00029
    00030 #if(PVMEM_INST_LEVEL>0)
    00031 #define MM_AUDIT_ALLOC_NODE_SUPPORT 1
    00032 #define MM_AUDIT_FENCE_SUPPORT 1
    00033 #define MM_AUDIT_INCLUDE_ALL_HEAP_VALIDATION 1
    00034 #define MM_AUDIT_FILL_SUPPORT 1
    00035 #define MM_AUDIT_FAILURE_SIMULATION_SUPPORT 1
    00036 #else
    00037 #define MM_AUDIT_ALLOC_NODE_SUPPORT 1
    00038 #define MM_AUDIT_FENCE_SUPPORT 0
    00039 #define MM_AUDIT_INCLUDE_ALL_HEAP_VALIDATION 1
    00040 #define MM_AUDIT_FILL_SUPPORT 0
    00041 #define MM_AUDIT_FAILURE_SIMULATION_SUPPORT 1
    00042 #endif
    00043
    00044 #define FENCE_PATTERN 0xAA
    00045 #define MIN_FENCE_SIZE 4
    00046
    00047 #ifdef MEM_ALIGN_4
    00048 #define MEM_ALIGN_SIZE 4
    00049 #else
    00050 #define MEM_ALIGN_SIZE 8
    00051 #endif
    00052
    00053
    00054
    00055 /* CURRENTLY THIS STRUCTURE IS A MULTIPLE OF 8 BYTES.  MAKE SURE IT
    00056  * MAINTAINS A SIZE THAT IS AN INTEGER MULTIPLE OF THE ALIGNMENT SIZE
    00057  * FOR THE PLATFORM IN QUESTION.  ADD PAD BYTES TO THE STRUCTURE
    00058  * IF NECESSARY
    00059  */
    00060 struct MM_AllocBlockHdr
    00061 {
    00062     void *pNode; //pointer to either a stats node or an alloc node.
    00063     uint32 size;
    00064
    00065     void *pRootNode; //pointer to root node, to use when de-allocating.
    00066     uint32 pad;//to maintain 8-byte alignment
    00067
    00068     /* windows compiler assumes the the assignment
    00069      * is a pure-virtual declaration and does not allow
    00070      * it to be non-zero.  We actually set the value below.
    00071      */
    00072     static const uint32 ALLOC_NODE_FLAG; // = 0x80000000;
    00073
    00074     bool isAllocNodePtr()
    00075     {
    00076         return ((size & ALLOC_NODE_FLAG) != 0);
    00077     };
    00078     void setAllocNodeFlag()
    00079     {
    00080         size |= ALLOC_NODE_FLAG;
    00081     };
    00082
    00083     MM_AllocBlockHdr(): pNode(0), size(0), pRootNode(0), pad(0) {};
    00084     MM_AllocBlockHdr(void* ptr, uint32 inSize): pNode(ptr), size(inSize), pRootNode(0), pad(0) {};
    00085 };
    00086
    00087 // actually set the value here.
    00088 const uint32 MM_AllocBlockHdr::ALLOC_NODE_FLAG = 0x80000000;
    00089
    00090 #define COMPUTE_MEM_ALIGN_SIZE(x,y,z) (y+(((x+y)%z) ? (z - (x+y)%z) : 0))
    00091
    00092 struct MM_AllocBlockFence
    00093 {
    00094
    00095     uint8 pad[COMPUTE_MEM_ALIGN_SIZE(sizeof(MM_AllocBlockHdr), MIN_FENCE_SIZE, MEM_ALIGN_SIZE)];
    00096     MM_AllocBlockFence()
    00097     {
    00098         fill_fence();
    00099     };
    00100
    00101     void fill_fence()
    00102     {
    00103         oscl_memset(pad, FENCE_PATTERN, sizeof(pad));
    00104     };
    00105
    00106     bool check_fence()
    00107     {
    00108         for (uint ii = 0; ii < sizeof(pad); ++ii)
    00109         {
    00110             if (pad[ii] != FENCE_PATTERN) return false;
    00111         }
    00112         return true;
    00113     };
    00114 };
    00115
    00116
    00117
    00118
    00119 #define DEFAULT_PREFILL_PATTERN 0x96
    00120 #define DEFAULT_POSTFILL_PATTERN 0x5A
    00121
    00122
    00123
    00124
    00125
    00126 #endif
    00127