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