blob: 689b17dda2398b2aa7f27e42feca290cd2125868 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>oscl_error_trapcleanup.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.18 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="modules.html">Modules</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="annotated.html">Data Structures</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Data Fields</a> &nbsp; <a class="qindex" href="globals.html">Globals</a> &nbsp; </center>
<hr><h1>oscl_error_trapcleanup.h</h1><a href="oscl__error__trapcleanup_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">// -*- c++ -*-</span>
00002 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span>
00003
00004 <span class="comment">// O S C L _ E R R O R _ T R A P C L E A N U P</span>
00005
00006 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span>
00007
00018 <span class="preprocessor">#ifndef OSCL_ERROR_TRAPCLEANUP_H_INCLUDED</span>
00019 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_ERROR_TRAPCLEANUP_H_INCLUDED</span>
00020 <span class="preprocessor"></span>
00021 <span class="preprocessor">#ifndef OSCLCONFIG_ERROR_H_INCLUDED</span>
00022 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="osclconfig__error_8h.html">osclconfig_error.h</a>"</span>
00023 <span class="preprocessor">#endif</span>
00024 <span class="preprocessor"></span>
00025
00026
00027 <span class="preprocessor">#ifndef OSCL_HEAPBASE_H_INCLUDED</span>
00028 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__heapbase_8h.html">oscl_heapbase.h</a>"</span>
00029 <span class="preprocessor">#endif</span>
00030 <span class="preprocessor"></span>
<a name="l00031"></a><a class="code" href="group__osclerror.html#a43">00031</a> <span class="preprocessor">#define OSCL_MAX_TRAP_LEVELS 20</span>
00032 <span class="preprocessor"></span>
<a name="l00036"></a><a class="code" href="classOsclTrapStackItem.html">00036</a> <span class="keyword">class </span><a class="code" href="classOsclTrapStackItem.html">OsclTrapStackItem</a>
00037 {
00038 <span class="keyword">public</span>:
<a name="l00039"></a><a class="code" href="classOsclTrapStackItem.html#a0">00039</a> <a class="code" href="classOsclTrapStackItem.html#a0">OsclTrapStackItem</a>() {}
<a name="l00040"></a><a class="code" href="classOsclTrapStackItem.html#a1">00040</a> <a class="code" href="classOsclTrapStackItem.html#a0">OsclTrapStackItem</a>(<a class="code" href="class__OsclHeapBase.html">_OsclHeapBase</a> *aCBase)
00041 {
00042 <a class="code" href="classOsclTrapStackItem.html#m0">iCBase</a> = aCBase;
00043 <a class="code" href="classOsclTrapStackItem.html#m1">iTAny</a> = (<a class="code" href="group__osclbase.html#a25">OsclAny</a>*)aCBase;
00044 <a class="code" href="classOsclTrapStackItem.html#m2">iTrapOperation</a> = <a class="code" href="group__osclbase.html#a81">NULL</a>;
00045 <a class="code" href="classOsclTrapStackItem.html#m3">iNext</a> = <a class="code" href="group__osclbase.html#a81">NULL</a>;
00046 }
<a name="l00047"></a><a class="code" href="classOsclTrapStackItem.html#a2">00047</a> <a class="code" href="classOsclTrapStackItem.html#a0">OsclTrapStackItem</a>(<a class="code" href="group__osclbase.html#a25">OsclAny</a> *aTAny)
00048 {
00049 <a class="code" href="classOsclTrapStackItem.html#m0">iCBase</a> = <a class="code" href="group__osclbase.html#a81">NULL</a>;
00050 <a class="code" href="classOsclTrapStackItem.html#m1">iTAny</a> = aTAny;
00051 <a class="code" href="classOsclTrapStackItem.html#m2">iTrapOperation</a> = <a class="code" href="group__osclbase.html#a81">NULL</a>;
00052 <a class="code" href="classOsclTrapStackItem.html#m3">iNext</a> = <a class="code" href="group__osclbase.html#a81">NULL</a>;
00053 }
<a name="l00054"></a><a class="code" href="classOsclTrapStackItem.html#a3">00054</a> <a class="code" href="classOsclTrapStackItem.html#a0">OsclTrapStackItem</a>(<a class="code" href="classOsclTrapItem.html">OsclTrapItem</a> aItem)
00055 {
00056 <a class="code" href="classOsclTrapStackItem.html#m0">iCBase</a> = <a class="code" href="group__osclbase.html#a81">NULL</a>;
00057 <a class="code" href="classOsclTrapStackItem.html#m1">iTAny</a> = aItem.<a class="code" href="classOsclTrapItem.html#o1">iPtr</a>;
00058 <a class="code" href="classOsclTrapStackItem.html#m2">iTrapOperation</a> = aItem.<a class="code" href="classOsclTrapItem.html#o0">iOperation</a>;
00059 <a class="code" href="classOsclTrapStackItem.html#m3">iNext</a> = <a class="code" href="group__osclbase.html#a81">NULL</a>;
00060 }
<a name="l00061"></a><a class="code" href="classOsclTrapStackItem.html#m0">00061</a> <a class="code" href="class__OsclHeapBase.html">_OsclHeapBase</a> *<a class="code" href="classOsclTrapStackItem.html#m0">iCBase</a>;
<a name="l00062"></a><a class="code" href="classOsclTrapStackItem.html#m1">00062</a> <a class="code" href="group__osclbase.html#a25">OsclAny</a> *<a class="code" href="classOsclTrapStackItem.html#m1">iTAny</a>;
<a name="l00063"></a><a class="code" href="classOsclTrapStackItem.html#m2">00063</a> <a class="code" href="group__osclerror.html#a3">OsclTrapOperation</a> <a class="code" href="classOsclTrapStackItem.html#m2">iTrapOperation</a>;
<a name="l00064"></a><a class="code" href="classOsclTrapStackItem.html#m3">00064</a> <a class="code" href="classOsclTrapStackItem.html">OsclTrapStackItem</a> *<a class="code" href="classOsclTrapStackItem.html#m3">iNext</a>;
00065 };
00066
00067 <span class="keyword">class </span><a class="code" href="classOsclJump.html">OsclJump</a>;
00068
00069 <span class="preprocessor">#ifndef OSCL_ERROR_IMP_H_INCLUDED</span>
00070 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__error__imp_8h.html">oscl_error_imp.h</a>"</span>
00071 <span class="preprocessor">#endif</span>
00072 <span class="preprocessor"></span>
00073 <span class="preprocessor">#ifndef OSCL_DEFALLOC_H_INCLUDED</span>
00074 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__defalloc_8h.html">oscl_defalloc.h</a>"</span>
00075 <span class="preprocessor">#endif</span>
00076 <span class="preprocessor"></span>
00077 <span class="preprocessor">#ifndef OSCL_ASSERT_H_INCLUDED</span>
00078 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__assert_8h.html">oscl_assert.h</a>"</span>
00079 <span class="preprocessor">#endif</span>
00080 <span class="preprocessor"></span>
00081 <span class="preprocessor">#ifndef OSCL_ERROR_H_INCLUDED</span>
00082 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__error_8h.html">oscl_error.h</a>"</span>
00083 <span class="preprocessor">#endif</span>
00084 <span class="preprocessor"></span>
<a name="l00089"></a><a class="code" href="classOsclTrapStack.html">00089</a> <span class="keyword">class </span><a class="code" href="classOsclTrapStack.html">OsclTrapStack</a>
00090 {
00091 <span class="keyword">private</span>:
00092 <a class="code" href="classOsclTrapStack.html">OsclTrapStack</a>(<a class="code" href="classOscl__DefAlloc.html">Oscl_DefAlloc</a> *iAlloc);
00093 ~<a class="code" href="classOsclTrapStack.html">OsclTrapStack</a>();
00094
00095 <span class="comment">//Trap APIs</span>
00096 <span class="keyword">inline</span> <span class="keywordtype">void</span> Trap();
00097 <span class="keyword">inline</span> <span class="keywordtype">bool</span> UnTrap();
00098
00099 <span class="comment">//Cleanup stack APIs</span>
00100 <span class="keywordtype">void</span> PushL(<a class="code" href="class__OsclHeapBase.html">_OsclHeapBase</a> *aCBase);
00101 <span class="keywordtype">void</span> PushL(<a class="code" href="group__osclbase.html#a25">OsclAny</a> *aTAny);
00102 <span class="keywordtype">void</span> PushL(<a class="code" href="classOsclTrapItem.html">OsclTrapItem</a> anItem);
00103 <span class="keywordtype">void</span> Push(<a class="code" href="classOsclTrapStackItem.html">OsclTrapStackItem</a> *aItem);
00104 <span class="keywordtype">void</span> Pop();
00105 <span class="keywordtype">void</span> Pop(int32 aCount);
00106 <span class="keywordtype">void</span> PopDealloc();
00107 <span class="keywordtype">void</span> PopDealloc(int32 aCount);
00108 <span class="keywordtype">void</span> Leaving();
00109
00110 <span class="comment">//top of cleanup stack</span>
00111 <a class="code" href="classOsclTrapStackItem.html">OsclTrapStackItem</a> *iTop;
00112
00113 <span class="comment">//cleanup stack allocator.</span>
00114 <a class="code" href="classOscl__DefAlloc.html">Oscl_DefAlloc</a> *iAlloc;
00115
<a name="l00116"></a><a class="code" href="classOsclTrapStack.html#l0">00116</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classOsclError.html">OsclError</a>;
<a name="l00117"></a><a class="code" href="classOsclTrapStack.html#l1">00117</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classOsclErrorTrap.html">OsclErrorTrap</a>;
<a name="l00118"></a><a class="code" href="classOsclTrapStack.html#l2">00118</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>;
00119
00120 <span class="keyword">private</span>:
00121 <span class="comment">//The trap mark stack is a stack used to mark the top of the cleanup stack</span>
00122 <span class="comment">//for each trap level.</span>
00123
00124 <span class="keyword">inline</span> <span class="keywordtype">void</span> PushTrapL(<a class="code" href="group__osclbase.html#a25">OsclAny</a> *aTAny);
00125 <span class="keyword">inline</span> <span class="keywordtype">void</span> PopTrap();
00126
00127 <span class="comment">//top of trap mark stack</span>
00128 <a class="code" href="classOsclTrapStackItem.html">OsclTrapStackItem</a> *TrapTop()
00129 {
00130 <span class="keywordflow">if</span> (iTrapTopIndex &gt;= 0)
00131 <span class="keywordflow">return</span> &amp;iTrapTopArray[iTrapTopIndex];
00132 <span class="keywordflow">return</span> <a class="code" href="group__osclbase.html#a81">NULL</a>;
00133 }
00134
00135 <a class="code" href="classOsclTrapStackItem.html">OsclTrapStackItem</a> iTrapTopArray[<a class="code" href="group__osclerror.html#a43">OSCL_MAX_TRAP_LEVELS</a>];
00136
00137 <span class="comment">//index to top of stack, or (-1) when stack is empty</span>
00138 int32 iTrapTopIndex;
00139
00140 <span class="keywordtype">void</span> pushTrapIndex()
00141 {
00142 <a class="code" href="group__osclbase.html#a78">OSCL_ASSERT</a>(iTrapTopIndex &lt; (<a class="code" href="group__osclerror.html#a43">OSCL_MAX_TRAP_LEVELS</a> - 1));<span class="comment">//stack overflow</span>
00143 iTrapTopIndex++;
00144 }
00145
00146 <span class="keywordtype">void</span> popTrapIndex()
00147 {
00148 <a class="code" href="group__osclbase.html#a78">OSCL_ASSERT</a>(iTrapTopIndex &gt;= 0);<span class="comment">//stack underflow</span>
00149 iTrapTopIndex--;
00150 }
00151 };
00152
00153
00154
00155 <span class="preprocessor">#ifndef OSCL_BASE_ALLOC_H_INCLUDED</span>
00156 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__base__alloc_8h.html">oscl_base_alloc.h</a>"</span>
00157 <span class="preprocessor">#endif</span>
00158 <span class="preprocessor"></span>
00159 <span class="comment">//For non-symbian, the error trap stack must be in a global registry.</span>
00160 <span class="comment">//</span>
00161 <span class="comment">//Use TLS registry unless it's not available, then</span>
00162 <span class="comment">//use singleton.</span>
00163 <span class="comment">//Note: singleton-based registry only works for single-threaded</span>
00164 <span class="comment">//scenarios because this implementation assumes a per-thread registry.</span>
00165 <span class="preprocessor">#include "<a class="code" href="oscl__tls_8h.html">oscl_tls.h</a>"</span>
00166 <span class="preprocessor">#include "<a class="code" href="oscl__singleton_8h.html">oscl_singleton.h</a>"</span>
<a name="l00167"></a><a class="code" href="group__osclerror.html#a44">00167</a> <span class="preprocessor">#define PVERRORTRAP_REGISTRY_ID OSCL_TLS_ID_PVERRORTRAP</span>
<a name="l00168"></a><a class="code" href="group__osclerror.html#a45">00168</a> <span class="preprocessor"></span><span class="preprocessor">#define PVERRORTRAP_REGISTRY OsclTLSRegistry</span>
00169 <span class="preprocessor"></span>
00170
<a name="l00174"></a><a class="code" href="classOsclErrorTrapImp.html">00174</a> <span class="keyword">class </span><a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>
00175 {
00176 <span class="keyword">public</span>:
00181 OSCL_IMPORT_REF <span class="keywordtype">void</span> <a class="code" href="classOsclErrorTrapImp.html#a0">UnTrap</a>();
00182 <span class="preprocessor">#if defined(PVERROR_IMP_JUMPS)</span>
<a name="l00183"></a><a class="code" href="classOsclErrorTrapImp.html#m0">00183</a> <span class="preprocessor"></span> <a class="code" href="classOsclJump.html">OsclJump</a> *<a class="code" href="classOsclErrorTrapImp.html#m0">iJumpData</a>;
00184 <span class="preprocessor">#endif</span>
00185 <span class="preprocessor"></span>
00186 <span class="comment">//Global leave info.</span>
<a name="l00187"></a><a class="code" href="classOsclErrorTrapImp.html#m1">00187</a> int32 <a class="code" href="classOsclErrorTrapImp.html#m1">iLeave</a>;
00188
00189 <span class="keyword">public</span>:
00193 OSCL_IMPORT_REF <span class="keyword">static</span> <a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>* <a class="code" href="classOsclErrorTrapImp.html#d0">Trap</a>();
00194 <span class="comment">//This version of Trap is identical to the above, except it avoids the TLS lookup.</span>
00195 OSCL_IMPORT_REF <span class="keyword">static</span> <a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>* <a class="code" href="classOsclErrorTrapImp.html#d1">TrapNoTls</a>(<a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>*);
<a name="l00196"></a><a class="code" href="classOsclErrorTrapImp.html#m2">00196</a> <a class="code" href="classOsclTrapStack.html">OsclTrapStack</a> *<a class="code" href="classOsclErrorTrapImp.html#m2">iTrapStack</a>;
00197
00198 <span class="keyword">private</span>:
00199 <a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>(<a class="code" href="classOscl__DefAlloc.html">Oscl_DefAlloc</a> *aAlloc, int32 &amp;error);
00200 ~<a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>();
00201 <a class="code" href="classOscl__DefAlloc.html">Oscl_DefAlloc</a> *iAlloc;
00202
00203 <span class="keyword">static</span> <a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>* GetErrorTrap(int32&amp; aError)
00204 <span class="comment">//static function to get currently installed error trap</span>
00205 <span class="comment">//for this thread.</span>
00206 {
00207 <a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a> *current = (<a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>*)PVERRORTRAP_REGISTRY::getInstance(<a class="code" href="group__osclerror.html#a44">PVERRORTRAP_REGISTRY_ID</a>, aError);
00208 <span class="keywordflow">return</span> current;
00209 }
00210 <span class="keyword">static</span> <a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>* GetErrorTrap()
00211 <span class="comment">//static function to get currently installed error trap</span>
00212 <span class="comment">//for this thread. returns NULL on error.</span>
00213 {
00214 int32 error;
00215 <a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>* current = GetErrorTrap(error);
00216 <span class="keywordflow">if</span> (error)
00217 <span class="keywordflow">return</span> <a class="code" href="group__osclbase.html#a81">NULL</a>;
00218 <span class="keywordflow">return</span> current;
00219 }
00220
00221 <span class="keyword">static</span> <a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>* SetErrorTrap(<a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>* a, int32&amp; aError)
00222 <span class="comment">//static function to set currently installed error trap</span>
00223 <span class="comment">//for this thread. return previous error trap, if any.</span>
00224 {
00225 <a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>* temp = GetErrorTrap(aError);
00226 PVERRORTRAP_REGISTRY::registerInstance(a, <a class="code" href="group__osclerror.html#a44">PVERRORTRAP_REGISTRY_ID</a>, aError);
00227 <span class="keywordflow">return</span> temp;
00228 }
00229
00230 <span class="comment">//Global cleanup function for OsclAny items.</span>
00231 <span class="keyword">static</span> <span class="keywordtype">void</span> TrapOperation(<a class="code" href="group__osclbase.html#a25">OsclAny</a> *ptr)
00232 {
00233 int32 error;
00234 <a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a> *trap = GetErrorTrap(error);
00235 <span class="keywordflow">if</span> (trap &amp;&amp; trap-&gt;<a class="code" href="classOsclErrorTrapImp.html#o0">iAlloc</a>)
00236 trap-&gt;<a class="code" href="classOsclErrorTrapImp.html#o0">iAlloc</a>-&gt;<a class="code" href="classOscl__DefAlloc.html#a2">deallocate</a>(ptr);
00237 <span class="keywordflow">else</span>
00238 {
00239 <a class="code" href="class__OsclBasicAllocator.html">_OsclBasicAllocator</a> alloc;
00240 alloc.<a class="code" href="class__OsclBasicAllocator.html#a1">deallocate</a>(ptr);
00241 }
00242 }
00243
00244 <span class="comment">//default allocators.</span>
00245 <a class="code" href="class__OsclBasicAllocator.html">_OsclBasicAllocator</a> iDefAlloc;
00246
<a name="l00247"></a><a class="code" href="classOsclErrorTrapImp.html#l0">00247</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classOsclErrorTrap.html">OsclErrorTrap</a>;
<a name="l00248"></a><a class="code" href="classOsclErrorTrapImp.html#l1">00248</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classOsclError.html">OsclError</a>;
<a name="l00249"></a><a class="code" href="classOsclErrorTrapImp.html#l2">00249</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classOsclExecScheduler.html">OsclExecScheduler</a>;
<a name="l00250"></a><a class="code" href="classOsclErrorTrapImp.html#l3">00250</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classOsclExecSchedulerCommonBase.html">OsclExecSchedulerCommonBase</a>;
<a name="l00251"></a><a class="code" href="classOsclErrorTrapImp.html#l4">00251</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classOsclJump.html">OsclJump</a>;
<a name="l00252"></a><a class="code" href="classOsclErrorTrapImp.html#l5">00252</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classOsclErrorTrapImp.html#l5">OsclJumpMark</a>;
<a name="l00253"></a><a class="code" href="classOsclErrorTrapImp.html#l6">00253</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classOsclTrapStack.html">OsclTrapStack</a>;
<a name="l00254"></a><a class="code" href="classOsclErrorTrapImp.html#l7">00254</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classOsclErrorTrapImp.html#l7">CPVInterfaceProxy</a>;
<a name="l00255"></a><a class="code" href="classOsclErrorTrapImp.html#l8">00255</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classOsclScheduler.html">OsclScheduler</a>;
00256 };
00257
00258
00259 <span class="preprocessor">#endif</span>
00260 <span class="preprocessor"></span>
</pre></div><hr size="1"><img src="pvlogo_small.jpg"><address style="align: right;"><small>OSCL API</small>
<address style="align: left;"><small>Posting Version: OPENCORE_20090310 </small>
</small></address>
</body>
</html>