45e9809aff7304721fddb95654901b32195c9c7avboxsync/***********************************************************
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncCopyright 1987, 1998 The Open Group
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncPermission to use, copy, modify, distribute, and sell this software and its
45e9809aff7304721fddb95654901b32195c9c7avboxsyncdocumentation for any purpose is hereby granted without fee, provided that
45e9809aff7304721fddb95654901b32195c9c7avboxsyncthe above copyright notice appear in all copies and that both that
45e9809aff7304721fddb95654901b32195c9c7avboxsynccopyright notice and this permission notice appear in supporting
45e9809aff7304721fddb95654901b32195c9c7avboxsyncdocumentation.
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncThe above copyright notice and this permission notice shall be included in
45e9809aff7304721fddb95654901b32195c9c7avboxsyncall copies or substantial portions of the Software.
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45e9809aff7304721fddb95654901b32195c9c7avboxsyncIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45e9809aff7304721fddb95654901b32195c9c7avboxsyncFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45e9809aff7304721fddb95654901b32195c9c7avboxsyncOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
45e9809aff7304721fddb95654901b32195c9c7avboxsyncAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
45e9809aff7304721fddb95654901b32195c9c7avboxsyncCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncExcept as contained in this notice, the name of The Open Group shall not be
45e9809aff7304721fddb95654901b32195c9c7avboxsyncused in advertising or otherwise to promote the sale, use or other dealings
45e9809aff7304721fddb95654901b32195c9c7avboxsyncin this Software without prior written authorization from The Open Group.
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync All Rights Reserved
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncPermission to use, copy, modify, and distribute this software and its
45e9809aff7304721fddb95654901b32195c9c7avboxsyncdocumentation for any purpose and without fee is hereby granted,
45e9809aff7304721fddb95654901b32195c9c7avboxsyncprovided that the above copyright notice appear in all copies and that
45e9809aff7304721fddb95654901b32195c9c7avboxsyncboth that copyright notice and this permission notice appear in
45e9809aff7304721fddb95654901b32195c9c7avboxsyncsupporting documentation, and that the name of Digital not be
45e9809aff7304721fddb95654901b32195c9c7avboxsyncused in advertising or publicity pertaining to distribution of the
45e9809aff7304721fddb95654901b32195c9c7avboxsyncsoftware without specific, written prior permission.
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
45e9809aff7304721fddb95654901b32195c9c7avboxsyncALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
45e9809aff7304721fddb95654901b32195c9c7avboxsyncDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
45e9809aff7304721fddb95654901b32195c9c7avboxsyncANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
45e9809aff7304721fddb95654901b32195c9c7avboxsyncWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45e9809aff7304721fddb95654901b32195c9c7avboxsyncARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
45e9809aff7304721fddb95654901b32195c9c7avboxsyncSOFTWARE.
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncCopyright 1992, 1993 Data General Corporation;
45e9809aff7304721fddb95654901b32195c9c7avboxsyncCopyright 1992, 1993 OMRON Corporation
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncPermission to use, copy, modify, distribute, and sell this software and its
45e9809aff7304721fddb95654901b32195c9c7avboxsyncdocumentation for any purpose is hereby granted without fee, provided that the
45e9809aff7304721fddb95654901b32195c9c7avboxsyncabove copyright notice appear in all copies and that both that copyright
45e9809aff7304721fddb95654901b32195c9c7avboxsyncnotice and this permission notice appear in supporting documentation, and that
45e9809aff7304721fddb95654901b32195c9c7avboxsyncneither the name OMRON or DATA GENERAL be used in advertising or publicity
45e9809aff7304721fddb95654901b32195c9c7avboxsyncpertaining to distribution of the software without specific, written prior
45e9809aff7304721fddb95654901b32195c9c7avboxsyncpermission of the party whose name is to be used. Neither OMRON or
45e9809aff7304721fddb95654901b32195c9c7avboxsyncDATA GENERAL make any representation about the suitability of this software
45e9809aff7304721fddb95654901b32195c9c7avboxsyncfor any purpose. It is provided "as is" without express or implied warranty.
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncOMRON AND DATA GENERAL EACH DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
45e9809aff7304721fddb95654901b32195c9c7avboxsyncSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
45e9809aff7304721fddb95654901b32195c9c7avboxsyncIN NO EVENT SHALL OMRON OR DATA GENERAL BE LIABLE FOR ANY SPECIAL, INDIRECT
45e9809aff7304721fddb95654901b32195c9c7avboxsyncOR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
45e9809aff7304721fddb95654901b32195c9c7avboxsyncDATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
45e9809aff7304721fddb95654901b32195c9c7avboxsyncTORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
45e9809aff7304721fddb95654901b32195c9c7avboxsyncOF THIS SOFTWARE.
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync******************************************************************/
45e9809aff7304721fddb95654901b32195c9c7avboxsync#ifndef MISC_H
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MISC_H 1
45e9809aff7304721fddb95654901b32195c9c7avboxsync/*
45e9809aff7304721fddb95654901b32195c9c7avboxsync * X internal definitions
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <X11/Xosdefs.h>
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <X11/Xfuncproto.h>
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <X11/Xmd.h>
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <X11/X.h>
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <X11/Xdefs.h>
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <stddef.h>
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#ifndef MAXSCREENS
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MAXSCREENS 16
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MAXCLIENTS 256
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MAXEXTENSIONS 128
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MAXFORMATS 8
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MAXDEVICES 40 /* input devices */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define EXTENSION_EVENT_BASE 64
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define EXTENSION_BASE 128
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsynctypedef unsigned long PIXEL;
45e9809aff7304721fddb95654901b32195c9c7avboxsynctypedef unsigned long ATOM;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#ifndef TRUE
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define TRUE 1
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define FALSE 0
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#ifndef _XTYPEDEF_CALLBACKLISTPTR
45e9809aff7304721fddb95654901b32195c9c7avboxsynctypedef struct _CallbackList *CallbackListPtr; /* also in dix.h */
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define _XTYPEDEF_CALLBACKLISTPTR
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsynctypedef struct _xReq *xReqPtr;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "os.h" /* for ALLOCATE_LOCAL and DEALLOCATE_LOCAL */
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <X11/Xfuncs.h> /* for bcopy, bzero, and bcmp */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define NullBox ((BoxPtr)0)
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MILLI_PER_MIN (1000 * 60)
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MILLI_PER_SECOND (1000)
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync /* this next is used with None and ParentRelative to tell
45e9809aff7304721fddb95654901b32195c9c7avboxsync PaintWin() what to use to paint the background. Also used
45e9809aff7304721fddb95654901b32195c9c7avboxsync in the macro IS_VALID_PIXMAP */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define USE_BACKGROUND_PIXEL 3
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define USE_BORDER_PIXEL 3
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/* byte swap a 32-bit literal */
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define lswapl(x) ((((x) & 0xff) << 24) |\
45e9809aff7304721fddb95654901b32195c9c7avboxsync (((x) & 0xff00) << 8) |\
45e9809aff7304721fddb95654901b32195c9c7avboxsync (((x) & 0xff0000) >> 8) |\
45e9809aff7304721fddb95654901b32195c9c7avboxsync (((x) >> 24) & 0xff))
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/* byte swap a short literal */
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define lswaps(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#undef min
45e9809aff7304721fddb95654901b32195c9c7avboxsync#undef max
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define min(a, b) (((a) < (b)) ? (a) : (b))
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define max(a, b) (((a) > (b)) ? (a) : (b))
45e9809aff7304721fddb95654901b32195c9c7avboxsync/* abs() is a function, not a macro; include the file declaring
45e9809aff7304721fddb95654901b32195c9c7avboxsync * it in case we haven't done that yet.
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <stdlib.h>
45e9809aff7304721fddb95654901b32195c9c7avboxsync#ifndef Fabs
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define Fabs(a) ((a) > 0.0 ? (a) : -(a)) /* floating absolute value */
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define sign(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0))
45e9809aff7304721fddb95654901b32195c9c7avboxsync/* this assumes b > 0 */
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define modulus(a, b, d) if (((d) = (a) % (b)) < 0) (d) += (b)
45e9809aff7304721fddb95654901b32195c9c7avboxsync/*
45e9809aff7304721fddb95654901b32195c9c7avboxsync * return the least significant bit in x which is set
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * This works on 1's complement and 2's complement machines.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * If you care about the extra instruction on 2's complement
45e9809aff7304721fddb95654901b32195c9c7avboxsync * machines, change to ((x) & (-(x)))
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define lowbit(x) ((x) & (~(x) + 1))
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/* XXX Not for modules */
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <limits.h>
45e9809aff7304721fddb95654901b32195c9c7avboxsync#if !defined(MAXSHORT) || !defined(MINSHORT) || \
45e9809aff7304721fddb95654901b32195c9c7avboxsync !defined(MAXINT) || !defined(MININT)
45e9809aff7304721fddb95654901b32195c9c7avboxsync/*
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Some implementations #define these through <math.h>, so preclude
45e9809aff7304721fddb95654901b32195c9c7avboxsync * #include'ing it later.
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <math.h>
45e9809aff7304721fddb95654901b32195c9c7avboxsync#undef MAXSHORT
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MAXSHORT SHRT_MAX
45e9809aff7304721fddb95654901b32195c9c7avboxsync#undef MINSHORT
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MINSHORT SHRT_MIN
45e9809aff7304721fddb95654901b32195c9c7avboxsync#undef MAXINT
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MAXINT INT_MAX
45e9809aff7304721fddb95654901b32195c9c7avboxsync#undef MININT
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MININT INT_MIN
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <assert.h>
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <ctype.h>
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <stdio.h> /* for fopen, etc... */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/**
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Calculate the number of bytes needed to hold bits.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @param bits The minimum number of bits needed.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @return The number of bytes needed to hold bits.
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsyncstatic inline int
45e9809aff7304721fddb95654901b32195c9c7avboxsyncbits_to_bytes(const int bits) {
45e9809aff7304721fddb95654901b32195c9c7avboxsync return ((bits + 7) >> 3);
45e9809aff7304721fddb95654901b32195c9c7avboxsync}
45e9809aff7304721fddb95654901b32195c9c7avboxsync/**
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Calculate the number of 4-byte units needed to hold the given number of
45e9809aff7304721fddb95654901b32195c9c7avboxsync * bytes.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @param bytes The minimum number of bytes needed.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @return The number of 4-byte units needed to hold bytes.
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsyncstatic inline int
45e9809aff7304721fddb95654901b32195c9c7avboxsyncbytes_to_int32(const int bytes) {
45e9809aff7304721fddb95654901b32195c9c7avboxsync return (((bytes) + 3) >> 2);
45e9809aff7304721fddb95654901b32195c9c7avboxsync}
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/**
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Calculate the number of bytes (in multiples of 4) needed to hold bytes.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @param bytes The minimum number of bytes needed.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @return The closest multiple of 4 that is equal or higher than bytes.
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsyncstatic inline int
45e9809aff7304721fddb95654901b32195c9c7avboxsyncpad_to_int32(const int bytes) {
45e9809aff7304721fddb95654901b32195c9c7avboxsync return (((bytes) + 3) & ~3);
45e9809aff7304721fddb95654901b32195c9c7avboxsync}
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/* some macros to help swap requests, replies, and events */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define LengthRestB(stuff) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync ((client->req_len << 2) - sizeof(*stuff))
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define LengthRestS(stuff) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync ((client->req_len << 1) - (sizeof(*stuff) >> 1))
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define LengthRestL(stuff) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync (client->req_len - (sizeof(*stuff) >> 2))
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define SwapRestS(stuff) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync SwapShorts((short *)(stuff + 1), LengthRestS(stuff))
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define SwapRestL(stuff) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync SwapLongs((CARD32 *)(stuff + 1), LengthRestL(stuff))
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/* byte swap a 32-bit value */
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define swapl(x, n) { \
45e9809aff7304721fddb95654901b32195c9c7avboxsync n = ((char *) (x))[0];\
45e9809aff7304721fddb95654901b32195c9c7avboxsync ((char *) (x))[0] = ((char *) (x))[3];\
45e9809aff7304721fddb95654901b32195c9c7avboxsync ((char *) (x))[3] = n;\
45e9809aff7304721fddb95654901b32195c9c7avboxsync n = ((char *) (x))[1];\
45e9809aff7304721fddb95654901b32195c9c7avboxsync ((char *) (x))[1] = ((char *) (x))[2];\
45e9809aff7304721fddb95654901b32195c9c7avboxsync ((char *) (x))[2] = n; }
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/* byte swap a short */
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define swaps(x, n) { \
45e9809aff7304721fddb95654901b32195c9c7avboxsync n = ((char *) (x))[0];\
45e9809aff7304721fddb95654901b32195c9c7avboxsync ((char *) (x))[0] = ((char *) (x))[1];\
45e9809aff7304721fddb95654901b32195c9c7avboxsync ((char *) (x))[1] = n; }
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/* copy 32-bit value from src to dst byteswapping on the way */
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define cpswapl(src, dst) { \
45e9809aff7304721fddb95654901b32195c9c7avboxsync ((char *)&(dst))[0] = ((char *) &(src))[3];\
45e9809aff7304721fddb95654901b32195c9c7avboxsync ((char *)&(dst))[1] = ((char *) &(src))[2];\
45e9809aff7304721fddb95654901b32195c9c7avboxsync ((char *)&(dst))[2] = ((char *) &(src))[1];\
45e9809aff7304721fddb95654901b32195c9c7avboxsync ((char *)&(dst))[3] = ((char *) &(src))[0]; }
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/* copy short from src to dst byteswapping on the way */
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define cpswaps(src, dst) { \
45e9809aff7304721fddb95654901b32195c9c7avboxsync ((char *) &(dst))[0] = ((char *) &(src))[1];\
45e9809aff7304721fddb95654901b32195c9c7avboxsync ((char *) &(dst))[1] = ((char *) &(src))[0]; }
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern _X_EXPORT void SwapLongs(
45e9809aff7304721fddb95654901b32195c9c7avboxsync CARD32 *list,
45e9809aff7304721fddb95654901b32195c9c7avboxsync unsigned long count);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern _X_EXPORT void SwapShorts(
45e9809aff7304721fddb95654901b32195c9c7avboxsync short *list,
45e9809aff7304721fddb95654901b32195c9c7avboxsync unsigned long count);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern _X_EXPORT void MakePredeclaredAtoms(void);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern _X_EXPORT int Ones(
45e9809aff7304721fddb95654901b32195c9c7avboxsync unsigned long /*mask*/);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsynctypedef struct _xPoint *DDXPointPtr;
45e9809aff7304721fddb95654901b32195c9c7avboxsynctypedef struct pixman_box16 *BoxPtr;
45e9809aff7304721fddb95654901b32195c9c7avboxsynctypedef struct _xEvent *xEventPtr;
45e9809aff7304721fddb95654901b32195c9c7avboxsynctypedef struct _xRectangle *xRectanglePtr;
45e9809aff7304721fddb95654901b32195c9c7avboxsynctypedef struct _GrabRec *GrabPtr;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/* typedefs from other places - duplicated here to minimize the amount
45e9809aff7304721fddb95654901b32195c9c7avboxsync * of unnecessary junk that one would normally have to include to get
45e9809aff7304721fddb95654901b32195c9c7avboxsync * these symbols defined
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#ifndef _XTYPEDEF_CHARINFOPTR
45e9809aff7304721fddb95654901b32195c9c7avboxsynctypedef struct _CharInfo *CharInfoPtr; /* also in fonts/include/font.h */
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define _XTYPEDEF_CHARINFOPTR
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern _X_EXPORT unsigned long globalSerialNumber;
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern _X_EXPORT unsigned long serverGeneration;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif /* MISC_H */