rtexcept.h
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C头文件 代码 · 共 732 行 · 第 1/2 页
H
732 行
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#ifndef __RTEXCEPT_H__
#define __RTEXCEPT_H__
#ifndef __cplusplus
#error RTEXCEPT.H only compiles under C++
#endif
struct _RTCTL;
typedef enum // TYPES OF DISPATCHABILITIES
{ DISPATCHABLE_NONE // - not dispatchable
, DISPATCHABLE_CATCH // - dispatchable for catch
, DISPATCHABLE_FNEXC // - dispatchable for function exception spec.
, DISPATCHABLE_NO_CATCH // - no catch block dispatchable (throw)
, DISPATCHABLE_STOP // - stop search: error situation
, DISPATCHABLE_SYS_EXC // - uncatchable system exception
} DISPATCHABLE;
#ifndef NDEBUG
#define GOOF_EXC( msg ) GOOF( msg )
#else
#define GOOF_EXC( msg ) CPPLIB( corrupted_stack )()
#endif
//************************************************************************
// Commands referenced from state-variable table
//************************************************************************
struct RT_ARRAY_INIT // RT_ARRAY_INIT: array being init'ed
{ void* array; // - addr[ array ]
RT_TYPE_SIG sig; // - type signature
offset_t index; // - initialized count
};
struct DTOR_CMD_BASE // BASE FOR DTOR_CMD
{ DTOR_CMD_CODE code; // - command
};
struct DTOR_CMD_ARRAY // DTOR_CMD: ARRAY
{ DTOR_CMD_BASE base; // - base
AlignPad1
offset_t offset; // - RT_ARRAY_INIT offset
offset_t count; // - # elements
RT_TYPE_SIG sig; // - type signature
};
struct DTOR_CMD_SET_SV // DTOR_CMD: SET_SV
{ DTOR_CMD_BASE base; // - base
AlignPad1
RT_STATE_VAR state_var; // - new state variable
};
struct DTOR_CMD_CTOR_TEST // DTOR_CMD: CTOR_TEST
{ DTOR_CMD_BASE base; // - base
AlignPad1
offset_t index; // - index of flag
};
struct DTOR_CMD_FN_EXC // DTOR_CMD: FN_EXC
{ DTOR_CMD_BASE base; // - base
AlignPad1
offset_t count; // - number of elements
RT_TYPE_SIG sigs[1]; // - type signatures permitted
};
struct DTOR_CMD_TRY // DTOR_CMD: TRY
{ DTOR_CMD_BASE base; // - base
DTOR_CMD_BASE base_catch; // - base: catch
AlignPad2
RT_STATE_VAR state; // - state preceding try
offset_t jmp_buf; // - RW-offset[ longjmp jmp_buf ]
offset_t offset; // - RW-offset[ try variable ]
offset_t count; // - number of catch blocks
RT_TYPE_SIG sigs[1]; // - type signatures for catches
};
#define TryFromCatch( cmd ) \
(DTOR_CMD *) \
( (char *)( cmd ) - __offsetof( DTOR_CMD_TRY, base_catch ) )
struct DTOR_CMD_TEST_FLAG // DTOR_CMD: TEST_FLAG
{ DTOR_CMD_BASE base; // - base
AlignPad1
offset_t index; // - index of flag
RT_STATE_VAR state_var_true; // - state variable, when true
RT_STATE_VAR state_var_false; // - state variable, when false
};
struct DTOR_CMD_COMPONENT // DTOR_CMD: COMPONENT
{ DTOR_CMD_BASE base; // - base
AlignPad1
offset_t offset_init; // - offset to RT_OBJECT_INIT element
offset_t offset_object; // - offset of component object
pFUNdtor dtor; // - DTOR address
};
struct DTOR_CMD_ARRAY_INIT // DTOR_CMD: ARRAY_INIT
{ DTOR_CMD_BASE base; // - base
AlignPad1
offset_t offset; // - offset of RT_ARRAY_INIT
};
typedef void (*pFunDelete1)( void* );
typedef void (*pFunDelete2)( void*, size_t );
union pFunDelete {
pFunDelete1 delete_1;
pFunDelete2 delete_2;
};
struct DTOR_CMD_DLT_1 // DTOR_CMD: DTC_DLT_..._1
{ DTOR_CMD_BASE base; // - base
AlignPad1
offset_t offset; // - offset to ptr to area
pFunDelete1 op_del; // - operator delete( void* );
};
struct DTOR_CMD_DLT_2 // DTOR_CMD: DTC_DLT_..._2
{ DTOR_CMD_BASE base; // - base
AlignPad1
offset_t offset; // - offset to ptr to area
pFunDelete2 op_del; // - operator delete( void*, size_t );
size_t size; // - size of object
};
union DTOR_CMD // DTOR_CMD: one of
{ DTOR_CMD_BASE base; // - base
DTOR_CMD_ARRAY array; // - array
DTOR_CMD_SET_SV set_sv; // - set_sv
DTOR_CMD_FN_EXC fn_exc; // - fn_exc
DTOR_CMD_TRY try_cmd; // - try
DTOR_CMD_TEST_FLAG test_flag; // - test_flag
DTOR_CMD_COMPONENT component; // - component of object
DTOR_CMD_ARRAY_INIT array_init; // - array being initialized
DTOR_CMD_DLT_1 delete_1; // - delete: operator delete(void*)
DTOR_CMD_DLT_2 delete_2; // - delete: operator delete(void*,size_t)
DTOR_CMD_CTOR_TEST ctor_test; // - ctor-test
};
//************************************************************************
// Static command codes
//************************************************************************
struct STATIC_CMDS // STATIC COMMANDS
{ DTOR_CMD_CODE direct_base; // - direct base
DTOR_CMD_CODE virtual_base; // - virtual base
DTOR_CMD_SET_SV set_sv_cmds[ MAX_SET_SV ]; // - set-sv commands
};
//************************************************************************
// State variable table
//************************************************************************
struct RO_STATE // RO_STATE -- R/O entry for state var.
{ pFUNdtor dtor; // - NULL or DTOR address
union { // - one of
void* data_addr; // - - data address
offset_t data_offset; // - - data offset
DTOR_CMD* cmd_addr; // - - command address
} u;
};
//************************************************************************
// Registration Definitions
//************************************************************************
struct RO_DTREG_BASE // RO_DTREG_BASE -- R/O base
{ offset_t reg_type; // - type of registration
};
struct RW_DTREG_BASE // RW_DTREG_BASE -- R/W base (automatic)
{
#ifdef RW_REGISTRATION
RW_DTREG* prev; // - previous entry
FS_HANDLER* handler; // - fs: handler
#endif
RO_DTREG* ro; // - R/O entry
RT_STATE_VAR state_var; // - state variable
};
struct RW_DTREG_BASE_STATIC // RW_DTREG_BASE -- R/W base (static)
{ RW_DTREG* prev; // - previous entry
RO_DTREG* ro; // - R/O entry
RT_STATE_VAR state_var; // - state variable
};
#ifdef RW_REGISTRATION
struct RW_DTREG_ROOT // RW_DTREG_BASE -- R/W base
{ RW_DTREG* prev; // - previous entry
FS_HANDLER* handler; // - fs: handler
FS_HANDLER* signature; // - fs: handler (again, used as signature)
THREAD_CTL* pgm_thread; // - thread when WATCOM program (across DLL'S)
};
#endif
//************************************************************************
// Registration for a function
//************************************************************************
struct RW_DTREG_FUN // R/W registration
{ RW_DTREG_BASE base; // - base
uint_8 flags[1]; // - flags [optional]
};
struct RO_DTREG_FUN // R/O registration
{ RO_DTREG_BASE base; // - base
#ifdef PD_REGISTRATION
offset_t rw_offset; // - offset[ R/W from frame ]
#endif
RO_STATE state_table[1]; // - state table
};
//************************************************************************
// Registration for an Object
//************************************************************************
struct RW_DTREG_OBJECT // R/W registration (not linked, no state)
{ void* object; // - object address
uint_8 cdtor; // - CDTOR used to ctor/dtor object
};
//************************************************************************
// Registration for static initialization
//************************************************************************
struct RW_DTREG_INITFS // R/W registration, file scope
{ RW_DTREG_BASE_STATIC base; // - base
};
struct RO_DTREG_INITFS // R/O registration, file scope
{ RO_DTREG_BASE base; // - base
RO_STATE state_table[1]; // - state table
};
struct RW_DTREG_INITLS_STATIC // R/W registration, local scope (memory)
{ RW_DTREG_BASE_STATIC base; // - base
void* object; // - object to be DTOR'ED
};
struct RW_DTREG_INITLS // R/W registration, local scope (stack)
{ RW_DTREG_BASE base; // - base
void* object; // - object to be DTOR'ED
};
struct RO_DTREG_INITLS // R/O registration, local scope
{ RO_DTREG_BASE base; // - base
RO_STATE state_table[1]; // - state table
};
//************************************************************************
// Registration Definitions
//************************************************************************
union RW_DTREG // R/W Registration: one of
{ RW_DTREG_BASE base; // - base (automatic)
RW_DTREG_BASE_STATIC base_st;//- base (static)
#ifdef RW_REGISTRATION
RW_DTREG_ROOT root; // - root
#endif
RW_DTREG_FUN fun; // - function
RW_DTREG_INITLS_STATIC init_ls_st; // - static init., local scope (static)
};
union RO_DTREG // R/O Registration: one of
{ RO_DTREG_BASE base; // - base
RO_DTREG_FUN fun; // - function
RO_DTREG_INITLS init_ls; // - static init., local scope
};
//************************************************************************
// Support for state-table traversal
//************************************************************************
enum // OB_TYPE -- type of object
{ OBT_OBJECT // - complete object
, OBT_MEMBER // - member
, OBT_DBASE // - direct base
, OBT_VBASE // - virtual base
};
typedef uint_8 OB_TYPE;
struct STAB_TRAVERSE // STAB_TRAVERSE -- control for traversal
{ _RTCTL* rtc; // - R/T control info
RT_STATE_VAR state_var; // - state variable for position
RT_STATE_VAR bound; // - bound for traversal
OB_TYPE obj_type; // - type of object
uint_8 unwinding :1; // - TRUE ==> unwinding stack
unsigned :0; // - alignment
};
//************************************************************************
// Static Initialization
//************************************************************************
struct MODRO_LS // local-scope R/O registration
{ offset_t reg_type; // - registration type
RO_STATE state_table[1]; // - state table (one entry)
};
struct MODRW_LS // local-scope R/W registration (one var.)
{ MODRW_LS *prev; // - previous R/W block (NULL==>not init.ed)
MODRO_LS *ro; // - R/O for module
};
struct THROW_RW // THROW_RW - R/W INFORMATION FOR A THROW
{ THROW_RW *prev; // - previous throw pending in thread
THROW_RO *ro_blk; // - R/O information for thrown object
char thrown[1]; // - thrown object
};
enum EXCSTATE // STATES FOR EXCEPTIONS
{ EXCSTATE_UNWIND = 0 // - attempting to unwind
, EXCSTATE_DISPATCH = 1 // - handler has been dispatched
, EXCSTATE_UNEXPECTED = 2 // - "unexpected" routine has been called
, EXCSTATE_TERMINATE = 3 // - "terminate" routine has been called
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?