45e9809aff7304721fddb95654901b32195c9c7avboxsync/*
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Copyright (C) 2000 The XFree86 Project, Inc. All Rights Reserved.
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Permission is hereby granted, free of charge, to any person obtaining a copy
45e9809aff7304721fddb95654901b32195c9c7avboxsync * of this software and associated documentation files (the "Software"), to
45e9809aff7304721fddb95654901b32195c9c7avboxsync * deal in the Software without restriction, including without limitation the
45e9809aff7304721fddb95654901b32195c9c7avboxsync * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
45e9809aff7304721fddb95654901b32195c9c7avboxsync * sell copies of the Software, and to permit persons to whom the Software is
45e9809aff7304721fddb95654901b32195c9c7avboxsync * furnished to do so, subject to the following conditions:
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * The above copyright notice and this permission notice shall be included in
45e9809aff7304721fddb95654901b32195c9c7avboxsync * all copies or substantial portions of the Software.
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45e9809aff7304721fddb95654901b32195c9c7avboxsync * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45e9809aff7304721fddb95654901b32195c9c7avboxsync * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45e9809aff7304721fddb95654901b32195c9c7avboxsync * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
45e9809aff7304721fddb95654901b32195c9c7avboxsync * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
45e9809aff7304721fddb95654901b32195c9c7avboxsync * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Except as contained in this notice, the name of the XFree86 Project shall
45e9809aff7304721fddb95654901b32195c9c7avboxsync * not be used in advertising or otherwise to promote the sale, use or other
45e9809aff7304721fddb95654901b32195c9c7avboxsync * dealings in this Software without prior written authorization from the
45e9809aff7304721fddb95654901b32195c9c7avboxsync * XFree86 Project.
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#ifndef _MICOORD_H_
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define _MICOORD_H_ 1
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "servermd.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/* Macros which handle a coordinate in a single register */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/*
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Most compilers will convert divisions by 65536 into shifts, if signed
45e9809aff7304721fddb95654901b32195c9c7avboxsync * shifts exist. If your machine does arithmetic shifts and your compiler
45e9809aff7304721fddb95654901b32195c9c7avboxsync * can't get it right, add to this line.
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/*
45e9809aff7304721fddb95654901b32195c9c7avboxsync * mips compiler - what a joke - it CSEs the 65536 constant into a reg
45e9809aff7304721fddb95654901b32195c9c7avboxsync * forcing as to use div instead of shift. Let's be explicit.
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#if defined(mips) || defined(sgi) || \
45e9809aff7304721fddb95654901b32195c9c7avboxsync defined(sparc) || defined(__sparc64__) || \
45e9809aff7304721fddb95654901b32195c9c7avboxsync defined(__alpha) || defined(__alpha__) || \
45e9809aff7304721fddb95654901b32195c9c7avboxsync defined(__i386__) || defined(i386) || \
45e9809aff7304721fddb95654901b32195c9c7avboxsync defined(__ia64__) || defined(ia64) || \
45e9809aff7304721fddb95654901b32195c9c7avboxsync defined(__s390x__) || defined(__s390__) || \
45e9809aff7304721fddb95654901b32195c9c7avboxsync defined(__amd64__) || defined(amd64) || defined(__amd64)
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define GetHighWord(x) (((int) (x)) >> 16)
45e9809aff7304721fddb95654901b32195c9c7avboxsync#else
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define GetHighWord(x) (((int) (x)) / 65536)
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#if IMAGE_BYTE_ORDER == MSBFirst
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define intToCoord(i,x,y) (((x) = GetHighWord(i)), ((y) = (int) ((short) (i))))
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define coordToInt(x,y) (((x) << 16) | ((y) & 0xffff))
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define intToX(i) (GetHighWord(i))
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define intToY(i) ((int) ((short) i))
45e9809aff7304721fddb95654901b32195c9c7avboxsync#else
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define intToCoord(i,x,y) (((x) = (int) ((short) (i))), ((y) = GetHighWord(i)))
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define coordToInt(x,y) (((y) << 16) | ((x) & 0xffff))
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define intToX(i) ((int) ((short) (i)))
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define intToY(i) (GetHighWord(i))
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif /* _MICOORD_H_ */