cpplib.h

来自「开放源码的编译器open watcom 1.6.0版的源代码」· C头文件 代码 · 共 439 行 · 第 1/2 页

H
439
字号
// Miscellaneous definitions
//************************************************************************

struct ARRAY_STORAGE            // ARRAY_STORAGE -- structure of array
{   size_t element_count;       // - number of elements
    char apparent_address[];    // - address used in code
};

#define ArrayStorageFromArray( array ) \
    (ARRAY_STORAGE*) ( (char*)(array) - sizeof( ARRAY_STORAGE ) )

//*** PLEASE NOTE !!! ****************************************************
// If struct thread_ctl changes in size, be sure to update
// struct wint_thread_ctl in clib\h\thread.h to reflect the change.
//
// See CGBKRREG.C
//  - offset of thread_ctl.registered, thread_ctl.flags is known
//
//************************************************************************

struct THREAD_CTL               // THREAD_CTL -- control execution thread
{
    union {
        RW_DTREG* registered;   // - list of registrations, execution
        THREAD_CTL* call_base;  // - furthest THREAD_CTL down call chain
    };
    union {
        struct {                    // - flags:
            unsigned terminated :1; // - - "terminate" called
            unsigned executable :1; // - - is .EXE (not .DLL)
        } flags;
        void *d0;               // - padding
    };
    ACTIVE_EXC *excepts;        // - exceptions being handled
    char *abort_msg;            // - abortion message
    pFUNVOIDVOID unexpected;    // - "unexpected" routine
    pFUNVOIDVOID terminate;     // - "terminate" routine
    pFUNVOIDVOID new_handler;   // - new_handler routine (ANSI)
    pFUNINTUNSIGNED _new_handler;//- _new_handler routine (Microsoft)
    _EXC_PR* exc_pr;            // - controls exceptional processing
};


//************************************************************************
// GLOBAL DATA
//************************************************************************
#if( ! defined(GBL) )
    #define GBL _WPRTLINK extern
#endif

//************************************************************************
// Per Thread Data
// Storage is allocated in in cppdata.obj for non multi-thread or
// by the clib BeginThread() routine for multi-thread.
//*** PLEASE NOTE !!! ****************************************************
// If the _ThreadData macro changes for multi-thread, be sure to
// update clib\h\thread.h
//************************************************************************
#if defined(__MT__)
#if defined(__386__) || defined(__AXP__)
  GBL unsigned              _wint_thread_data_offset;
  #define _ThreadData (*((THREAD_CTL*)(((char *)__THREADDATAPTR)+_wint_thread_data_offset)))
#else
  #define _ThreadData (*((THREAD_CTL*)&(__THREADDATAPTR->_wint_thread_data)))
#endif
#else
GBL THREAD_CTL              _wint_thread_data;
#define _ThreadData         _wint_thread_data
#endif

//************************************************************************
// Per Process Data
// storage is allocated in prwdata.asm for everyting but PENPOINT
// PENPOINT allocates storage with clib\ph\rtdata.h
//************************************************************************
#if !defined(__PENPOINT__)
extern short                _wint_pure_error_flag;
extern short                _wint_undef_vfun_flag;
extern RW_DTREG*            _wint_module_init;
#define _PureErrorFlag      _wint_pure_error_flag
#define _UndefVfunFlag      _wint_undef_vfun_flag
#define _ModuleInit         _wint_module_init

#if defined(__MT__)
extern __lock               _wint_static_init_sema;
#define _StaticInitSema     _wint_static_init_sema
#endif

#endif


//************************************************************************
// PROTOTYPES
//************************************************************************

void CPPLIB( call_terminate )(      // CALL "terminate" SET BY "set_terminate"
    char* abort_msg,                // - abortion message
    THREAD_CTL *thr )               // - thread-specific data
;
void CPPLIB( call_unexpected )(     // CALL "unexpected" SET BY "set_unexpected"
    void )
;
_WPRTLINK
void * CPPLIB(copy_array)(          // CALL COPY CONSTRUCTORS FOR ARRAY
    void *tgt_array,                // - target array (element w/o virtual base)
    void *src_array,                // - source array
    unsigned count,                 // - number of elements
    RT_TYPE_SIG sig )               // - signature of array
;
_WPRTLINK
void * CPPLIB(copy_varray)(         // CALL COPY CONSTRUCTORS FOR ARRAY
    void *tgt_array,                // - target array (element has virtal base)
    void *src_array,                // - source array
    unsigned count,                 // - number of elements
    RT_TYPE_SIG sig )               // - signature of array
;
_WPRTLINK
void * CPPLIB(ctor_array)(          // CALL CONSTRUCTORS FOR NEW ARRAY ELEMENTS
    void *array,                    // - array
    unsigned count,                 // - number of elements
    RT_TYPE_SIG sig )               // - signature of array
;
_WPRTLINK
void * CPPLIB(ctor_varray)(         // CALL CONSTRUCTORS FOR NEW ARRAY ELEMENTS
    void *array,                    // - array
    unsigned count,                 // - number of elements
    RT_TYPE_SIG sig )               // - signature of array
;
_WPRTLINK
void * CPPLIB(dtor_array)(          // CALL DESTRUCTORS FOR ARRAY ELEMENTS
    void *array,                    // - array
    unsigned count,                 // - number of elements
    RT_TYPE_SIG sig )               // - signature of array
;
_WPRTLINK
ARRAY_STORAGE* CPPLIB(dtor_array_store)(  // CALL DTORS FOR ARRAY_STORAGE
    void *array,                    // - array
    RT_TYPE_SIG sig )               // - type signature for array type
;
void CPPLIB(dtor_del_array)(        // CALL DTORS FOR ARRAY ELEMENTS AND DELETE
    void *array,                    // - array
    RT_TYPE_SIG sig )               // - type signature for array type
;
void CPPLIB(dtor_del_array_x)(      // CALL DTORS FOR ARRAY ELEMENTS AND DELETE
    void *array,                    // - array
    RT_TYPE_SIG sig )               // - type signature for array type
;
_WPRTLINK
pFUNVOIDVOID CPPLIB( lj_handler )   // GET ADDRESS OF longjmp HANDLER
    ( void )
;
void CPPLIB(module_dtor)            // DTOR STATICS FOR PROGRAM
    ( void )
;
void CPPLIB(multi_thread_init)      // INITIALIZER FOR MULTI-THREAD DATA
    ( void )
;
void* CPPLIB( new_allocator )(      // DEFAULT ALLOCATOR FOR NEW, NEW[]
    size_t size )                   // - size required
;
void * CPPLIB(new_array)(           // CALL NEW AND CTORS FOR ARRAY ELEMENTS
    ARRAY_STORAGE *new_alloc,       // - what was allocated
    unsigned count,                 // - number of elements
    RT_TYPE_SIG sig )               // - type signature for array type
;
void * CPPLIB(new_varray)(          // CALL NEW AND CTORS FOR ARRAY ELEMENTS
    ARRAY_STORAGE *new_alloc,       // - what was allocated
    unsigned count,                 // - number of elements
    RT_TYPE_SIG sig )               // - type signature for array type
;
void * CPPLIB(new_darray)(          // CALL NEW AND CTORS FOR ARRAY ELEMENTS
    ARRAY_STORAGE *new_alloc,       // - what was allocated
    unsigned count )                // - number of elements
;
_WPRTLINK
void CPPLIB(pure_error)(            // TRAP NON-OVERRIDDEN PURE VIRTUAL CALLS
    void )
;
void CPPLIB(fatal_runtime_error)(   // FATAL RUNTIME ERROR
    char *msg,                      // - diagnostic message
    int code )                      // - exit code
;
rboolean CPPLIB( ts_equiv )(         // TEST IF TYPE SIG.S ARE EQUIVALENT
    RT_TYPE_SIG tgt,                // - target type signature
    RT_TYPE_SIG src,                // - source type signature
    rboolean zero_thrown )           // - TRUE ==> zero was thrown
;
RT_TYPE_SIG CPPLIB( ts_pnted )(     // POINT PAST POINTER TYPE-SIG
    RT_TYPE_SIG sig )               // - the signature
;
RT_TYPE_SIG CPPLIB( ts_refed )(     // POINT PAST REFERENCE TYPE-SIG, IF REQ'D
    RT_TYPE_SIG sig )               // - the signature
;
size_t CPPLIB( ts_size )(           // GET SIZE OF ELEMENT FROM TYPE SIGNATURE
    RT_TYPE_SIG sig )               // - type signature
;
_WPRTLINK
void CPPLIB( undefed_cdtor )(       // ISSUE ERROR FOR UNDEFINED CTOR, DTOR
    void )
;
void CPPLIB( unmark_bitvect )(      // UNMARK LAST BIT IN BIT-VECTOR
    uint_8 *bit_vect,               // - bit vector
    size_t bit_count )              // - # bits in vector
;

#ifndef NDEBUG
    #define GOOF( msg ) CPPLIB(fatal_runtime_error)( "*** GOOF **" msg, 1 )
#else
    #define GOOF( msg )
#endif

#define KLUGE_CPPLIB_END
#include "kluges.h"

};  // extern "C"


#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?