Home | History | Annotate | Download | only in X11
      1 /* $XdotOrg: $ */
      2 /* $XFree86: xc/include/Xmd.h,v 3.18tsi Exp $ */
      3 /***********************************************************
      4 
      5 Copyright 1987, 1998  The Open Group
      6 
      7 Permission to use, copy, modify, distribute, and sell this software and its
      8 documentation for any purpose is hereby granted without fee, provided that
      9 the above copyright notice appear in all copies and that both that
     10 copyright notice and this permission notice appear in supporting
     11 documentation.
     12 
     13 The above copyright notice and this permission notice shall be included in
     14 all copies or substantial portions of the Software.
     15 
     16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
     19 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
     20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
     21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     22 
     23 Except as contained in this notice, the name of The Open Group shall not be
     24 used in advertising or otherwise to promote the sale, use or other dealings
     25 in this Software without prior written authorization from The Open Group.
     26 
     27 
     28 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
     29 
     30                         All Rights Reserved
     31 
     32 Permission to use, copy, modify, and distribute this software and its
     33 documentation for any purpose and without fee is hereby granted,
     34 provided that the above copyright notice appear in all copies and that
     35 both that copyright notice and this permission notice appear in
     36 supporting documentation, and that the name of Digital not be
     37 used in advertising or publicity pertaining to distribution of the
     38 software without specific, written prior permission.
     39 
     40 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
     41 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
     42 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
     43 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
     44 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
     45 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
     46 SOFTWARE.
     47 
     48 ******************************************************************/
     49 #ifndef XMD_H
     50 #define XMD_H 1
     51 /* $Xorg: Xmd.h,v 1.4 2001/02/09 02:03:22 xorgcvs Exp $ */
     52 /*
     53  *  Xmd.h: MACHINE DEPENDENT DECLARATIONS.
     54  */
     55 
     56 /*
     57  * Special per-machine configuration flags.
     58  */
     59 #if defined(sun) && defined(__SVR4)
     60 # include <sys/isa_defs.h> /* Solaris: defines _LP64 if necessary */
     61 #endif
     62 
     63 #ifdef CRAY
     64 #define WORD64				/* 64-bit architecture */
     65 #endif
     66 #if defined (_LP64) || \
     67     defined(__alpha) || defined(__alpha__) || \
     68     defined(__ia64__) || defined(ia64) || \
     69     defined(__sparc64__) || \
     70     defined(__s390x__) || \
     71     (defined(__hppa__) && defined(__LP64__)) || \
     72     defined(__amd64__) || defined(amd64) || \
     73     defined(__powerpc64__) || \
     74     (defined(sgi) && (_MIPS_SZLONG == 64))
     75 #define LONG64				/* 32/64-bit architecture */
     76 #endif
     77 
     78 /*
     79  * Stuff to handle large architecture machines; the constants were generated
     80  * on a 32-bit machine and must correspond to the protocol.
     81  */
     82 #ifdef WORD64
     83 #define MUSTCOPY
     84 #endif /* WORD64 */
     85 
     86 
     87 /*
     88  * Definition of macro used to set constants for size of network structures;
     89  * machines with preprocessors that can't handle all of the sz_ symbols
     90  * can define this macro to be sizeof(x) if and only if their compiler doesn't
     91  * pad out structures (esp. the xTextElt structure which contains only two
     92  * one-byte fields).  Network structures should always define sz_symbols.
     93  *
     94  * The sz_ prefix is used instead of something more descriptive so that the
     95  * symbols are no more than 32 characters long (which causes problems for some
     96  * compilers and preprocessors).
     97  *
     98  * The extra indirection in the __STDC__ case is to get macro arguments to
     99  * expand correctly before the concatenation, rather than afterward.
    100  */
    101 #if ((defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)) && !defined(UNIXCPP)) || defined(ANSICPP)
    102 #define _SIZEOF(x) sz_##x
    103 #define SIZEOF(x) _SIZEOF(x)
    104 #else
    105 #define SIZEOF(x) sz_/**/x
    106 #endif /* if ANSI C compiler else not */
    107 
    108 /*
    109  * Bitfield suffixes for the protocol structure elements, if you
    110  * need them.  Note that bitfields are not guaranteed to be signed
    111  * (or even unsigned) according to ANSI C.
    112  */
    113 #ifdef WORD64
    114 typedef long INT64;
    115 typedef unsigned long CARD64;
    116 #define B32 :32
    117 #define B16 :16
    118 #ifdef UNSIGNEDBITFIELDS
    119 typedef unsigned int INT32;
    120 typedef unsigned int INT16;
    121 #else
    122 #ifdef __STDC__
    123 typedef signed int INT32;
    124 typedef signed int INT16;
    125 #else
    126 typedef int INT32;
    127 typedef int INT16;
    128 #endif
    129 #endif
    130 #else
    131 #define B32
    132 #define B16
    133 #ifdef LONG64
    134 typedef long INT64;
    135 typedef int INT32;
    136 #else
    137 typedef long INT32;
    138 #endif
    139 typedef short INT16;
    140 #endif
    141 
    142 #if defined(__STDC__) || defined(sgi) || defined(_AIX)
    143 typedef signed char    INT8;
    144 #else
    145 typedef char           INT8;
    146 #endif
    147 
    148 #ifdef LONG64
    149 typedef unsigned long CARD64;
    150 typedef unsigned int CARD32;
    151 #else
    152 typedef unsigned long CARD32;
    153 #endif
    154 #if !defined(WORD64) && !defined(LONG64)
    155 typedef unsigned long long CARD64;
    156 #endif
    157 typedef unsigned short CARD16;
    158 typedef unsigned char  CARD8;
    159 
    160 typedef CARD32		BITS32;
    161 typedef CARD16		BITS16;
    162 
    163 #ifndef I_NEED_OS2_H
    164 typedef CARD8		BYTE;
    165 typedef CARD8		BOOL;
    166 #else
    167 #define BYTE	CARD8
    168 #define BOOL	CARD8
    169 #endif
    170 
    171 /*
    172  * definitions for sign-extending bitfields on 64-bit architectures
    173  */
    174 #if defined(WORD64) && defined(UNSIGNEDBITFIELDS)
    175 #define cvtINT8toInt(val)   (((val) & 0x00000080) ? ((val) | 0xffffffffffffff00) : (val))
    176 #define cvtINT16toInt(val)  (((val) & 0x00008000) ? ((val) | 0xffffffffffff0000) : (val))
    177 #define cvtINT32toInt(val)  (((val) & 0x80000000) ? ((val) | 0xffffffff00000000) : (val))
    178 #define cvtINT8toShort(val)  cvtINT8toInt(val)
    179 #define cvtINT16toShort(val) cvtINT16toInt(val)
    180 #define cvtINT32toShort(val) cvtINT32toInt(val)
    181 #define cvtINT8toLong(val)  cvtINT8toInt(val)
    182 #define cvtINT16toLong(val) cvtINT16toInt(val)
    183 #define cvtINT32toLong(val) cvtINT32toInt(val)
    184 #else
    185 #define cvtINT8toInt(val) (val)
    186 #define cvtINT16toInt(val) (val)
    187 #define cvtINT32toInt(val) (val)
    188 #define cvtINT8toShort(val) (val)
    189 #define cvtINT16toShort(val) (val)
    190 #define cvtINT32toShort(val) (val)
    191 #define cvtINT8toLong(val) (val)
    192 #define cvtINT16toLong(val) (val)
    193 #define cvtINT32toLong(val) (val)
    194 #endif /* WORD64 and UNSIGNEDBITFIELDS */
    195 
    196 
    197 
    198 #ifdef MUSTCOPY
    199 /*
    200  * This macro must not cast or else pointers will get aligned and be wrong
    201  */
    202 #define NEXTPTR(p,t)  (((char *) p) + SIZEOF(t))
    203 #else /* else not MUSTCOPY, this is used for 32-bit machines */
    204 /*
    205  * this version should leave result of type (t *), but that should only be
    206  * used when not in MUSTCOPY
    207  */
    208 #define NEXTPTR(p,t) (((t *)(p)) + 1)
    209 #endif /* MUSTCOPY - used machines whose C structs don't line up with proto */
    210 
    211 #endif /* XMD_H */
    212