Annotation of sys/arch/vax/vsa/maskbits.h, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: maskbits.h,v 1.1 2006/08/05 10:00:30 miod Exp $ */
! 2:
! 3: /*-
! 4: * Copyright (c) 1994
! 5: * The Regents of the University of California. All rights reserved.
! 6: *
! 7: * Redistribution and use in source and binary forms, with or without
! 8: * modification, are permitted provided that the following conditions
! 9: * are met:
! 10: * 1. Redistributions of source code must retain the above copyright
! 11: * notice, this list of conditions and the following disclaimer.
! 12: * 2. Redistributions in binary form must reproduce the above copyright
! 13: * notice, this list of conditions and the following disclaimer in the
! 14: * documentation and/or other materials provided with the distribution.
! 15: * 3. Neither the name of the University nor the names of its contributors
! 16: * may be used to endorse or promote products derived from this software
! 17: * without specific prior written permission.
! 18: *
! 19: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
! 20: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 21: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 22: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
! 23: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 24: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 25: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 26: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 27: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 28: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 29: * SUCH DAMAGE.
! 30: *
! 31: * @(#)maskbits.h 8.2 (Berkeley) 3/21/94
! 32: */
! 33:
! 34: /*
! 35: * Derived from X11R4
! 36: */
! 37:
! 38: /* the following notes use the following conventions:
! 39: SCREEN LEFT SCREEN RIGHT
! 40: in this file and maskbits.c, left and right refer to screen coordinates,
! 41: NOT bit numbering in registers.
! 42:
! 43: rasops_lmask[n]
! 44: bits[0,n-1] = 0 bits[n,31] = 1
! 45: rasops_rmask[n] =
! 46: bits[0,n-1] = 1 bits[n,31] = 0
! 47:
! 48: maskbits(x, w, startmask, endmask, nlw)
! 49: for a span of width w starting at position x, returns
! 50: a mask for ragged bits at start, mask for ragged bits at end,
! 51: and the number of whole longwords between the ends.
! 52:
! 53: */
! 54:
! 55: #define maskbits(x, w, startmask, endmask, nlw) \
! 56: do { \
! 57: startmask = rasops_lmask[(x) & 0x1f]; \
! 58: endmask = rasops_rmask[((x) + (w)) & 0x1f]; \
! 59: if (startmask) \
! 60: nlw = (((w) - (32 - ((x) & 0x1f))) >> 5); \
! 61: else \
! 62: nlw = (w) >> 5; \
! 63: } while (0)
! 64:
! 65: #define FASTGETBITS(psrc,x,w,dst) \
! 66: __asm__ ("extzv %1,%2,%3,%0" \
! 67: : "=g" (dst) \
! 68: : "g" (x), "g" (w), "m" (*(char *)(psrc)))
! 69:
! 70: #define FASTPUTBITS(src, x, w, pdst) \
! 71: __asm__ ("insv %3,%1,%2,%0" \
! 72: : "=m" (*(char *)(pdst)) \
! 73: : "g" (x), "g" (w), "g" (src))
! 74:
! 75: #define RR_CLEAR 0x00
! 76: #define RR_SET 0x01
! 77: #define RR_COPY 0x02
! 78:
! 79: #define getandputrop(psrc, srcbit, dstbit, width, pdst, rop) \
! 80: do { \
! 81: unsigned int _tmpdst; \
! 82: switch (rop) { \
! 83: case RR_CLEAR: \
! 84: _tmpdst = 0; \
! 85: break; \
! 86: case RR_SET: \
! 87: _tmpdst = ~0; \
! 88: break; \
! 89: default: \
! 90: FASTGETBITS(psrc, srcbit, width, _tmpdst); \
! 91: break; \
! 92: } \
! 93: FASTPUTBITS(_tmpdst, dstbit, width, pdst); \
! 94: } while (0)
! 95:
! 96: #define getunalignedword(psrc, x, dst) \
! 97: do { \
! 98: int _tmp; \
! 99: FASTGETBITS(psrc, x, 32, _tmp); \
! 100: dst = _tmp; \
! 101: } while (0)
CVSweb