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