cpplib.h

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

H
439
字号

/****************************************************************************
*
*                            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:  Definitions for C++ library
*
****************************************************************************/

#ifndef __CPPLIB_H__
#define __CPPLIB_H__

#ifndef __cplusplus
    #error CPPLIB.H only compiles under C++
#endif

#include "variety.h"
#ifdef _WPRTLINK_RESIDENT
  #undef _WPRTLINK
  #define _WPRTLINK __declspec(__watcall)
  #undef _WPRTDATA
  #define _WPRTDATA __declspec(__watcall)
#endif

struct  ACTIVE_EXC;
struct  DISPATCH_EXC;
union   RW_DTREG;
union   RO_DTREG;
struct  THREAD_CTL;
struct  _EXC_PR;

#if defined( M_I386 ) || defined( M_I86 )
    #define M_PC_INTEL 1
#endif


#include <stddef.h>

#define PointUsingOffset( type, base, offset ) \
    ( (type*)( (char*)base + offset ) )
#define PointOffset( base, offset ) \
    PointUsingOffset( void, base, offset )

// this is necessary to avoid unnecessary overhead on pointer arithmetic
#ifdef __HUGE__
#define RT_FAR __far
typedef unsigned    RT_STATE_VAR;       // State variable
typedef unsigned    offset_t;           // offset
#else
#define RT_FAR
typedef size_t      RT_STATE_VAR;       // State variable
typedef size_t      offset_t;           // offset
#endif

// TYPEDEFS : c vs c++ language insensitive typedefs

typedef void (*pFUNVOIDVOID)                    // function returns void
                ( void );                       // - takes void
typedef int  (*pFUNINTUNSIGNED)                 // function returns int
                ( unsigned );                   // - takes unsigned
typedef void (*pFUNpVOIDVOID)                   // function returns void
                ( void * );                     // - takes void *
typedef void *(*pFUNdtor)                       // dtor
                ( void *                        // - address
                , unsigned );                   // - dtor vbase flag
typedef void (*pFUNctor)                        // ctor
                ( void * );                     // - address
typedef void (*pFUNctorV)                       // ctor
                ( void *                        // - address
                , unsigned );                   // - ctor vbase flag
typedef void (*pFUNcopy)                        // copy ctor
                ( void *                        // - target
                , void * );                     // - source
typedef void (*pFUNcopyV)                       // copy ctor
                ( void *                        // - target
                , unsigned                      // - ctor vbase flag
                , void * );                     // - source

// twits at Microsoft define "boolean" in their Win32 header files
typedef int rboolean;

// set up indication of -xs

#if defined( __SW_XS ) || defined( __SW_XSS ) || defined( __SW_XST )
#define RT_EXC_ENABLED
#endif



#if defined(__MT__)
#include <lock.h>
#endif

extern "C" {

#include "wcpp.h"

#pragma warning 604 9
#pragma warning 594 9

#include "rtdata.h"

#pragma warning 604 1
#pragma warning 594 1

#if !defined(__PENPOINT__) && defined(__MT__)
    #pragma warning 604 9
    #pragma warning 594 9
    #include "thread.h"
    #pragma warning 604 1
    #pragma warning 594 1
#endif

#if defined( __USE_FS ) || defined( __USE_RW ) || defined( __USE_PD )
    #include "fsreg.h"
#endif


#if defined( M_ALPHA ) || defined( M_I386 )
    // pad to 4-byte boundary
    #define AlignPad1 char padding[3];
    #define AlignPad2 char padding[2];
#elif defined( M_I86 )
    // pad to 2-byte boundary
    #define AlignPad1 char padding[1];
    #define AlignPad2 ;
#else
    #error bad target
#endif


//************************************************************************
// Type Signatures
//************************************************************************

union rt_type_sig;                  // union of all signatures
typedef rt_type_sig *RT_TYPE_SIG;   // RT_TYPE_SIG

struct TYPE_SIG_HDR             // TYPE SIGNATURE: BASE
{   THROBJ type;                // - object type
};

struct TYPE_SIG_SCALAR          // TYPE SIGNATURE: SCALAR, POINTER TO CLASS
{   TS_HDR hdr;                 // - header
    size_t size;                // - size of scalar
    char const * name;          // - type-signature name
};

struct TYPE_SIG_CLASS           // TYPE SIGNATURE: CLASS (NO VIRTUAL BASES)
{   TS_HDR hdr;                 // - header
    pFUNctor ctor;              // - addr[ default CTOR ]
    pFUNcopy copyctor;          // - addr[ copy CTOR ]
    pFUNdtor dtor;              // - addr[ DTOR ]
    size_t size;                // - size of object thrown
    char const * name;          // - type-signature name
};

struct TYPE_SIG_CLASS_VIRT      // TYPE SIGNATURE: CLASS (VIRTUAL BASES)
{   TS_HDR hdr;                 // - header
    pFUNctorV ctor;             // - addr[ default CTOR ]
    pFUNcopyV copyctor;         // - addr[ copy CTOR ]
    pFUNdtor dtor;              // - addr[ DTOR ]
    size_t size;                // - size of object thrown
    char const * name;          // - type-signature name
};

struct TYPE_SIG_BASE            // TYPE SIGNATURE: INDIRECTED
{   TS_HDR base;                // - header
    RT_TYPE_SIG sig;            // - indirected signature
};

union rt_type_sig               // RT_TYPE_SIG: one of
{   TYPE_SIG_HDR hdr;           // - general header: object
    TS_HDR base;                // - general header: base
    TYPE_SIG_BASE indirected;   // - indirected
    TYPE_SIG_SCALAR scalar;     // - scalar
    TYPE_SIG_CLASS clss;        // - class (no virtual bases)
    TYPE_SIG_CLASS_VIRT clss_v; // - class (with virtual bases)
};



//************************************************************************
// Throw Definitions
//************************************************************************

struct THROW_CNV                // THROW CONVERSION
{   RT_TYPE_SIG signature;      // - type signature
    size_t offset;              // - offset
};

struct THROW_RO
{   size_t count;               // - number of throw conversions
    THROW_CNV cnvs[1];          // - throw conversions
};


//************************************************************************

⌨️ 快捷键说明

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