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.41 91/05/10 10:00:03 jap 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 * The extra indirection in the __STDC__ case is to get macro arguments to 61 * expand correctly before the concatenation, rather than afterward. 62 */ 63 #if __STDC__ && !defined(UNIXCPP) 64 #define _SIZEOF(x) sz_##x 65 #define SIZEOF(x) _SIZEOF(x) 66 #else 67 #define SIZEOF(x) sz_/**/x 68 #endif /* if ANSI C compiler else not */ 69 70 /* 71 * Bitfield suffixes for the protocol structure elements, if you 72 * need them. Note that bitfields are not guarranteed to be signed 73 * (or even unsigned) according to ANSI C. 74 */ 75 #ifdef WORD64 76 #define B32 :32 77 #define B16 :16 78 #else 79 #define B32 80 #define B16 81 #endif 82 83 typedef long INT32; 84 typedef short INT16; 85 #if __STDC__ || defined(sgi) || defined(AIXV3) 86 typedef signed char INT8; 87 #else 88 typedef char INT8; 89 #endif 90 91 typedef unsigned long CARD32; 92 typedef unsigned short CARD16; 93 typedef unsigned char CARD8; 94 95 typedef unsigned long BITS32; 96 typedef unsigned short BITS16; 97 typedef unsigned char BYTE; 98 99 typedef unsigned char BOOL; 100 101 102 /* 103 * definitions for sign-extending bitfields on 64-bit architectures 104 */ 105 #if defined(WORD64) && defined(UNSIGNEDBITFIELDS) 106 #define cvtINT8toInt(val) (((val) & 0x00000080) ? ((val) | 0xffffffffffffff00) : (val)) 107 #define cvtINT16toInt(val) (((val) & 0x00008000) ? ((val) | 0xffffffffffff0000) : (val)) 108 #define cvtINT32toInt(val) (((val) & 0x80000000) ? ((val) | 0xffffffff00000000) : (val)) 109 #define cvtINT8toShort(val) cvtINT8toInt(val) 110 #define cvtINT16toShort(val) cvtINT16toInt(val) 111 #define cvtINT32toShort(val) cvtINT32toInt(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 cvtINT8toShort(val) (val) 120 #define cvtINT16toShort(val) (val) 121 #define cvtINT32toShort(val) (val) 122 #define cvtINT8toLong(val) (val) 123 #define cvtINT16toLong(val) (val) 124 #define cvtINT32toLong(val) (val) 125 #endif /* WORD64 and UNSIGNEDBITFIELDS */ 126 127 128 129 #ifdef MUSTCOPY 130 /* 131 * This macro must not cast or else pointers will get aligned and be wrong 132 */ 133 #define NEXTPTR(p,t) (((char *) p) + SIZEOF(t)) 134 #else /* else not MUSTCOPY, this is used for 32-bit machines */ 135 /* 136 * this version should leave result of type (t *), but that should only be 137 * used when not in MUSTCOPY 138 */ 139 #define NEXTPTR(p,t) (((t *)(p)) + 1) 140 #endif /* MUSTCOPY - used machines whose C structs don't line up with proto */ 141 142 #endif /* XMD_H */ 143