aboutsummaryrefslogtreecommitdiff
path: root/doc/oscl_html/oscl__mem__audit__internals_8h_source.html
blob: 069f8e643b42a5565d07014662720ac4e0ede7f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>oscl: oscl_mem_audit_internals.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<h1>oscl_mem_audit_internals.h</h1><a href="oscl__mem__audit__internals_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- c++ -*- */</span>
<a name="l00002"></a>00002 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span>
<a name="l00003"></a>00003 
<a name="l00004"></a>00004 <span class="comment">//           O S C L _ M E M _ A U D I T _ I N T E R N A L S</span>
<a name="l00005"></a>00005 
<a name="l00006"></a>00006 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span>
<a name="l00007"></a>00007 
<a name="l00019"></a>00019 <span class="preprocessor">#ifndef OSCL_MEM_AUDIT_INTERNALS_H</span>
<a name="l00020"></a>00020 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_MEM_AUDIT_INTERNALS_H</span>
<a name="l00021"></a>00021 <span class="preprocessor"></span>
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="preprocessor">#include &quot;<a class="code" href="oscl__base_8h.html" title="The file oscl_base.h is the public header that should be included to pick up the...">oscl_base.h</a>&quot;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &quot;<a class="code" href="oscl__mem__audit_8h.html" title="This file contains the definition and partial implementation of MM_Audit class.">oscl_mem_audit.h</a>&quot;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &quot;<a class="code" href="oscl__mem__inst_8h.html" title="The file defines default memory instrumentation level.">oscl_mem_inst.h</a>&quot;</span>
<a name="l00026"></a>00026 
<a name="l00027"></a><a class="code" href="group__osclmemory.html#ga9fcc278d0a7a8d1c95f95c3bd7067994">00027</a> <span class="preprocessor">#define OSCL_DISABLE_WARNING_TRUNCATE_DEBUG_MESSAGE</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span><span class="preprocessor">#include &quot;<a class="code" href="osclconfig__compiler__warnings_8h.html" title="This file contains the ability to turn off/on compiler warnings.">osclconfig_compiler_warnings.h</a>&quot;</span>
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 <span class="preprocessor">#if(PVMEM_INST_LEVEL&gt;0)</span>
<a name="l00031"></a>00031 <span class="preprocessor"></span><span class="preprocessor">#define MM_AUDIT_ALLOC_NODE_SUPPORT 1</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span><span class="preprocessor">#define MM_AUDIT_FENCE_SUPPORT 1</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#define MM_AUDIT_INCLUDE_ALL_HEAP_VALIDATION 1</span>
<a name="l00034"></a>00034 <span class="preprocessor"></span><span class="preprocessor">#define MM_AUDIT_FILL_SUPPORT 1</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span><span class="preprocessor">#define MM_AUDIT_FAILURE_SIMULATION_SUPPORT 1</span>
<a name="l00036"></a>00036 <span class="preprocessor"></span><span class="preprocessor">#else</span>
<a name="l00037"></a><a class="code" href="group__osclmemory.html#ga6d86accdb1569e3f2ec5fad1a1da0813">00037</a> <span class="preprocessor"></span><span class="preprocessor">#define MM_AUDIT_ALLOC_NODE_SUPPORT 1</span>
<a name="l00038"></a><a class="code" href="group__osclmemory.html#ga98b727807dd99d6c95b89d18e21150e1">00038</a> <span class="preprocessor"></span><span class="preprocessor">#define MM_AUDIT_FENCE_SUPPORT 0</span>
<a name="l00039"></a><a class="code" href="group__osclmemory.html#ga4f5110c4b2d4aa30332fea0887597e13">00039</a> <span class="preprocessor"></span><span class="preprocessor">#define MM_AUDIT_INCLUDE_ALL_HEAP_VALIDATION 1</span>
<a name="l00040"></a><a class="code" href="group__osclmemory.html#ga1638931c2a45998d41117c63d98aaaa3">00040</a> <span class="preprocessor"></span><span class="preprocessor">#define MM_AUDIT_FILL_SUPPORT 0</span>
<a name="l00041"></a><a class="code" href="group__osclmemory.html#gac413e0f53ebf7604754e70243d7e50aa">00041</a> <span class="preprocessor"></span><span class="preprocessor">#define MM_AUDIT_FAILURE_SIMULATION_SUPPORT 1</span>
<a name="l00042"></a>00042 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00043"></a>00043 <span class="preprocessor"></span>
<a name="l00044"></a><a class="code" href="group__osclmemory.html#ga8ecb0ce053d85e9cabb073d977fe8217">00044</a> <span class="preprocessor">#define FENCE_PATTERN 0xAA</span>
<a name="l00045"></a><a class="code" href="group__osclmemory.html#ga0d410e6faeceb9aee4bfa7de0a81f846">00045</a> <span class="preprocessor"></span><span class="preprocessor">#define MIN_FENCE_SIZE 4</span>
<a name="l00046"></a>00046 <span class="preprocessor"></span>
<a name="l00047"></a>00047 <span class="preprocessor">#ifdef MEM_ALIGN_4</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span><span class="preprocessor">#define MEM_ALIGN_SIZE 4</span>
<a name="l00049"></a>00049 <span class="preprocessor"></span><span class="preprocessor">#else</span>
<a name="l00050"></a><a class="code" href="group__osclmemory.html#ga0c5dc9a73108accd8c796abc8272861a">00050</a> <span class="preprocessor"></span><span class="preprocessor">#define MEM_ALIGN_SIZE 8</span>
<a name="l00051"></a>00051 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00052"></a>00052 <span class="preprocessor"></span>
<a name="l00053"></a>00053 
<a name="l00054"></a>00054 
<a name="l00055"></a>00055 <span class="comment">/* CURRENTLY THIS STRUCTURE IS A MULTIPLE OF 8 BYTES.  MAKE SURE IT</span>
<a name="l00056"></a>00056 <span class="comment"> * MAINTAINS A SIZE THAT IS AN INTEGER MULTIPLE OF THE ALIGNMENT SIZE</span>
<a name="l00057"></a>00057 <span class="comment"> * FOR THE PLATFORM IN QUESTION.  ADD PAD BYTES TO THE STRUCTURE</span>
<a name="l00058"></a>00058 <span class="comment"> * IF NECESSARY</span>
<a name="l00059"></a>00059 <span class="comment"> */</span>
<a name="l00060"></a><a class="code" href="structMM__AllocBlockHdr.html">00060</a> <span class="keyword">struct </span><a class="code" href="structMM__AllocBlockHdr.html">MM_AllocBlockHdr</a>
<a name="l00061"></a>00061 {
<a name="l00062"></a><a class="code" href="structMM__AllocBlockHdr.html#a2347d96bf6788a5e79374d16734e08e9">00062</a>     <span class="keywordtype">void</span> *<a class="code" href="structMM__AllocBlockHdr.html#a2347d96bf6788a5e79374d16734e08e9">pNode</a>; <span class="comment">//pointer to either a stats node or an alloc node.</span>
<a name="l00063"></a><a class="code" href="structMM__AllocBlockHdr.html#a4e87f1c1e9487e8f7397fe2cadb64042">00063</a>     uint32 <a class="code" href="structMM__AllocBlockHdr.html#a4e87f1c1e9487e8f7397fe2cadb64042">size</a>;
<a name="l00064"></a>00064 
<a name="l00065"></a><a class="code" href="structMM__AllocBlockHdr.html#a95f91c1b02fc7f8eaef192d0fcbe0e71">00065</a>     <span class="keywordtype">void</span> *<a class="code" href="structMM__AllocBlockHdr.html#a95f91c1b02fc7f8eaef192d0fcbe0e71">pRootNode</a>; <span class="comment">//pointer to root node, to use when de-allocating.</span>
<a name="l00066"></a><a class="code" href="structMM__AllocBlockHdr.html#af208e0f5916a8e9c9d8092dedc4cec5e">00066</a>     uint32 <a class="code" href="structMM__AllocBlockHdr.html#af208e0f5916a8e9c9d8092dedc4cec5e">pad</a>;<span class="comment">//to maintain 8-byte alignment</span>
<a name="l00067"></a>00067 
<a name="l00068"></a>00068     <span class="comment">/* windows compiler assumes the the assignment</span>
<a name="l00069"></a>00069 <span class="comment">     * is a pure-virtual declaration and does not allow</span>
<a name="l00070"></a>00070 <span class="comment">     * it to be non-zero.  We actually set the value below.</span>
<a name="l00071"></a>00071 <span class="comment">     */</span>
<a name="l00072"></a><a class="code" href="group__osclmemory.html#ga8fec96057b23accc66a5d60d4ef5d819">00072</a>     <span class="keyword">static</span> <span class="keyword">const</span> uint32 <a class="code" href="group__osclmemory.html#ga8fec96057b23accc66a5d60d4ef5d819">ALLOC_NODE_FLAG</a>; <span class="comment">// = 0x80000000;</span>
<a name="l00073"></a>00073 
<a name="l00074"></a><a class="code" href="structMM__AllocBlockHdr.html#aa48f577a75ee5a5bf48cb0cd50407503">00074</a>     <span class="keywordtype">bool</span> <a class="code" href="structMM__AllocBlockHdr.html#aa48f577a75ee5a5bf48cb0cd50407503">isAllocNodePtr</a>()
<a name="l00075"></a>00075     {
<a name="l00076"></a>00076         <span class="keywordflow">return</span> ((<a class="code" href="structMM__AllocBlockHdr.html#a4e87f1c1e9487e8f7397fe2cadb64042">size</a> &amp; <a class="code" href="group__osclmemory.html#ga8fec96057b23accc66a5d60d4ef5d819">ALLOC_NODE_FLAG</a>) != 0);
<a name="l00077"></a>00077     };
<a name="l00078"></a><a class="code" href="structMM__AllocBlockHdr.html#a235296d64c445372de3d849bc0df70cb">00078</a>     <span class="keywordtype">void</span> <a class="code" href="structMM__AllocBlockHdr.html#a235296d64c445372de3d849bc0df70cb">setAllocNodeFlag</a>()
<a name="l00079"></a>00079     {
<a name="l00080"></a>00080         <a class="code" href="structMM__AllocBlockHdr.html#a4e87f1c1e9487e8f7397fe2cadb64042">size</a> |= <a class="code" href="group__osclmemory.html#ga8fec96057b23accc66a5d60d4ef5d819">ALLOC_NODE_FLAG</a>;
<a name="l00081"></a>00081     };
<a name="l00082"></a>00082 
<a name="l00083"></a><a class="code" href="structMM__AllocBlockHdr.html#acee113f469ef8da3398d06116a7b0dad">00083</a>     <a class="code" href="structMM__AllocBlockHdr.html#acee113f469ef8da3398d06116a7b0dad">MM_AllocBlockHdr</a>(): <a class="code" href="structMM__AllocBlockHdr.html#a2347d96bf6788a5e79374d16734e08e9">pNode</a>(0), <a class="code" href="structMM__AllocBlockHdr.html#a4e87f1c1e9487e8f7397fe2cadb64042">size</a>(0), <a class="code" href="structMM__AllocBlockHdr.html#a95f91c1b02fc7f8eaef192d0fcbe0e71">pRootNode</a>(0), <a class="code" href="structMM__AllocBlockHdr.html#af208e0f5916a8e9c9d8092dedc4cec5e">pad</a>(0) {};
<a name="l00084"></a><a class="code" href="structMM__AllocBlockHdr.html#a0b04ba8b9dfa09600a05a589429eac17">00084</a>     <a class="code" href="structMM__AllocBlockHdr.html#a0b04ba8b9dfa09600a05a589429eac17">MM_AllocBlockHdr</a>(<span class="keywordtype">void</span>* ptr, uint32 inSize): <a class="code" href="structMM__AllocBlockHdr.html#a2347d96bf6788a5e79374d16734e08e9">pNode</a>(ptr), <a class="code" href="structMM__AllocBlockHdr.html#a4e87f1c1e9487e8f7397fe2cadb64042">size</a>(inSize), <a class="code" href="structMM__AllocBlockHdr.html#a95f91c1b02fc7f8eaef192d0fcbe0e71">pRootNode</a>(0), <a class="code" href="structMM__AllocBlockHdr.html#af208e0f5916a8e9c9d8092dedc4cec5e">pad</a>(0) {};
<a name="l00085"></a>00085 };
<a name="l00086"></a>00086 
<a name="l00087"></a>00087 <span class="comment">// actually set the value here.</span>
<a name="l00088"></a>00088 <span class="keyword">const</span> uint32 <a class="code" href="group__osclmemory.html#ga8fec96057b23accc66a5d60d4ef5d819">MM_AllocBlockHdr::ALLOC_NODE_FLAG</a> = 0x80000000;
<a name="l00089"></a>00089 
<a name="l00090"></a><a class="code" href="group__osclmemory.html#ga7a5bfe186fa6607f8e0a655b27756a95">00090</a> <span class="preprocessor">#define COMPUTE_MEM_ALIGN_SIZE(x,y,z) (y+(((x+y)%z) ? (z - (x+y)%z) : 0))</span>
<a name="l00091"></a>00091 <span class="preprocessor"></span>
<a name="l00092"></a><a class="code" href="structMM__AllocBlockFence.html">00092</a> <span class="keyword">struct </span><a class="code" href="structMM__AllocBlockFence.html">MM_AllocBlockFence</a>
<a name="l00093"></a>00093 {
<a name="l00094"></a>00094 
<a name="l00095"></a><a class="code" href="structMM__AllocBlockFence.html#a8802c7404ad6905a67aea749f9683b92">00095</a>     uint8 <a class="code" href="structMM__AllocBlockFence.html#a8802c7404ad6905a67aea749f9683b92">pad</a>[<a class="code" href="group__osclmemory.html#ga7a5bfe186fa6607f8e0a655b27756a95">COMPUTE_MEM_ALIGN_SIZE</a>(<span class="keyword">sizeof</span>(<a class="code" href="structMM__AllocBlockHdr.html">MM_AllocBlockHdr</a>), <a class="code" href="group__osclmemory.html#ga0d410e6faeceb9aee4bfa7de0a81f846">MIN_FENCE_SIZE</a>, <a class="code" href="group__osclmemory.html#ga0c5dc9a73108accd8c796abc8272861a">MEM_ALIGN_SIZE</a>)];
<a name="l00096"></a><a class="code" href="structMM__AllocBlockFence.html#ab04f808097e92bcb6a2aa649180784f0">00096</a>     <a class="code" href="structMM__AllocBlockFence.html#ab04f808097e92bcb6a2aa649180784f0">MM_AllocBlockFence</a>()
<a name="l00097"></a>00097     {
<a name="l00098"></a>00098         <a class="code" href="structMM__AllocBlockFence.html#a1a8c133ae4c9670b1a60c80ef283dda4">fill_fence</a>();
<a name="l00099"></a>00099     };
<a name="l00100"></a>00100 
<a name="l00101"></a><a class="code" href="structMM__AllocBlockFence.html#a1a8c133ae4c9670b1a60c80ef283dda4">00101</a>     <span class="keywordtype">void</span> <a class="code" href="structMM__AllocBlockFence.html#a1a8c133ae4c9670b1a60c80ef283dda4">fill_fence</a>()
<a name="l00102"></a>00102     {
<a name="l00103"></a>00103         <a class="code" href="group__osclmemory.html#ga93ce8ea351e601f7d68094199190178b">oscl_memset</a>(<a class="code" href="structMM__AllocBlockFence.html#a8802c7404ad6905a67aea749f9683b92">pad</a>, <a class="code" href="group__osclmemory.html#ga8ecb0ce053d85e9cabb073d977fe8217">FENCE_PATTERN</a>, <span class="keyword">sizeof</span>(<a class="code" href="structMM__AllocBlockFence.html#a8802c7404ad6905a67aea749f9683b92">pad</a>));
<a name="l00104"></a>00104     };
<a name="l00105"></a>00105 
<a name="l00106"></a><a class="code" href="structMM__AllocBlockFence.html#a7dddd5c318e0e62291474e8177b2b3d7">00106</a>     <span class="keywordtype">bool</span> <a class="code" href="structMM__AllocBlockFence.html#a7dddd5c318e0e62291474e8177b2b3d7">check_fence</a>()
<a name="l00107"></a>00107     {
<a name="l00108"></a>00108         <span class="keywordflow">for</span> (<a class="code" href="group__osclbase.html#ga91ad9478d81a7aaf2593e8d9c3d06a14" title="The uint type is a convenient abbreviation for unsigned int.">uint</a> ii = 0; ii &lt; <span class="keyword">sizeof</span>(<a class="code" href="structMM__AllocBlockFence.html#a8802c7404ad6905a67aea749f9683b92">pad</a>); ++ii)
<a name="l00109"></a>00109         {
<a name="l00110"></a>00110             <span class="keywordflow">if</span> (<a class="code" href="structMM__AllocBlockFence.html#a8802c7404ad6905a67aea749f9683b92">pad</a>[ii] != <a class="code" href="group__osclmemory.html#ga8ecb0ce053d85e9cabb073d977fe8217">FENCE_PATTERN</a>) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00111"></a>00111         }
<a name="l00112"></a>00112         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00113"></a>00113     };
<a name="l00114"></a>00114 };
<a name="l00115"></a>00115 
<a name="l00116"></a>00116 
<a name="l00117"></a>00117 
<a name="l00118"></a>00118 
<a name="l00119"></a><a class="code" href="group__osclmemory.html#ga8b370fbf428f95f949b00e449a26fe9a">00119</a> <span class="preprocessor">#define DEFAULT_PREFILL_PATTERN 0x96</span>
<a name="l00120"></a><a class="code" href="group__osclmemory.html#ga7d6a16209a451acbc39aa26024ef6b7b">00120</a> <span class="preprocessor"></span><span class="preprocessor">#define DEFAULT_POSTFILL_PATTERN 0x5A</span>
<a name="l00121"></a>00121 <span class="preprocessor"></span>
<a name="l00122"></a>00122 
<a name="l00123"></a>00123 
<a name="l00124"></a>00124 
<a name="l00125"></a>00125 
<a name="l00126"></a>00126 <span class="preprocessor">#endif</span>
<a name="l00127"></a>00127 <span class="preprocessor"></span>
</pre></div></div>
<hr size="1"><img src="pvlogo_small.jpg"><address style="align: right;"><small>OSCL API</small>
<address style="align: left;"><small>Posting Version: CORE_9.002.1.1 </small>
</small></address>
</body>
</html>