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