1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 2<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> 3<title>oscl_error_trapcleanup.h Source File</title> 4<link href="doxygen.css" rel="stylesheet" type="text/css"> 5</head><body> 6<!-- Generated by Doxygen 1.2.18 --> 7<center> 8<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="modules.html">Modules</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Data Structures</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Data Fields</a> <a class="qindex" href="globals.html">Globals</a> </center> 9<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> 1000002 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span> 1100003 1200004 <span class="comment">// O S C L _ E R R O R _ T R A P C L E A N U P</span> 1300005 1400006 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span> 1500007 1600018 <span class="preprocessor">#ifndef OSCL_ERROR_TRAPCLEANUP_H_INCLUDED</span> 1700019 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_ERROR_TRAPCLEANUP_H_INCLUDED</span> 1800020 <span class="preprocessor"></span> 1900021 <span class="preprocessor">#ifndef OSCLCONFIG_ERROR_H_INCLUDED</span> 2000022 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="osclconfig__error_8h.html">osclconfig_error.h</a>"</span> 2100023 <span class="preprocessor">#endif</span> 2200024 <span class="preprocessor"></span> 2300025 2400026 2500027 <span class="preprocessor">#ifndef OSCL_HEAPBASE_H_INCLUDED</span> 2600028 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__heapbase_8h.html">oscl_heapbase.h</a>"</span> 2700029 <span class="preprocessor">#endif</span> 2800030 <span class="preprocessor"></span> 29<a name="l00031"></a><a class="code" href="group__osclerror.html#a43">00031</a> <span class="preprocessor">#define OSCL_MAX_TRAP_LEVELS 20</span> 3000032 <span class="preprocessor"></span> 31<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> 3200037 { 3300038 <span class="keyword">public</span>: 34<a name="l00039"></a><a class="code" href="classOsclTrapStackItem.html#a0">00039</a> <a class="code" href="classOsclTrapStackItem.html#a0">OsclTrapStackItem</a>() {} 35<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) 3600041 { 3700042 <a class="code" href="classOsclTrapStackItem.html#m0">iCBase</a> = aCBase; 3800043 <a class="code" href="classOsclTrapStackItem.html#m1">iTAny</a> = (<a class="code" href="group__osclbase.html#a25">OsclAny</a>*)aCBase; 3900044 <a class="code" href="classOsclTrapStackItem.html#m2">iTrapOperation</a> = <a class="code" href="group__osclbase.html#a81">NULL</a>; 4000045 <a class="code" href="classOsclTrapStackItem.html#m3">iNext</a> = <a class="code" href="group__osclbase.html#a81">NULL</a>; 4100046 } 42<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) 4300048 { 4400049 <a class="code" href="classOsclTrapStackItem.html#m0">iCBase</a> = <a class="code" href="group__osclbase.html#a81">NULL</a>; 4500050 <a class="code" href="classOsclTrapStackItem.html#m1">iTAny</a> = aTAny; 4600051 <a class="code" href="classOsclTrapStackItem.html#m2">iTrapOperation</a> = <a class="code" href="group__osclbase.html#a81">NULL</a>; 4700052 <a class="code" href="classOsclTrapStackItem.html#m3">iNext</a> = <a class="code" href="group__osclbase.html#a81">NULL</a>; 4800053 } 49<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) 5000055 { 5100056 <a class="code" href="classOsclTrapStackItem.html#m0">iCBase</a> = <a class="code" href="group__osclbase.html#a81">NULL</a>; 5200057 <a class="code" href="classOsclTrapStackItem.html#m1">iTAny</a> = aItem.<a class="code" href="classOsclTrapItem.html#o1">iPtr</a>; 5300058 <a class="code" href="classOsclTrapStackItem.html#m2">iTrapOperation</a> = aItem.<a class="code" href="classOsclTrapItem.html#o0">iOperation</a>; 5400059 <a class="code" href="classOsclTrapStackItem.html#m3">iNext</a> = <a class="code" href="group__osclbase.html#a81">NULL</a>; 5500060 } 56<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>; 57<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>; 58<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>; 59<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>; 6000065 }; 6100066 6200067 <span class="keyword">class </span><a class="code" href="classOsclJump.html">OsclJump</a>; 6300068 6400069 <span class="preprocessor">#ifndef OSCL_ERROR_IMP_H_INCLUDED</span> 6500070 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__error__imp_8h.html">oscl_error_imp.h</a>"</span> 6600071 <span class="preprocessor">#endif</span> 6700072 <span class="preprocessor"></span> 6800073 <span class="preprocessor">#ifndef OSCL_DEFALLOC_H_INCLUDED</span> 6900074 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__defalloc_8h.html">oscl_defalloc.h</a>"</span> 7000075 <span class="preprocessor">#endif</span> 7100076 <span class="preprocessor"></span> 7200077 <span class="preprocessor">#ifndef OSCL_ASSERT_H_INCLUDED</span> 7300078 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__assert_8h.html">oscl_assert.h</a>"</span> 7400079 <span class="preprocessor">#endif</span> 7500080 <span class="preprocessor"></span> 7600081 <span class="preprocessor">#ifndef OSCL_ERROR_H_INCLUDED</span> 7700082 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__error_8h.html">oscl_error.h</a>"</span> 7800083 <span class="preprocessor">#endif</span> 7900084 <span class="preprocessor"></span> 80<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> 8100090 { 8200091 <span class="keyword">private</span>: 8300092 <a class="code" href="classOsclTrapStack.html">OsclTrapStack</a>(<a class="code" href="classOscl__DefAlloc.html">Oscl_DefAlloc</a> *iAlloc); 8400093 ~<a class="code" href="classOsclTrapStack.html">OsclTrapStack</a>(); 8500094 8600095 <span class="comment">//Trap APIs</span> 8700096 <span class="keyword">inline</span> <span class="keywordtype">void</span> Trap(); 8800097 <span class="keyword">inline</span> <span class="keywordtype">bool</span> UnTrap(); 8900098 9000099 <span class="comment">//Cleanup stack APIs</span> 9100100 <span class="keywordtype">void</span> PushL(<a class="code" href="class__OsclHeapBase.html">_OsclHeapBase</a> *aCBase); 9200101 <span class="keywordtype">void</span> PushL(<a class="code" href="group__osclbase.html#a25">OsclAny</a> *aTAny); 9300102 <span class="keywordtype">void</span> PushL(<a class="code" href="classOsclTrapItem.html">OsclTrapItem</a> anItem); 9400103 <span class="keywordtype">void</span> Push(<a class="code" href="classOsclTrapStackItem.html">OsclTrapStackItem</a> *aItem); 9500104 <span class="keywordtype">void</span> Pop(); 9600105 <span class="keywordtype">void</span> Pop(int32 aCount); 9700106 <span class="keywordtype">void</span> PopDealloc(); 9800107 <span class="keywordtype">void</span> PopDealloc(int32 aCount); 9900108 <span class="keywordtype">void</span> Leaving(); 10000109 10100110 <span class="comment">//top of cleanup stack</span> 10200111 <a class="code" href="classOsclTrapStackItem.html">OsclTrapStackItem</a> *iTop; 10300112 10400113 <span class="comment">//cleanup stack allocator.</span> 10500114 <a class="code" href="classOscl__DefAlloc.html">Oscl_DefAlloc</a> *iAlloc; 10600115 107<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>; 108<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>; 109<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>; 11000119 11100120 <span class="keyword">private</span>: 11200121 <span class="comment">//The trap mark stack is a stack used to mark the top of the cleanup stack</span> 11300122 <span class="comment">//for each trap level.</span> 11400123 11500124 <span class="keyword">inline</span> <span class="keywordtype">void</span> PushTrapL(<a class="code" href="group__osclbase.html#a25">OsclAny</a> *aTAny); 11600125 <span class="keyword">inline</span> <span class="keywordtype">void</span> PopTrap(); 11700126 11800127 <span class="comment">//top of trap mark stack</span> 11900128 <a class="code" href="classOsclTrapStackItem.html">OsclTrapStackItem</a> *TrapTop() 12000129 { 12100130 <span class="keywordflow">if</span> (iTrapTopIndex >= 0) 12200131 <span class="keywordflow">return</span> &iTrapTopArray[iTrapTopIndex]; 12300132 <span class="keywordflow">return</span> <a class="code" href="group__osclbase.html#a81">NULL</a>; 12400133 } 12500134 12600135 <a class="code" href="classOsclTrapStackItem.html">OsclTrapStackItem</a> iTrapTopArray[<a class="code" href="group__osclerror.html#a43">OSCL_MAX_TRAP_LEVELS</a>]; 12700136 12800137 <span class="comment">//index to top of stack, or (-1) when stack is empty</span> 12900138 int32 iTrapTopIndex; 13000139 13100140 <span class="keywordtype">void</span> pushTrapIndex() 13200141 { 13300142 <a class="code" href="group__osclbase.html#a78">OSCL_ASSERT</a>(iTrapTopIndex < (<a class="code" href="group__osclerror.html#a43">OSCL_MAX_TRAP_LEVELS</a> - 1));<span class="comment">//stack overflow</span> 13400143 iTrapTopIndex++; 13500144 } 13600145 13700146 <span class="keywordtype">void</span> popTrapIndex() 13800147 { 13900148 <a class="code" href="group__osclbase.html#a78">OSCL_ASSERT</a>(iTrapTopIndex >= 0);<span class="comment">//stack underflow</span> 14000149 iTrapTopIndex--; 14100150 } 14200151 }; 14300152 14400153 14500154 14600155 <span class="preprocessor">#ifndef OSCL_BASE_ALLOC_H_INCLUDED</span> 14700156 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__base__alloc_8h.html">oscl_base_alloc.h</a>"</span> 14800157 <span class="preprocessor">#endif</span> 14900158 <span class="preprocessor"></span> 15000159 <span class="comment">//For non-symbian, the error trap stack must be in a global registry.</span> 15100160 <span class="comment">//</span> 15200161 <span class="comment">//Use TLS registry unless it's not available, then</span> 15300162 <span class="comment">//use singleton.</span> 15400163 <span class="comment">//Note: singleton-based registry only works for single-threaded</span> 15500164 <span class="comment">//scenarios because this implementation assumes a per-thread registry.</span> 15600165 <span class="preprocessor">#include "<a class="code" href="oscl__tls_8h.html">oscl_tls.h</a>"</span> 15700166 <span class="preprocessor">#include "<a class="code" href="oscl__singleton_8h.html">oscl_singleton.h</a>"</span> 158<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> 159<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> 16000169 <span class="preprocessor"></span> 16100170 162<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> 16300175 { 16400176 <span class="keyword">public</span>: 16500181 OSCL_IMPORT_REF <span class="keywordtype">void</span> <a class="code" href="classOsclErrorTrapImp.html#a0">UnTrap</a>(); 16600182 <span class="preprocessor">#if defined(PVERROR_IMP_JUMPS)</span> 167<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>; 16800184 <span class="preprocessor">#endif</span> 16900185 <span class="preprocessor"></span> 17000186 <span class="comment">//Global leave info.</span> 171<a name="l00187"></a><a class="code" href="classOsclErrorTrapImp.html#m1">00187</a> int32 <a class="code" href="classOsclErrorTrapImp.html#m1">iLeave</a>; 17200188 17300189 <span class="keyword">public</span>: 17400193 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>(); 17500194 <span class="comment">//This version of Trap is identical to the above, except it avoids the TLS lookup.</span> 17600195 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>*); 177<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>; 17800197 17900198 <span class="keyword">private</span>: 18000199 <a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>(<a class="code" href="classOscl__DefAlloc.html">Oscl_DefAlloc</a> *aAlloc, int32 &error); 18100200 ~<a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>(); 18200201 <a class="code" href="classOscl__DefAlloc.html">Oscl_DefAlloc</a> *iAlloc; 18300202 18400203 <span class="keyword">static</span> <a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>* GetErrorTrap(int32& aError) 18500204 <span class="comment">//static function to get currently installed error trap</span> 18600205 <span class="comment">//for this thread.</span> 18700206 { 18800207 <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); 18900208 <span class="keywordflow">return</span> current; 19000209 } 19100210 <span class="keyword">static</span> <a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>* GetErrorTrap() 19200211 <span class="comment">//static function to get currently installed error trap</span> 19300212 <span class="comment">//for this thread. returns NULL on error.</span> 19400213 { 19500214 int32 error; 19600215 <a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>* current = GetErrorTrap(error); 19700216 <span class="keywordflow">if</span> (error) 19800217 <span class="keywordflow">return</span> <a class="code" href="group__osclbase.html#a81">NULL</a>; 19900218 <span class="keywordflow">return</span> current; 20000219 } 20100220 20200221 <span class="keyword">static</span> <a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>* SetErrorTrap(<a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>* a, int32& aError) 20300222 <span class="comment">//static function to set currently installed error trap</span> 20400223 <span class="comment">//for this thread. return previous error trap, if any.</span> 20500224 { 20600225 <a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>* temp = GetErrorTrap(aError); 20700226 PVERRORTRAP_REGISTRY::registerInstance(a, <a class="code" href="group__osclerror.html#a44">PVERRORTRAP_REGISTRY_ID</a>, aError); 20800227 <span class="keywordflow">return</span> temp; 20900228 } 21000229 21100230 <span class="comment">//Global cleanup function for OsclAny items.</span> 21200231 <span class="keyword">static</span> <span class="keywordtype">void</span> TrapOperation(<a class="code" href="group__osclbase.html#a25">OsclAny</a> *ptr) 21300232 { 21400233 int32 error; 21500234 <a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a> *trap = GetErrorTrap(error); 21600235 <span class="keywordflow">if</span> (trap && trap-><a class="code" href="classOsclErrorTrapImp.html#o0">iAlloc</a>) 21700236 trap-><a class="code" href="classOsclErrorTrapImp.html#o0">iAlloc</a>-><a class="code" href="classOscl__DefAlloc.html#a2">deallocate</a>(ptr); 21800237 <span class="keywordflow">else</span> 21900238 { 22000239 <a class="code" href="class__OsclBasicAllocator.html">_OsclBasicAllocator</a> alloc; 22100240 alloc.<a class="code" href="class__OsclBasicAllocator.html#a1">deallocate</a>(ptr); 22200241 } 22300242 } 22400243 22500244 <span class="comment">//default allocators.</span> 22600245 <a class="code" href="class__OsclBasicAllocator.html">_OsclBasicAllocator</a> iDefAlloc; 22700246 228<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>; 229<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>; 230<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>; 231<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>; 232<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>; 233<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>; 234<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>; 235<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>; 236<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>; 23700256 }; 23800257 23900258 24000259 <span class="preprocessor">#endif</span> 24100260 <span class="preprocessor"></span> 242</pre></div><hr size="1"><img src="pvlogo_small.jpg"><address style="align: right;"><small>OSCL API</small> 243<address style="align: left;"><small>Posting Version: OPENCORE_20090310 </small> 244</small></address> 245</body> 246</html> 247