1 /***********************************************************
3 Copyright (c) 1987 X Consortium
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
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 X CONSORTIUM 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.
22 Except as contained in this notice, the name of the X Consortium 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 X Consortium.
27 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
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.
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
47 Copyright 1992, 1993 Data General Corporation;
48 Copyright 1992, 1993 OMRON Corporation
50 Permission to use, copy, modify, distribute, and sell this software and its
51 documentation for any purpose is hereby granted without fee, provided that the
52 above copyright notice appear in all copies and that both that copyright
53 notice and this permission notice appear in supporting documentation, and that
54 neither the name OMRON or DATA GENERAL be used in advertising or publicity
55 pertaining to distribution of the software without specific, written prior
56 permission of the party whose name is to be used. Neither OMRON or
57 DATA GENERAL make any representation about the suitability of this software
58 for any purpose. It is provided "as is" without express or implied warranty.
60 OMRON AND DATA GENERAL EACH DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
61 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
62 IN NO EVENT SHALL OMRON OR DATA GENERAL BE LIABLE FOR ANY SPECIAL, INDIRECT
63 OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
64 DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
65 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
68 ******************************************************************/
69 /* $XConsortium: misc.h /main/28 1996/12/02 10:22:01 lehors $ */
70 /* $XFree86: xc/programs/Xserver/include/misc.h,v 3.5 1996/12/23 07:09:29 dawes Exp $ */
74 * X internal definitions
78 extern unsigned long globalSerialNumber;
79 extern unsigned long serverGeneration;
81 #include <X11/Xosdefs.h>
82 #include <X11/Xfuncproto.h>
87 #ifndef X_NOT_STDC_ENV
97 #define MAXCLIENTS 128
99 #define MAXEXTENSIONS 128
101 #define MAXVISUALS_PER_SCREEN 50
103 #if NeedFunctionPrototypes
104 typedef void *pointer;
106 typedef unsigned char *pointer;
109 typedef unsigned long PIXEL;
110 typedef unsigned long ATOM;
118 #ifndef _XTYPEDEF_FONTPTR
119 typedef struct _Font *FontPtr; /* also in fonts/include/font.h */
120 #define _XTYPEDEF_FONTPTR
123 #ifndef _XTYPEDEF_CLIENTPTR
124 typedef struct _Client *ClientPtr; /* also in dix.h */
125 #define _XTYPEDEF_CLIENTPTR
128 #ifndef _XTYPEDEF_CALLBACKLISTPTR
129 typedef struct _CallbackList *CallbackListPtr; /* also in dix.h */
130 #define _XTYPEDEF_CALLBACKLISTPTR
133 typedef struct _xReq *xReqPtr;
135 #include "os.h" /* for ALLOCATE_LOCAL and DEALLOCATE_LOCAL */
136 #include <X11/Xfuncs.h> /* for bcopy, bzero, and bcmp */
138 #define NullBox ((BoxPtr)0)
139 #define MILLI_PER_MIN (1000 * 60)
140 #define MILLI_PER_SECOND (1000)
142 /* this next is used with None and ParentRelative to tell
143 PaintWin() what to use to paint the background. Also used
144 in the macro IS_VALID_PIXMAP */
146 #define USE_BACKGROUND_PIXEL 3
147 #define USE_BORDER_PIXEL 3
150 /* byte swap a 32-bit literal */
151 #define lswapl(x) ((((x) & 0xff) << 24) |\
152 (((x) & 0xff00) << 8) |\
153 (((x) & 0xff0000) >> 8) |\
154 (((x) >> 24) & 0xff))
156 /* byte swap a short literal */
157 #define lswaps(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
159 #define min(a, b) (((a) < (b)) ? (a) : (b))
160 #define max(a, b) (((a) > (b)) ? (a) : (b))
161 #if !defined(AMOEBA) && !defined(__EMX__)
163 #define abs(a) ((a) > 0 ? (a) : -(a))
165 #else /* AMOEBA || __EMX__ */
166 /* abs() is a function, not a macro; include the file declaring
167 * it in case we haven't done that yet.
172 #define Fabs(a) ((a) > 0.0 ? (a) : -(a)) /* floating absolute value */
174 #define sign(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0))
175 /* this assumes b > 0 */
176 #define modulus(a, b, d) if (((d) = (a) % (b)) < 0) (d) += (b)
178 * return the least significant bit in x which is set
180 * This works on 1's complement and 2's complement machines.
181 * If you care about the extra instruction on 2's complement
182 * machines, change to ((x) & (-(x)))
184 #define lowbit(x) ((x) & (~(x) + 1))
187 #define MAXSHORT 32767
190 #define MINSHORT -MAXSHORT
194 /* some macros to help swap requests, replies, and events */
196 #define LengthRestB(stuff) \
197 ((client->req_len << 2) - sizeof(*stuff))
199 #define LengthRestS(stuff) \
200 ((client->req_len << 1) - (sizeof(*stuff) >> 1))
202 #define LengthRestL(stuff) \
203 (client->req_len - (sizeof(*stuff) >> 2))
205 #define SwapRestS(stuff) \
206 SwapShorts((short *)(stuff + 1), LengthRestS(stuff))
208 #define SwapRestL(stuff) \
209 SwapLongs((CARD32 *)(stuff + 1), LengthRestL(stuff))
211 /* byte swap a 32-bit value */
212 #define swapl(x, n) { \
213 n = ((char *) (x))[0];\
214 ((char *) (x))[0] = ((char *) (x))[3];\
215 ((char *) (x))[3] = n;\
216 n = ((char *) (x))[1];\
217 ((char *) (x))[1] = ((char *) (x))[2];\
218 ((char *) (x))[2] = n; }
220 /* byte swap a short */
221 #define swaps(x, n) { \
222 n = ((char *) (x))[0];\
223 ((char *) (x))[0] = ((char *) (x))[1];\
224 ((char *) (x))[1] = n; }
226 /* copy 32-bit value from src to dst byteswapping on the way */
227 #define cpswapl(src, dst) { \
228 ((char *)&(dst))[0] = ((char *) &(src))[3];\
229 ((char *)&(dst))[1] = ((char *) &(src))[2];\
230 ((char *)&(dst))[2] = ((char *) &(src))[1];\
231 ((char *)&(dst))[3] = ((char *) &(src))[0]; }
233 /* copy short from src to dst byteswapping on the way */
234 #define cpswaps(src, dst) { \
235 ((char *) &(dst))[0] = ((char *) &(src))[1];\
236 ((char *) &(dst))[1] = ((char *) &(src))[0]; }
238 extern void SwapLongs(
239 #if NeedFunctionPrototypes
245 extern void SwapShorts(
246 #if NeedFunctionPrototypes
252 extern void MakePredeclaredAtoms(
253 #if NeedFunctionPrototypes
259 #if NeedFunctionPrototypes
260 unsigned long /*mask*/
264 typedef struct _xPoint *DDXPointPtr;
265 typedef struct _Box *BoxPtr;
266 typedef struct _xEvent *xEventPtr;
267 typedef struct _xRectangle *xRectanglePtr;
268 typedef struct _GrabRec *GrabPtr;
270 /* typedefs from other places - duplicated here to minimize the amount
271 * of unnecessary junk that one would normally have to include to get
272 * these symbols defined
275 #ifndef _XTYPEDEF_CHARINFOPTR
276 typedef struct _CharInfo *CharInfoPtr; /* also in fonts/include/font.h */
277 #define _XTYPEDEF_CHARINFOPTR