45e9809aff7304721fddb95654901b32195c9c7avboxsync/*
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncCopyright 1989, 1998 The Open Group
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncPermission to use, copy, modify, distribute, and sell this software and its
45e9809aff7304721fddb95654901b32195c9c7avboxsyncdocumentation for any purpose is hereby granted without fee, provided that
45e9809aff7304721fddb95654901b32195c9c7avboxsyncthe above copyright notice appear in all copies and that both that
45e9809aff7304721fddb95654901b32195c9c7avboxsynccopyright notice and this permission notice appear in supporting
45e9809aff7304721fddb95654901b32195c9c7avboxsyncdocumentation.
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncThe above copyright notice and this permission notice shall be included
45e9809aff7304721fddb95654901b32195c9c7avboxsyncin all copies or substantial portions of the Software.
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
45e9809aff7304721fddb95654901b32195c9c7avboxsyncOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
45e9809aff7304721fddb95654901b32195c9c7avboxsyncMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45e9809aff7304721fddb95654901b32195c9c7avboxsyncIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
45e9809aff7304721fddb95654901b32195c9c7avboxsyncOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
45e9809aff7304721fddb95654901b32195c9c7avboxsyncARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
45e9809aff7304721fddb95654901b32195c9c7avboxsyncOTHER DEALINGS IN THE SOFTWARE.
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncExcept as contained in this notice, the name of The Open Group shall
45e9809aff7304721fddb95654901b32195c9c7avboxsyncnot be used in advertising or otherwise to promote the sale, use or
45e9809aff7304721fddb95654901b32195c9c7avboxsyncother dealings in this Software without prior written authorization
45e9809aff7304721fddb95654901b32195c9c7avboxsyncfrom The Open Group.
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync*/
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/*
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Fast bitblt macros for certain hardware. If your machine has an addressing
45e9809aff7304721fddb95654901b32195c9c7avboxsync * mode of small constant + register, you'll probably want this magic specific
45e9809aff7304721fddb95654901b32195c9c7avboxsync * code. It's 25% faster for the R2000. I haven't studied the Sparc
45e9809aff7304721fddb95654901b32195c9c7avboxsync * instruction set, but I suspect it also has this addressing mode. Also,
45e9809aff7304721fddb95654901b32195c9c7avboxsync * unrolling the loop by 32 is possibly excessive for mfb. The number of times
45e9809aff7304721fddb95654901b32195c9c7avboxsync * the loop is actually looped through is pretty small.
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/*
45e9809aff7304721fddb95654901b32195c9c7avboxsync * WARNING: These macros make *a lot* of assumptions about
45e9809aff7304721fddb95654901b32195c9c7avboxsync * the environment they are invoked in. Plenty of implicit
45e9809aff7304721fddb95654901b32195c9c7avboxsync * arguments, lots of side effects. Don't use them casually.
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define SwitchOdd(n) case n: BodyOdd(n)
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define SwitchEven(n) case n: BodyEven(n)
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/* to allow mfb and cfb to share code... */
45e9809aff7304721fddb95654901b32195c9c7avboxsync#ifdef HAVE_DIX_CONFIG_H
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <dix-config.h>
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#ifndef BitRight
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define BitRight(a,b) SCRRIGHT(a,b)
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define BitLeft(a,b) SCRLEFT(a,b)
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#ifdef LARGE_INSTRUCTION_CACHE
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define UNROLL 8
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define PackedLoop \
45e9809aff7304721fddb95654901b32195c9c7avboxsync switch (nl & (UNROLL-1)) { \
45e9809aff7304721fddb95654901b32195c9c7avboxsync SwitchOdd( 7) SwitchEven( 6) SwitchOdd( 5) SwitchEven( 4) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync SwitchOdd( 3) SwitchEven( 2) SwitchOdd( 1) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync } \
45e9809aff7304721fddb95654901b32195c9c7avboxsync while ((nl -= UNROLL) >= 0) { \
45e9809aff7304721fddb95654901b32195c9c7avboxsync LoopReset \
45e9809aff7304721fddb95654901b32195c9c7avboxsync BodyEven( 8) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync BodyOdd( 7) BodyEven( 6) BodyOdd( 5) BodyEven( 4) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync BodyOdd( 3) BodyEven( 2) BodyOdd( 1) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync }
45e9809aff7304721fddb95654901b32195c9c7avboxsync#else
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define UNROLL 4
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define PackedLoop \
45e9809aff7304721fddb95654901b32195c9c7avboxsync switch (nl & (UNROLL-1)) { \
45e9809aff7304721fddb95654901b32195c9c7avboxsync SwitchOdd( 3) SwitchEven( 2) SwitchOdd( 1) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync } \
45e9809aff7304721fddb95654901b32195c9c7avboxsync while ((nl -= UNROLL) >= 0) { \
45e9809aff7304721fddb95654901b32195c9c7avboxsync LoopReset \
45e9809aff7304721fddb95654901b32195c9c7avboxsync BodyEven( 4) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync BodyOdd( 3) BodyEven( 2) BodyOdd( 1) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync }
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define DuffL(counter,label,body) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync switch (counter & 3) { \
45e9809aff7304721fddb95654901b32195c9c7avboxsync label: \
45e9809aff7304721fddb95654901b32195c9c7avboxsync body \
45e9809aff7304721fddb95654901b32195c9c7avboxsync case 3: \
45e9809aff7304721fddb95654901b32195c9c7avboxsync body \
45e9809aff7304721fddb95654901b32195c9c7avboxsync case 2: \
45e9809aff7304721fddb95654901b32195c9c7avboxsync body \
45e9809aff7304721fddb95654901b32195c9c7avboxsync case 1: \
45e9809aff7304721fddb95654901b32195c9c7avboxsync body \
45e9809aff7304721fddb95654901b32195c9c7avboxsync case 0: \
45e9809aff7304721fddb95654901b32195c9c7avboxsync if ((counter -= 4) >= 0) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync goto label; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync }