home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / g / gs241j11.zip / INCLUDE.SNF / XMD.H < prev    next >
C/C++ Source or Header  |  1992-04-07  |  4KB  |  140 lines

  1. /***********************************************************
  2. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  3. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  4.  
  5.                         All Rights Reserved
  6.  
  7. Permission to use, copy, modify, and distribute this software and its 
  8. documentation for any purpose and without fee is hereby granted, 
  9. provided that the above copyright notice appear in all copies and that
  10. both that copyright notice and this permission notice appear in 
  11. supporting documentation, and that the names of Digital or MIT not be
  12. used in advertising or publicity pertaining to distribution of the
  13. software without specific, written prior permission.  
  14.  
  15. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  16. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  17. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  18. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  19. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  20. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21. SOFTWARE.
  22.  
  23. ******************************************************************/
  24. #ifndef XMD_H
  25. #define XMD_H 1
  26. /* $XConsortium: Xmd.h,v 1.35 89/08/15 14:38:57 jim Exp $ */
  27. /*
  28.  *  Xmd.h: MACHINE DEPENDENT DECLARATIONS.
  29.  */
  30.  
  31. /*
  32.  * Special per-machine configuration flags.
  33.  */
  34. #ifdef CRAY
  35. #define WORD64                /* 64-bit architecture */
  36. #define UNSIGNEDBITFIELDS        /* bit fields do not honor sign */
  37. #endif
  38.  
  39.  
  40. /*
  41.  * Stuff to handle large architecture machines; the constants were generated
  42.  * on a 32-bit machine and must coorespond to the protocol.
  43.  */
  44. #ifdef WORD64
  45. #define MUSTCOPY
  46. #endif /* WORD64 */
  47.  
  48.  
  49. /*
  50.  * Definition of macro used to set constants for size of network structures;
  51.  * machines with preprocessors that can't handle all of the sz_ symbols
  52.  * can define this macro to be sizeof(x) if and only if their compiler doesn't
  53.  * pad out structures (esp. the xTextElt structure which contains only two 
  54.  * one-byte fields).  Network structures should always define sz_symbols.
  55.  *
  56.  * The sz_ prefix is used instead of something more descriptive so that the
  57.  * symbols are no more than 32 characters long (which causes problems for some
  58.  * compilers and preprocessors).
  59.  */
  60. #if defined(__STDC__) && !defined(UNIXCPP)
  61. #define SIZEOF(x) sz_##x
  62. #else
  63. #define SIZEOF(x) sz_/**/x
  64. #endif /* if ANSI C compiler else not */
  65.  
  66.  
  67.  
  68. /*
  69.  * ibm pcc doesn't understand pragmas.
  70.  */
  71. #if defined(ibm032) && defined(__HIGHC__)
  72. pragma on(pointers_compatible);
  73. pragma off(char_default_unsigned);
  74. #endif
  75.  
  76.  
  77. /*
  78.  * Bitfield suffixes for the protocol structure elements, if you
  79.  * need them.  Note that bitfields are not guarranteed to be signed
  80.  * (or even unsigned) according to ANSI C.
  81.  */
  82. #ifdef WORD64
  83. #define B32 :32
  84. #define B16 :16
  85. #else
  86. #define B32
  87. #define B16
  88. #endif
  89.  
  90. typedef long           INT32;
  91. typedef short          INT16;
  92. typedef char           INT8;
  93.  
  94. typedef unsigned long CARD32;
  95. typedef unsigned short CARD16;
  96. typedef unsigned char  CARD8;
  97.  
  98. typedef unsigned long        BITS32;
  99. typedef unsigned short        BITS16;
  100. typedef unsigned char        BYTE;
  101.  
  102. typedef unsigned char            BOOL;
  103.  
  104.  
  105. /*
  106.  * definitions for sign-extending bitfields on 64-bit architectures
  107.  */
  108. #if defined(WORD64) && defined(UNSIGNEDBITFIELDS)
  109. #define cvtINT8toInt(val)   (((val) & 0x00000080) ? ((val) | 0xffffffffffffff00) : (val))
  110. #define cvtINT16toInt(val)  (((val) & 0x00008000) ? ((val) | 0xffffffffffff0000) : (val))
  111. #define cvtINT32toInt(val)  (((val) & 0x80000000) ? ((val) | 0xffffffff00000000) : (val))
  112. #define cvtINT8toLong(val)  cvtINT8toInt(val)
  113. #define cvtINT16toLong(val) cvtINT16toInt(val)
  114. #define cvtINT32toLong(val) cvtINT32toInt(val)
  115. #else
  116. #define cvtINT8toInt(val) (val)
  117. #define cvtINT16toInt(val) (val)
  118. #define cvtINT32toInt(val) (val)
  119. #define cvtINT8toLong(val) (val)
  120. #define cvtINT16toLong(val) (val)
  121. #define cvtINT32toLong(val) (val)
  122. #endif /* WORD64 and UNSIGNEDBITFIELDS */
  123.  
  124.  
  125.  
  126. #ifdef MUSTCOPY
  127. /*
  128.  * This macro must not cast or else pointers will get aligned and be wrong
  129.  */
  130. #define NEXTPTR(p,t)  (((char *) p) + SIZEOF(t))
  131. #else /* else not MUSTCOPY, this is used for 32-bit machines */
  132. /*
  133.  * this version should leave result of type (t *), but that should only be 
  134.  * used when not in MUSTCOPY
  135.  */  
  136. #define NEXTPTR(p,t) (((t *)(p)) + 1)
  137. #endif /* MUSTCOPY - used machines whose C structs don't line up with proto */
  138.  
  139. #endif /* XMD_H */
  140.