b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/* $XFree86: xc/programs/Xserver/include/misc.h,v 3.28 2001/12/14 19:59:55 dawes Exp $ */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/***********************************************************
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncCopyright 1987, 1998 The Open Group
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncPermission to use, copy, modify, distribute, and sell this software and its
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncdocumentation for any purpose is hereby granted without fee, provided that
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncthe above copyright notice appear in all copies and that both that
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsynccopyright notice and this permission notice appear in supporting
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncdocumentation.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncThe above copyright notice and this permission notice shall be included in
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncall copies or substantial portions of the Software.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncExcept as contained in this notice, the name of The Open Group shall not be
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncused in advertising or otherwise to promote the sale, use or other dealings
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncin this Software without prior written authorization from The Open Group.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync All Rights Reserved
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncPermission to use, copy, modify, and distribute this software and its
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncdocumentation for any purpose and without fee is hereby granted,
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncprovided that the above copyright notice appear in all copies and that
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncboth that copyright notice and this permission notice appear in
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncsupporting documentation, and that the name of Digital not be
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncused in advertising or publicity pertaining to distribution of the
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncsoftware without specific, written prior permission.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncCopyright 1992, 1993 Data General Corporation;
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncCopyright 1992, 1993 OMRON Corporation
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncPermission to use, copy, modify, distribute, and sell this software and its
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncdocumentation for any purpose is hereby granted without fee, provided that the
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncabove copyright notice appear in all copies and that both that copyright
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncnotice and this permission notice appear in supporting documentation, and that
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncneither the name OMRON or DATA GENERAL be used in advertising or publicity
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncpertaining to distribution of the software without specific, written prior
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncpermission of the party whose name is to be used. Neither OMRON or
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncDATA GENERAL make any representation about the suitability of this software
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncfor any purpose. It is provided "as is" without express or implied warranty.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncOMRON AND DATA GENERAL EACH DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncIN NO EVENT SHALL OMRON OR DATA GENERAL BE LIABLE FOR ANY SPECIAL, INDIRECT
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncOR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncDATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncTORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncOF THIS SOFTWARE.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync******************************************************************/
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/* $Xorg: misc.h,v 1.5 2001/02/09 02:05:15 xorgcvs Exp $ */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * X internal definitions
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncextern unsigned long globalSerialNumber;
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncextern unsigned long serverGeneration;
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsynctypedef struct _CallbackList *CallbackListPtr; /* also in dix.h */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#include "os.h" /* for ALLOCATE_LOCAL and DEALLOCATE_LOCAL */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#include <X11/Xfuncs.h> /* for bcopy, bzero, and bcmp */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync /* this next is used with None and ParentRelative to tell
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync PaintWin() what to use to paint the background. Also used
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync in the macro IS_VALID_PIXMAP */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/* byte swap a 32-bit literal */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/* byte swap a short literal */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#define lswaps(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/* abs() is a function, not a macro; include the file declaring
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * it in case we haven't done that yet.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#endif /* IN_MODULE */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#define Fabs(a) ((a) > 0.0 ? (a) : -(a)) /* floating absolute value */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/* this assumes b > 0 */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#define modulus(a, b, d) if (((d) = (a) % (b)) < 0) (d) += (b)
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * return the least significant bit in x which is set
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * This works on 1's complement and 2's complement machines.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * If you care about the extra instruction on 2's complement
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * machines, change to ((x) & (-(x)))
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/* XXX Not for modules */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * Some implementations #define these through <math.h>, so preclude
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * #include'ing it later.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/* some macros to help swap requests, replies, and events */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync SwapShorts((short *)(stuff + 1), LengthRestS(stuff))
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync SwapLongs((CARD32 *)(stuff + 1), LengthRestL(stuff))
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/* byte swap a 32-bit value */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync n = ((char *) (x))[0];\
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync ((char *) (x))[0] = ((char *) (x))[3];\
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync ((char *) (x))[3] = n;\
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync n = ((char *) (x))[1];\
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync ((char *) (x))[2] = n; }
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/* byte swap a short */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync n = ((char *) (x))[0];\
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync ((char *) (x))[0] = ((char *) (x))[1];\
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync ((char *) (x))[1] = n; }
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/* copy 32-bit value from src to dst byteswapping on the way */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/* copy short from src to dst byteswapping on the way */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync unsigned long count);
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync unsigned long count);
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncextern void MakePredeclaredAtoms(void);
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync unsigned long /*mask*/);
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/* typedefs from other places - duplicated here to minimize the amount
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * of unnecessary junk that one would normally have to include to get
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * these symbols defined
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsynctypedef struct _CharInfo *CharInfoPtr; /* also in fonts/include/font.h */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#endif /* MISC_H */