home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c220 / 7.ddi / INCLUDES / PLTYPES.H < prev   
Encoding:
C/C++ Source or Header  |  1990-04-19  |  4.6 KB  |  130 lines

  1. /* PLTYPES.H - Definitions for Phar Lap standard data types         */
  2. /* $Id: pltypes.h 1.3 90/04/19 14:32:56 rms Exp $ */
  3. /************************************************************************/
  4. /*    Copyright (C) 1986-1988 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.  
  15. /*
  16.     In order to be able to use this file with the EFI Libraries,
  17.     I had to check the symbol below to make sure that these
  18.     basic data types are not multiply-defined.  This symbol is
  19.     set whenever the OS2 file "os2.h" is included (therefore,
  20.     if the file "os2.h" will be used, it must be included
  21.     BEFORE this file).
  22. */
  23.  
  24.  
  25. #ifndef STDPL
  26.  
  27. #ifndef OS2_INCLUDED
  28.  
  29. /*
  30. /*
  31.  * Data types.  SHORT and LONG data types are guaranteed to be set up
  32.  * as 16 and 32 bit data types, respectively, for all systems.
  33.  */
  34.  
  35. typedef unsigned char UCHAR;    /* unsigned 8-bit value */
  36. typedef short SHORT;        /* signed 16-bit value */
  37. typedef unsigned short USHORT;    /* unsigned 16-bit value */
  38. typedef unsigned int UINT;    /* unsigned integer */
  39. typedef long LONG;        /* signed 32-bit value */
  40. typedef unsigned long ULONG;    /* unsigned 32-bit value */
  41. /* TBC - BOOL is a conflicting data type between OS2 and DOSX */
  42. typedef int BOOL;        /* Boolean value */
  43.  
  44.  
  45. /*
  46.  * Special values
  47.  */
  48. #define TRUE    1        /* Boolean true */
  49. #define FALSE    0        /* Boolean false */
  50.  
  51. #endif /* OS2_INCLUDED */
  52.  
  53. typedef void *PTR;        /* generic pointer */
  54. #define EOS  '\0'        /* end-of-string character */
  55.  
  56. #endif /* STDPL */
  57.  
  58.  
  59. /*
  60.  
  61. Real mode pointer data type (segment:offset16)
  62.  
  63. The REALPTR data type is used in protected mode to hold
  64. real mode pointers.  The data type is an unsigned long value.
  65. The upper 16 bits of the long are a segment number and the lower
  66. 16 bits of the long are an offset.  The format of REALPTR is
  67. identical to a standard pointer as used in real mode.  The 
  68. REALPTR data type is used when mixing real and protected mode
  69. code in the same program.  A REALPTR cannot be dereferenced
  70. in protected mode since the format of pointers in real and
  71. protected mode are different.
  72.  
  73. As well as the data definition for the REALPTR type, the following
  74. macros are available to set and extract the segment and
  75. offset fields of a REALPR.  The RP_OFF macro returns the offset
  76. portion of a REALPTR.  The RP_SEG macro returns the segment portion
  77. of a REALPTR.  The macro RP_SET is used to combine a segment and an
  78. offset into a REALPTR.  It takes three arguments: the name of the 
  79. REALPTR to be set, an offset, and a segment number.
  80.  
  81. */
  82.  
  83. typedef ULONG REALPTR;
  84.  
  85. #define RP_OFF(rp) ((USHORT)(((ULONG)(rp)) & 0xFFFF))
  86. #define RP_SEG(rp) ((USHORT)(((ULONG)(rp)) >> 16))
  87. #define RP_SET(rp, off, seg) (rp = ((ULONG)(seg) << 16) + (off))
  88.  
  89.  
  90. /*
  91.  
  92. Far pointer data type (selector:offset32)
  93.  
  94. The MetaWare 80386 High C compiler supports far pointers as well as
  95. 32-bit near pointers.  A far pointer consists of a 32-bit offset followed
  96. by 16-bit selector number.  Far pointers are used to reference memory
  97. locations in segments outside of the data segment.  In the MetaWare
  98. High C compiler a far pointer is declared using a definition of the
  99. following form:
  100.  
  101.     char _far *ptr;
  102.  
  103. The "_far" keyword is used to indicate a pointer is a far pointer as 
  104. opposed to a near pointer.  Note: For compatibility with existing C 
  105. source code which is compiled with the 8086 Microsoft C compiler
  106. C code, Microsoft C "far" keyword can still used by putting the
  107. following #define in a header file:
  108.  
  109.     #define far _far
  110.  
  111. The following macros are used to get and set the selector and offset fields
  112. of far pointers.  The FP_SEL macro returns the 16-bit selector number field
  113. of a far pointer.  The FP_OFF macro returns the 32-bit offset
  114. field of a far pointer.  The FP_SET macro is used to construct a far
  115. pointer from a selector number and offset.  It takes three arguments:
  116. the name of the far pointer to be set, an offset, and a selector number.
  117.  
  118. */
  119.  
  120. typedef UCHAR _far *FARPTR;
  121.  
  122. #define FP_SEL(fp) ((USHORT)(*(((USHORT *)&(fp))+sizeof(UINT)/sizeof(USHORT))))
  123. #define FP_OFF(fp) ((UINT)(*(UCHAR **)&(fp)))
  124.  
  125. #define FP_SET(fp, off, sel) ((*(UINT *)&fp=(UINT)(off)),\
  126. (*(((USHORT *)&fp) + sizeof(UINT)/sizeof(USHORT))=sel))
  127.  
  128. #define PLTYPES
  129. #endif
  130.