exc_defs.h
来自「澳洲人写的Cortex,包括uC_IP协议栈」· C头文件 代码 · 共 219 行
H
219 行
<HTML><HEAD><TITLE>/home/asysweb/public_html/cortex/kernel/src/exc_defs.h</TITLE></HEAD><BODY><pre><font color="#6920ac">/*************************************************************************/</font><font color="#6920ac">/* */</font><font color="#6920ac">/* Copyright (c) 1997-1999 Australian Real Time Embedded Systems */</font><font color="#6920ac">/* */</font><font color="#6920ac">/* PROPRIETARY RIGHTS of Australian Real Time Embedded Systems */</font><font color="#6920ac">/* are involved in the subject matter of this material. All reproduction,*/</font><font color="#6920ac">/* manufacturing, use, and sales rights pertaining to this subject matter*/</font><font color="#6920ac">/* are governed by the license agreement. The recipient of this software */</font><font color="#6920ac">/* implicitly accepts the terms of the license. */</font><font color="#6920ac">/* */</font><font color="#6920ac">/*************************************************************************/</font><font color="#6920ac">/************************************************************************* * * FILE NAME * * exc_defs.h * * SYSTEM COMPONENT * * Exception Handler * * DESCRIPTION * * This commponent allowes to raise an exception and install * a handler to caught exception. This component simply wraps * setjmp/longjmp in a set of macros and functions to provide * a structure exception facility. * Exception handler may be installed by using EXCP_TRY-EXCP_END * structure: * * EXCP_TRY * S (install exception handlers and process block S) * (EXCP_RETURN must be used to return from this block) * EXCP_EXCEPT(e1) * S1 (this block to be performed if e1 exception occured) * EXCP_EXCEPT(e2) * S2 (this block to be performed if e2 exception occured) * EXCP_ELSE * S0 (this block to be performed if any other exception detected) * EXCP_FINALLY * Sf (excuted after S-block if no exception occured; * also excuted after exception processing block Si if * exception occured; may reraise exception if exception * has not been handled) * EXCP_END * * EXCP_EXCEPTION, EXCP_ELSE and EXCP_FINALLY sections are optional. * Use EXCP_RAISE and/or EXCP_RAISE_SPECIFIC to raise exception from * within block S. * * This implementation is borowed (with very minor modifications) from: * * Hanson, David R. * C Interfaces and implementations: techniques for creating * reusable software * (Addison-Wasley professional computing series) * ISBN 0-201-49841-3 * * SCCS HISTORY * * @(#)exc_defs.h 1.5, 06/18/99, 20:45:39 * * AUTHOR * * Vadim N. Azarovsky * * CREATED * * 19-Mar-1997 by Vadim N. Azarovsky * * REVISION HISTORY * * NAME DATE REMARKS * **************************************************************************/</font><b><font color='DarkGreen'>#ifndef</font></b><font color="maroon"> __EXC_DEFS__H</font><b><font color='DarkGreen'>#define</font></b> <font color="maroon"><a name="__EXC_DEFS__H">__EXC_DEFS__H</a></font><b><font color='DarkGreen'>#ifdef</font></b><font color="maroon"> __cplusplus</font><i>extern</i> <font color="DarkGreen">"C"</font> {<b><font color='DarkGreen'>#endif</font></b><font color="maroon"> <font color="#6920ac">/* __cplusplus */</font></font><b><font color='DarkGreen'>#include</font></b> <a href="crt_defs.h.FIND-INC"><font color="blue">"crt_defs.h"</font></a><b><font color='DarkGreen'>#include</font></b> <a href="setjmp.h.FIND-INC"><<font color="blue">setjmp.h</font>></a><font color="#6920ac">/*********************** * GLOBAL CONSTANSTS * ***********************/</font><font color="#6920ac">/* None */</font><font color="#6920ac">/******************* * GLOBAL MACROS * *******************/</font><font color="#6920ac">/* Begin exception statement */</font><b><font color='DarkGreen'>#define</font></b> <font color="maroon"><a name="EXCP_TRY">EXCP_TRY</a></font> \ <b>do</b> { \ <i>volatile</i> <i>excp_State_t</i> excp_State; \ <i>excp_StackFrame_t</i> excp_CurrFrame; \ excp_CurrFrame.pPrevFrame = excp_Stack_g; \ excp_Stack_g = &excp_CurrFrame; \ excp_State = (<i>excp_State_t</i>)<a href="setjmp.FIND-FUNC">setjmp</a>(excp_CurrFrame.Environ); \ <b>if</b> (excp_State == excp_Entered) {<font color="#6920ac">/* Process specified exception */</font><b><font color='DarkGreen'>#define</font></b> <font color="maroon"><a name="EXCP_EXCEPT">EXCP_EXCEPT</a></font>(_excp) \ <b>if</b> (excp_State == excp_Entered) \ excp_Stack_g = excp_Stack_g->pPrevFrame; \ } <b>else</b> <b>if</b> (excp_CurrFrame.pException == &(_excp)) { \ excp_State = excp_Handled;<font color="#6920ac">/* Process unspecified exception */</font><b><font color='DarkGreen'>#define</font></b> <font color="maroon"><a name="EXCP_ELSE">EXCP_ELSE</a></font> \ <b>if</b> (excp_State == excp_Entered) \ excp_Stack_g = excp_Stack_g->pPrevFrame; \ } <b>else</b> { \ excp_State = excp_Handled;<font color="#6920ac">/* Finalise exception */</font><b><font color='DarkGreen'>#define</font></b> <font color="maroon"><a name="EXCP_FINALLY">EXCP_FINALLY</a></font> \ <b>if</b> (excp_State == excp_Entered) \ excp_Stack_g = excp_Stack_g->pPrevFrame; \ } { \ <b>if</b> (excp_State == excp_Entered) \ excp_State = excp_Finalised;<font color="#6920ac">/* End of exception statement */</font><b><font color='DarkGreen'>#define</font></b> <font color="maroon"><a name="EXCP_END">EXCP_END</a></font> \ <b>if</b> (excp_State == excp_Entered) \ excp_Stack_g = excp_Stack_g->pPrevFrame; \ } <b>if</b> (excp_State == excp_Raised) <a href="#EXCP_RERAISE">EXCP_RERAISE</a>; \ } <b>while</b> (0)<font color="#6920ac">/* Raise exception */</font><b><font color='DarkGreen'>#define</font></b> <font color="maroon"><a name="EXCP_RAISE">EXCP_RAISE</a></font>(_excp) excp_Raise(&(_excp), __FILE__, __LINE__, CRTX_NULL)<font color="#6920ac">/* Raise exception with exception specific data provided */</font><b><font color='DarkGreen'>#define</font></b> <font color="maroon"><a name="EXCP_RAISE_SPECIFIC">EXCP_RAISE_SPECIFIC</a></font>(_excp,_data) \ <a href="excp_Raise.FIND-FUNC">excp_Raise</a>(&(_excp), <a href="__FILE__.FIND-DEF">__FILE__</a>, <a href="__LINE__.FIND-DEF">__LINE__</a>, (_data))<font color="#6920ac">/* Reraise exception excplicitly */</font><b><font color='DarkGreen'>#define</font></b> <font color="maroon"><a name="EXCP_RERAISE">EXCP_RERAISE</a></font> excp_Raise(excp_CurrFrame.pException, \ excp_CurrFrame.pFile, excp_CurrFrame.Line)<font color="#6920ac">/* * EXCP_RETURN macro MUST be used to instead of return statements * inside EXCP_TRY statements. It is unchecked runtime error to * execute the C return statement inside a EXCP_TRY-EXCP_EXCEPT, * EXCP_TRY-EXCP_ELSE or EXP_TRY-EXCP_FINALLY statement. */</font><b><font color='DarkGreen'>#define</font></b> <font color="maroon"><a name="EXCP_RETURN">EXCP_RETURN</a></font> \ <b>switch</b> (excp_State==excp_Entered && \ excp_Stack_g=excp_Stack_g->pPrevFrame, 0) <b>default</b>: <b>return</b><font color="#6920ac">/*********************** * GLOBAL DATA TYPES * ***********************/</font><font color="#6920ac">/* Exception descriptor */</font><i><a name="excp_Descr_t">typedef</a></i> <i>struct</i> { <i>char</i> *Descr; <font color="#6920ac">/* exception description */</font>} <i><font color='DarkBlue'>excp_Descr_t</font></i>;<font color="#6920ac">/* Exception stack frame */</font><i><a name="excp_StackFrame_t">typedef</a></i> <i>struct</i> excp_StackFrame_s <i><font color='DarkBlue'>excp_StackFrame_t</font></i>;<i>struct</i> excp_StackFrame_s { <i>excp_StackFrame_t</i> *pPrevFrame; <font color="#6920ac">/* previous exception frame */</font> jmp_buf Environ; <font color="#6920ac">/* longjump environment */</font> <i>crtx_Char_t</i> *pFile; <font color="#6920ac">/* exception's file name */</font> <i>crtx_Int_t</i> Line; <font color="#6920ac">/* exception's line number */</font> <i>crtx_Void_t</i> *pData; <font color="#6920ac">/* exception's specific data */</font> <i>excp_Descr_t</i> *pException; <font color="#6920ac">/* exception descriptor */</font>};<font color="#6920ac">/* Exception states within EXCP_TRY statement */</font><i><a name="excp_State_t">typedef</a></i> <i>enum</i> { excp_Entered=0, <font color="#6920ac">/* exception statement is entered */</font> excp_Raised, <font color="#6920ac">/* exception is reised */</font> excp_Handled, <font color="#6920ac">/* exception handled by exception handler */</font> excp_Finalised <font color="#6920ac">/* exception statement is finalised */</font>} <i><font color='DarkBlue'>excp_State_t</font></i>;<font color="#6920ac">/***************** * GLOBAL DATA * *****************/</font><font color="#6920ac">/* excp_Stack_g points to the top exception frame on the exception stack and the pPrevFrame of each frame points to its predecessor */</font><i>extern</i> <i>excp_StackFrame_t</i> *excp_Stack_g;<font color="#6920ac">/*************************** * PROCEDURES PROTOTYPES * ***************************/</font><font color="#6920ac">/* * Core Functions */</font><font color="#6920ac">/* Raise exception */</font><font size="+1"><i>crtx_Void_t</i> <a href="excp_Raise.FIND-FUNC">excp_Raise</a>(<i>excp_Descr_t</i> *pException_a, <i>crtx_Char_t</i> *pFile_a, <i>crtx_Int_t</i> Line_a, <i>crtx_Void_t</i> *pData_a);</font><font color="#6920ac">/* ===== END OF THE DEFINITION FILE ===== */</font><b><font color='DarkGreen'>#ifdef</font></b><font color="maroon"> __cplusplus</font>}<b><font color='DarkGreen'>#endif</font></b><font color="maroon"> <font color="#6920ac">/* __cplusplus */</font></font><b><font color='DarkGreen'>#endif</font></b><font color="maroon"> <font color="#6920ac">/* __EXC_DEFS__H */</font></font></pre></BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?