home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l350 / 3.ddi / INCLUDE / PLTYPES.H < prev   
Encoding:
C/C++ Source or Header  |  1993-01-13  |  7.1 KB  |  214 lines

  1. /* PLTYPES.H - Definitions for Phar Lap standard data types         */
  2. /* $Id: pltypes.h 2.1 93/01/13 13:09:42 rwm Exp $ */
  3. /************************************************************************/
  4. /*    Copyright (C) 1986-1993 Phar Lap Software, Inc.            */
  5. /*    Unpublished - rights reserved under the Copyright Laws of the    */
  6. /*    United States.  Use, duplication, or disclosure by the         */
  7. /*    Government is subject to restrictions as set forth in         */
  8. /*    subparagraph (c)(1)(ii) of the Rights in Technical Data and     */
  9. /*    Computer Software clause at 252.227-7013.            */
  10. /*    Phar Lap Software, Inc., 60 Aberdeen Ave., Cambridge, MA 02138    */
  11. /************************************************************************/
  12.  
  13. #ifndef PLTYPES
  14. #define PLTYPES
  15.  
  16. /*
  17.  * Define the symbol __MSC32__ if we are compiling with a Microsoft C 32-bit
  18.  * compiler
  19.  */
  20. #if defined(_MSC_VER) && (_M_IX86 >= 300)
  21. /* It's a Microsoft compiler, with a target of an 80386 or later */
  22. #define __MSC32__
  23. #endif
  24.  
  25. /*
  26.  * Compiler features, used to control data type and function prototype
  27.  * setup here, and in PHARLAP.H and PLDOS32.H
  28.  *
  29.  * We set up features for Microsoft 32-bit C/C++, MetaWare High C/C++,
  30.  * and Watcom C/386 here.  For other compilers, we assume all features
  31.  * are supported;  if this is not the case for your compiler, set up
  32.  * __CMPLR_FEATURES__ appropriately here.
  33.  */
  34. #define __FEATURE_FARPTR__    0x00000001    // FAR pointers supported
  35. #define __FEATURE_DOSCALL__    0x00000002    // _dos_, _bios_, _intdosx, 
  36.                         // _int86x calls supported in
  37.                         // C run-time library
  38.  
  39. #ifdef __MSC32__
  40. // Microsoft 32-bit C/C++
  41. #define __CMPLR_FEATURES__    0
  42. #endif
  43.  
  44. #if defined(__HIGHC__) || defined(__WATCOMC__)
  45. // MetaWare High C/C++ and Watcom C/386
  46. #define __CMPLR_FEATURES__    (__FEATURE_FARPTR__ | __FEATURE_DOSCALL__)
  47. #endif
  48.  
  49. #ifndef __CMPLR_FEATURES__
  50. // Assume other compilers support all features
  51. #define __CMPLR_FEATURES__    (__FEATURE_FARPTR__ | __FEATURE_DOSCALL__)
  52. #endif
  53.  
  54. /*
  55.  * Keyword used to force stack-based calling conventions in function prototypes
  56.  * for Phar Lap library routines in PHARLAP.H and PLDOS32.H, even if 
  57.  * compiling with register-based calling conventions.
  58.  */
  59. #define __STKCALL        /* define to nothing by default */
  60. #ifdef __HIGHC__
  61. #undef __STKCALL
  62. //#define __STKCALL _CC(_CALLING_CONVENTION & ~_ARGS_IN_REGS)
  63. // High C won't let you turn off reg-based arg passing on an individual
  64. // basis when it's turned on globally.  However, (at least in version 3.03)
  65. // it's always disabled anyway as long as the function isn't declared static.
  66. #define __STKCALL
  67. #endif
  68. #if defined(__WATCOMC__) || defined(__MSC32__)
  69. #undef __STKCALL
  70. #define __STKCALL __cdecl    /* This works for Microsoft and Watcom */
  71. #endif
  72.  
  73. /*
  74.  * Basic data types and constants.  Some of these are conditionally defined
  75.  * to prevent conflicts with include files for various compilers or
  76.  * operating systems
  77.  */
  78. #ifndef STDPL        /* defined if internal Phar Lap header file included */
  79. #ifndef OS2_INCLUDED    /* defined if OS2.H is included before this file */
  80.  
  81. typedef unsigned char UCHAR;    /* unsigned 8-bit value */
  82. typedef short SHORT;        /* signed 16-bit value */
  83. typedef unsigned short USHORT;    /* unsigned 16-bit value */
  84. typedef unsigned int UINT;    /* unsigned integer */
  85. #ifndef LONG    /* some folks like to #define LONG */
  86. typedef long LONG;        /* signed 32-bit value */
  87. #endif    /* LONG */
  88. typedef unsigned long ULONG;    /* unsigned 32-bit value */
  89. /* NOTE - BOOL is a conflicting data type between OS2 and DOSX */
  90. typedef int BOOL;        /* Boolean value */
  91.  
  92. #define TRUE    1        /* Boolean true */
  93. #define FALSE    0        /* Boolean false */
  94.  
  95. #endif /* OS2_INCLUDED */
  96.  
  97. typedef void *PTR;        /* generic pointer */
  98. #define EOS  '\0'        /* end-of-string character */
  99.  
  100. #endif /* STDPL */
  101.  
  102. /*
  103.  
  104. Real mode pointer data type (segment:offset16)
  105.  
  106. The REALPTR data type is used in protected mode to hold
  107. real mode pointers.  The data type is an unsigned long value.
  108. The upper 16 bits of the long are a segment number and the lower
  109. 16 bits of the long are an offset.  The format of REALPTR is
  110. identical to a standard pointer as used in real mode.  The 
  111. REALPTR data type is used when mixing real and protected mode
  112. code in the same program.  A REALPTR cannot be dereferenced
  113. in protected mode since the format of pointers in real and
  114. protected mode are different.
  115.  
  116. As well as the data definition for the REALPTR type, the following
  117. macros are available to set and extract the segment and
  118. offset fields of a REALPR.  The RP_OFF macro returns the offset
  119. portion of a REALPTR.  The RP_SEG macro returns the segment portion
  120. of a REALPTR.  The macro RP_SET is used to combine a segment and an
  121. offset into a REALPTR.  It takes three arguments: the name of the 
  122. REALPTR to be set, an offset, and a segment number.
  123. The RP_INCR macro incrments the offset portion of a REALPTR.
  124.  
  125. */
  126.  
  127. typedef ULONG REALPTR;
  128.  
  129. #define RP_OFF(rp) ((USHORT)(((ULONG)(rp)) & 0xFFFF))
  130. #define RP_SEG(rp) ((USHORT)(((ULONG)(rp)) >> 16))
  131. #define RP_SET(rp, off, seg) (rp = ((ULONG)(seg) << 16) + (off))
  132. #define RP_INCR(rp, incr) (rp += ((ULONG) (incr)) & 0xFFFF)
  133.  
  134.  
  135. /*
  136.  
  137. Far pointer data type (selector:offset32)
  138.  
  139. The Microsoft C 32-bit compiler does not support far pointers.  For this
  140. compiler, a FARPTR is defined as a structure which has the same organization
  141. in memory as a standard 48-bit far pointer.
  142.  
  143. The MetaWare High C/C++ and Watcom C/386 compilers support far pointers in
  144. The MetaWare 80386 High C compiler supports far pointers as well as
  145. addition to 32-bit near pointers.  
  146.  
  147. The following macros are used to get and set the selector and offset fields
  148. of far pointers, and work both for compilers that directly support far 
  149. pointers and compilers that don't have far pointer support.  
  150. The FP_SEL macro returns the 16-bit selector number field
  151. of a far pointer.  The FP_OFF macro returns the 32-bit offset
  152. field of a far pointer.  The FP_SET macro is used to construct a far
  153. pointer from a selector number and offset.  It takes three arguments:
  154. the name of the far pointer to be set, an offset, and a selector number.
  155. The FP_INCR macro increments the offset field of a far pointer.
  156.  
  157. */
  158.  
  159. #if __CMPLR_FEATURES__ & __FEATURE_FARPTR__
  160. /*
  161.  * Compilers that support far pointers
  162.  */
  163. typedef UCHAR _far *FARPTR;
  164.  
  165. #ifndef FP_SEL
  166. #define FP_SEL(fp) ((USHORT)(*(((USHORT *)&(fp))+sizeof(UINT)/sizeof(USHORT))))
  167. #endif
  168.  
  169. #ifndef FP_OFF
  170. #define FP_OFF(fp) ((UINT)(*(UCHAR **)&(fp)))
  171. #endif
  172.  
  173. #ifndef FP_SET
  174. #define FP_SET(fp, off, sel) ((*(UINT *)&(fp)=(UINT)(off)),\
  175. (*(((USHORT *)&(fp)) + sizeof(UINT)/sizeof(USHORT))=sel))
  176. #endif
  177.  
  178. #ifndef FP_INCR
  179. #define FP_INCR(fp, incr) (*(UINT *)&(fp) += (UINT) (incr))
  180. #endif
  181.  
  182. #else
  183. /*
  184.  * Compilers that don't support far pointers;  use a struct instead.
  185.  */
  186. typedef struct {
  187.     ULONG    Off;
  188.     USHORT    Sel;
  189. } FARPTR;
  190.  
  191. #ifndef FP_SEL
  192. #define FP_SEL(fp) ((fp).Sel)
  193. #endif
  194.  
  195. #ifndef FP_OFF
  196. #define FP_OFF(fp) ((fp).Off)
  197. #endif
  198.  
  199. #ifndef FP_SET
  200. #define FP_SET(fp, off, sel) \
  201.     {\
  202.         (fp).Sel = (USHORT) (sel);\
  203.         (fp).Off = (ULONG) (off);\
  204.     }
  205. #endif
  206.  
  207. #ifndef FP_INCR
  208. #define FP_INCR(fp, incr) ((fp).Off += (ULONG) (incr))
  209. #endif
  210.  
  211. #endif        /* FARPTR setup */
  212.  
  213. #endif        /* PLTYPES */
  214.