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