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