v03i006: Purdue speedups to R3 server, Release 2, Part04/04
Mike Wexler
mikew at wyse.wyse.com
Wed Feb 1 05:57:24 AEST 1989
Submitted-by: spaf at purdue.edu (Gene Spafford)
Posting-number: Volume 3, Issue 6
Archive-name: p2speedups/part04
# Purdue/Purdue+ patches, part 4 of 4
# Shar archive. Give the following as input to /bin/sh
# Packed Sun Jan 22 19:39:58 EST 1989 by spaf at uther.cs.purdue.edu
#
# This archive contains:
# mfbline.c.patch
# mfbpntarea.c.patch
# mfbsetsp.c.patch
# mfbtegblt.c.patch
# mfbtile.c.patch
# maskbits.h.patch
# mfb.h.patch
#
#
echo x - mfbline.c.patch
sed 's/^X//' >mfbline.c.patch <<'*-*-END-of-mfbline.c.patch-*-*'
X*** /tmp/,RCSt1a01562 Wed Jan 18 23:15:24 1989
X--- ddx/mfb/mfbline.c Tue Jan 17 23:39:37 1989
X***************
X*** 1,3 ****
X--- 1,4 ----
X+ /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
X /***********************************************************
X Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
X and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X***************
X*** 110,116 ****
X--- 111,121 ----
X #define round(dividend, divisor) \
X ( (((dividend)<<1) + (divisor)) / ((divisor)<<1) )
X
X+ #ifndef PURDUE
X #define ceiling(m,n) ( ((m) + (n) -1)/(n) )
X+ #else
X+ #define ceiling(m,n) (((m)-1)/(n) + 1)
X+ #endif /* PURDUE */
X
X #define SignTimes(sign, n) ((sign) * ((int)(n)))
X
X***************
X*** 119,124 ****
X--- 124,130 ----
X ( ((sign)<0) ? -(n) : (n) )
X */
X
X+ #ifndef PURDUE
X #define SWAPPT(p1, p2, pttmp) \
X pttmp = p1; \
X p1 = p2; \
X***************
X*** 129,134 ****
X--- 135,156 ----
X i = j; \
X j = t;
X
X+ #else
X+ #define SWAPINT(i, j) \
X+ { register int _t = i; \
X+ i = j; \
X+ j = _t; \
X+ }
X+
X+ #define SWAPPT(i, j) \
X+ { register DDXPointRec _t; \
X+ _t = i; \
X+ i = j; \
X+ j = _t; \
X+ }
X+ #endif /* PURDUE */
X+
X+
X void
X mfbLineSS(pDrawable, pGC, mode, npt, pptInit)
X DrawablePtr pDrawable;
X***************
X*** 200,210 ****
X--- 222,236 ----
X nptTmp = npt;
X if (mode == CoordModeOrigin)
X {
X+ #ifndef PURDUE
X while(nptTmp--)
X {
X ppt->x += xorg;
X ppt++->y += yorg;
X }
X+ #else
X+ Duff(nptTmp, ppt->x += xorg; ppt++->y += yorg);
X+ #endif /* PURDUE */
X }
X else
X {
X***************
X*** 211,216 ****
X--- 237,243 ----
X ppt->x += xorg;
X ppt->y += yorg;
X nptTmp--;
X+ #ifndef PURDUE
X while(nptTmp--)
X {
X ppt++;
X***************
X*** 217,222 ****
X--- 244,252 ----
X ppt->x += (ppt-1)->x;
X ppt->y += (ppt-1)->y;
X }
X+ #else
X+ Duff(nptTmp, ppt++; ppt->x += (ppt-1)->x; ppt->y += (ppt-1)->y);
X+ #endif /* PURDUE */
X }
X
X ppt = pptInit;
X***************
X*** 235,240 ****
X--- 265,273 ----
X */
X if (pt1.y > pt2.y)
X {
X+ #ifdef PURDUE
X+ register int tmp;
X+ #endif
X tmp = pt2.y;
X pt2.y = pt1.y + 1;
X pt1.y = tmp + 1;
X***************
X*** 277,282 ****
X--- 310,318 ----
X */
X if (pt1.x > pt2.x)
X {
X+ #ifdef PURDUE
X+ register int tmp;
X+ #endif
X tmp = pt2.x;
X pt2.x = pt1.x + 1;
X pt1.x = tmp + 1;
X***************
X*** 308,314 ****
X--- 344,354 ----
X if (pbox->x1 >= pt2.x)
X {
X nbox = 0;
X+ #ifndef PURDUE
X continue;
X+ #else
X+ break;
X+ #endif /* PURDUE */
X }
X
X x1 = max(pt1.x, pbox->x1);
X***************
X*** 440,445 ****
X--- 480,486 ----
X (ppt->y != pptInit->y) ||
X (ppt == pptInit + 1)))
X {
X+ #ifndef PURDUE
X pt1 = *ppt;
X
X nbox = nboxInit;
X***************
X*** 469,474 ****
X--- 510,554 ----
X else
X pbox++;
X }
X+ #else
X+ unsigned int _mask;
X+ int _incr, _rop = ((mfbPrivGC *)(pGC->devPriv))->rop;
X+
X+ pt1 = *ppt;
X+ if (_rop == RROP_BLACK)
X+ _mask = rmask[pt1.x & 0x1f];
X+ else
X+ _mask = mask[pt1.x & 0x1f];
X+ _incr = (pt1.y * nlwidth) + (pt1.x >> 5);
X+
X+ nbox = nboxInit;
X+ pbox = pboxInit;
X+ while (nbox--)
X+ {
X+ if ((pt1.x >= pbox->x1) &&
X+ (pt1.y >= pbox->y1) &&
X+ (pt1.x < pbox->x2) &&
X+ (pt1.y < pbox->y2))
X+ {
X+ addrl += _incr;
X+ switch(_rop)
X+ {
X+ case RROP_BLACK:
X+ *addrl &= _mask;
X+ break;
X+ case RROP_WHITE:
X+ *addrl |= _mask;
X+ break;
X+ case RROP_INVERT:
X+ *addrl ^= _mask;
X+ break;
X+ }
X+ break;
X+ }
X+ else
X+ pbox++;
X+ }
X+ #endif /* PURDUE */
X }
X }
X
X***************
X*** 570,580 ****
X--- 650,664 ----
X nptTmp = npt;
X if (mode == CoordModeOrigin)
X {
X+ #ifndef PURDUE
X while(nptTmp--)
X {
X ppt->x += xorg;
X ppt++->y += yorg;
X }
X+ #else
X+ Duff(nptTmp, ppt->x += xorg; ppt++->y += yorg );
X+ #endif /* PURDUE */
X }
X else
X {
X***************
X*** 581,586 ****
X--- 665,671 ----
X ppt->x += xorg;
X ppt->y += yorg;
X nptTmp--;
X+ #ifndef PURDUE
X while(nptTmp--)
X {
X ppt++;
X***************
X*** 587,592 ****
X--- 672,680 ----
X ppt->x += (ppt-1)->x;
X ppt->y += (ppt-1)->y;
X }
X+ #else
X+ Duff (nptTmp, ppt++; ppt->x += (ppt-1)->x; ppt->y += (ppt-1)->y);
X+ #endif
X }
X
X
X***************
X*** 766,774 ****
X--- 854,868 ----
X clipDone = 1;
X if (swapped)
X {
X+ #ifndef PURDUE
X SWAPPT(pt1, pt2, ptTmp);
X SWAPINT(oc1, oc2, tmp);
X SWAPINT(clip1, clip2, tmp);
X+ #else
X+ SWAPPT(pt1, pt2);
X+ SWAPINT(oc1, oc2);
X+ SWAPINT(clip1, clip2);
X+ #endif /* PURDUE */
X }
X }
X else /* have to clip */
X***************
X*** 776,784 ****
X--- 870,884 ----
X /* only clip one point at a time */
X if (!oc1)
X {
X+ #ifndef PURDUE
X SWAPPT(pt1, pt2, ptTmp);
X SWAPINT(oc1, oc2, tmp);
X SWAPINT(clip1, clip2, tmp);
X+ #else
X+ SWAPPT(pt1, pt2);
X+ SWAPINT(oc1, oc2);
X+ SWAPINT(clip1, clip2);
X+ #endif /* PURDUE */
X swapped = !swapped;
X }
X
*-*-END-of-mfbline.c.patch-*-*
echo x - mfbpntarea.c.patch
sed 's/^X//' >mfbpntarea.c.patch <<'*-*-END-of-mfbpntarea.c.patch-*-*'
X*** /tmp/,RCSt1a01566 Wed Jan 18 23:15:29 1989
X--- ddx/mfb/mfbpntarea.c Tue Jan 17 23:39:40 1989
X***************
X*** 1,3 ****
X--- 1,4 ----
X+ /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
X /***********************************************************
X Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
X and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X***************
X*** 99,109 ****
X--- 100,114 ----
X {
X maskpartialbits(pbox->x1, w, startmask);
X nlwExtra = nlwidth;
X+ #ifndef PURDUE
X while (h--)
X {
X *p OPEQ startmask;
X p += nlwExtra;
X }
X+ #else
X+ Duff(h, *p OPEQ startmask; p += nlwExtra);
X+ #endif
X }
X else
X {
X***************
X*** 118,125 ****
X--- 123,134 ----
X nlw = nlwMiddle;
X *p OPEQ startmask;
X p++;
X+ #ifndef PURDUE
X while (nlw--)
X *p++ EQWHOLEWORD;
X+ #else
X+ Duff(nlw, *p++ EQWHOLEWORD);
X+ #endif /* PURDUE */
X *p OPEQ endmask;
X p += nlwExtra;
X }
X***************
X*** 132,139 ****
X--- 141,152 ----
X nlw = nlwMiddle;
X *p OPEQ startmask;
X p++;
X+ #ifndef PURDUE
X while (nlw--)
X *p++ EQWHOLEWORD;
X+ #else
X+ Duff(nlw, *p++ EQWHOLEWORD);
X+ #endif /* PURDUE */
X p += nlwExtra;
X }
X }
X***************
X*** 142,149 ****
X--- 155,166 ----
X while (h--)
X {
X nlw = nlwMiddle;
X+ #ifndef PURDUE
X while (nlw--)
X *p++ EQWHOLEWORD;
X+ #else
X+ Duff(nlw, *p++ EQWHOLEWORD);
X+ #endif /* PURDUE */
X *p OPEQ endmask;
X p += nlwExtra;
X }
X***************
X*** 153,160 ****
X--- 170,181 ----
X while (h--)
X {
X nlw = nlwMiddle;
X+ #ifndef PURDUE
X while (nlw--)
X *p++ EQWHOLEWORD;
X+ #else
X+ Duff(nlw, *p++ EQWHOLEWORD);
X+ #endif /* PURDUE */
X p += nlwExtra;
X }
X }
X***************
X*** 257,267 ****
X--- 278,292 ----
X nlw = nlwMiddle;
X *p OPEQ (srcpix & startmask);
X p++;
X+ #ifndef PURDUE
X while (nlw--)
X {
X *p OPEQ srcpix;
X p++;
X }
X+ #else
X+ Duff (nlw, *p++ OPEQ srcpix);
X+ #endif /* PURDUE */
X *p OPEQ (srcpix & endmask);
X p += nlwExtra;
X }
X***************
X*** 276,286 ****
X--- 301,315 ----
X nlw = nlwMiddle;
X *p OPEQ (srcpix & startmask);
X p++;
X+ #ifndef PURDUE
X while (nlw--)
X {
X *p OPEQ srcpix;
X p++;
X }
X+ #else
X+ Duff(nlw, *p++ OPEQ srcpix);
X+ #endif /* PURDUE */
X p += nlwExtra;
X }
X }
X***************
X*** 291,301 ****
X--- 320,334 ----
X srcpix = psrc[iy];
X iy = ++iy < tileHeight ? iy : 0;
X nlw = nlwMiddle;
X+ #ifndef PURDUE
X while (nlw--)
X {
X *p OPEQ srcpix;
X p++;
X }
X+ #else
X+ Duff(nlw, *p++ OPEQ srcpix);
X+ #endif /* PURDUE */
X *p OPEQ (srcpix & endmask);
X p += nlwExtra;
X }
X***************
X*** 307,317 ****
X--- 340,354 ----
X srcpix = psrc[iy];
X iy = ++iy < tileHeight ? iy : 0;
X nlw = nlwMiddle;
X+ #ifndef PURDUE
X while (nlw--)
X {
X *p OPEQ srcpix;
X p++;
X }
X+ #else
X+ Duff(nlw, *p++ OPEQ srcpix);
X+ #endif /* PURDUE */
X p += nlwExtra;
X }
X }
*-*-END-of-mfbpntarea.c.patch-*-*
echo x - mfbsetsp.c.patch
sed 's/^X//' >mfbsetsp.c.patch <<'*-*-END-of-mfbsetsp.c.patch-*-*'
X*** /tmp/,RCSt1a01579 Wed Jan 18 23:15:37 1989
X--- ddx/mfb/mfbsetsp.c Tue Jan 17 23:39:49 1989
X***************
X*** 1,3 ****
X--- 1,4 ----
X+ /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
X /***********************************************************
X Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
X and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X***************
X*** 73,80 ****
X
X if (dstBit + w <= 32)
X {
X getbits(psrc, offSrc, w, tmpSrc);
X! putbitsrop(tmpSrc, dstBit, w, pdst, alu);
X }
X else
X {
X--- 74,85 ----
X
X if (dstBit + w <= 32)
X {
X+ #ifndef PURDUE
X getbits(psrc, offSrc, w, tmpSrc);
X! putbitsrop(tmpSrc, dstBit, w, pdst, alu);
X! #else
X! getandputrop(psrc, offSrc, dstBit, w, pdst, alu)
X! #endif /* PURDUE */
X }
X else
X {
X***************
X*** 90,97 ****
X--- 95,106 ----
X nend = 0;
X if (startmask)
X {
X+ #ifndef PURDUE
X getbits(psrc, offSrc, nstart, tmpSrc);
X putbitsrop(tmpSrc, dstBit, nstart, pdst, alu);
X+ #else
X+ getandputrop(psrc, offSrc, dstBit, nstart, pdst, alu)
X+ #endif /* PURDUE */
X pdst++;
X offSrc += nstart;
X if (offSrc > 31)
X***************
X*** 104,117 ****
X--- 113,134 ----
X while (nl--)
X {
X getbits(psrc, offSrc, 32, tmpSrc);
X+ #ifndef PURDUE
X *pdst = DoRop(alu, tmpSrc, *pdst);
X+ #else /* PURDUE */
X+ DoRop(*pdst, alu, tmpSrc, *pdst);
X+ #endif /* PURDUE */
X pdst++;
X psrc++;
X }
X if (endmask)
X {
X+ #ifndef PURDUE
X getbits(psrc, offSrc, nend, tmpSrc);
X putbitsrop(tmpSrc, 0, nend, pdst, alu);
X+ #else
X+ getandputrop0(psrc, offSrc, nend, pdst, alu);
X+ #endif /* PURDUE */
X }
X
X }
*-*-END-of-mfbsetsp.c.patch-*-*
echo x - mfbtegblt.c.patch
sed 's/^X//' >mfbtegblt.c.patch <<'*-*-END-of-mfbtegblt.c.patch-*-*'
X*** /tmp/,RCSt1a01583 Wed Jan 18 23:15:39 1989
X--- ddx/mfb/mfbtegblt.c Tue Jan 17 23:39:52 1989
X***************
X*** 1,4 ****
X--- 1,5 ----
X /* $XConsortium: mfbtegblt.c,v 1.2 88/09/06 14:53:48 jim Exp $ */
X+ /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
X /***********************************************************
X Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
X and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X***************
X*** 159,176 ****
X--- 160,198 ----
X hTmp = h;
X pdst = pdstBase;
X
X+ #ifdef PURDUE
X+ #if defined(NO_3_60_CG4) && defined(FASTPUTBITS) && defined(FASTGETBITS)
X+ #define FASTCHARS
X+ #endif
X+ #endif
X+
X+ #ifndef FASTCHARS
X if ( (xpos+w) < 32)
X {
X maskpartialbits(xpos, w, startmask);
X+ #endif /* FASTCHARS */
X while(hTmp--)
X {
X+ #ifndef FASTCHARS
X getleftbits(pglyph, w, tmpSrc);
X *pdst = (*pdst & ~startmask) |
X (OP(SCRRIGHT(tmpSrc, xpos)) & startmask);
X+ #else
X+ FASTGETBITS(pglyph, 0, w, tmpSrc);
X+ FASTPUTBITS(OP(tmpSrc), xpos, w, pdst);
X+ #endif /* FASTCHARS */
X pdst += widthDst;
X pglyph += widthGlyph;
X }
X+ #ifdef FASTCHARS
X xpos += w;
X+ if (xpos >= 32)
X+ {
X+ xpos &= 0x1f;
X+ pdstBase++;
X+ }
X+ #else
X+ xpos += w;
X }
X else
X {
X***************
X*** 190,195 ****
X--- 212,218 ----
X xpos &= 0x1f;
X pdstBase++;
X }
X+ #endif /* FASTCHARS */
X }
X break;
X }
*-*-END-of-mfbtegblt.c.patch-*-*
echo x - mfbtile.c.patch
sed 's/^X//' >mfbtile.c.patch <<'*-*-END-of-mfbtile.c.patch-*-*'
X*** /tmp/,RCSt1a01587 Wed Jan 18 23:15:41 1989
X--- ddx/mfb/mfbtile.c Tue Jan 17 23:39:55 1989
X***************
X*** 1,3 ****
X--- 1,4 ----
X+ /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
X /***********************************************************
X Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
X and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X***************
X*** 108,115 ****
X--- 109,124 ----
X {
X srcpix = psrc[iy];
X iy = ++iy < tileHeight ? iy : 0;
X+ #ifndef PURDUE
X *p = (*p & ~startmask) |
X (DoRop(alu, srcpix, *p) & startmask);
X+ #else /* PURDUE */
X+ {
X+ unsigned _p;
X+ DoRop(_p, alu, srcpix, *p);
X+ *p = (*p & ~startmask) | (_p & startmask);
X+ }
X+ #endif /* PURDUE */
X p += nlwExtra;
X }
X }
X***************
X*** 126,134 ****
X--- 135,152 ----
X srcpix = psrc[iy];
X iy = ++iy < tileHeight ? iy : 0;
X nlw = nlwMiddle;
X+ #ifndef PURDUE
X *p = (*p & ~startmask) |
X (DoRop(alu, srcpix, *p) & startmask);
X+ #else /* PURDUE */
X+ {
X+ unsigned _p;
X+ DoRop(_p, alu, srcpix, *p);
X+ *p = (*p & ~startmask) | (_p & startmask);
X+ }
X+ #endif /* PURDUE */
X p++;
X+ #ifndef PURDUE
X while (nlw--)
X {
X *p = DoRop(alu, srcpix, *p);
X***************
X*** 136,141 ****
X--- 154,172 ----
X }
X *p = (*p & ~endmask) |
X (DoRop(alu, srcpix, *p) & endmask);
X+ #else /* PURDUE */
X+ while (nlw--)
X+ {
X+ DoRop(*p, alu, srcpix, *p);
X+ p++;
X+ }
X+
X+ {
X+ unsigned _p;
X+ DoRop(_p, alu, srcpix, *p);
X+ *p = (*p & ~endmask) | (_p & endmask);
X+ }
X+ #endif /* PURDUE */
X p += nlwExtra;
X }
X }
X***************
X*** 147,158 ****
X--- 178,201 ----
X srcpix = psrc[iy];
X iy = ++iy < tileHeight ? iy : 0;
X nlw = nlwMiddle;
X+ #ifndef PURDUE
X *p = (*p & ~startmask) |
X (DoRop(alu, srcpix, *p) & startmask);
X+ #else /* PURDUE */
X+ {
X+ unsigned _p;
X+ DoRop(_p, alu, srcpix, *p);
X+ *p = (*p & ~startmask) | (_p & startmask);
X+ }
X+ #endif /* PURDUE */
X p++;
X while (nlw--)
X {
X+ #ifndef PURDUE
X *p = DoRop(alu, srcpix, *p);
X+ #else /* PURDUE */
X+ DoRop(*p, alu, srcpix, *p);
X+ #endif /* PURDUE */
X p++;
X }
X p += nlwExtra;
X***************
X*** 165,170 ****
X--- 208,214 ----
X srcpix = psrc[iy];
X iy = ++iy < tileHeight ? iy : 0;
X nlw = nlwMiddle;
X+ #ifndef PURDUE
X while (nlw--)
X {
X *p = DoRop(alu, srcpix, *p);
X***************
X*** 172,177 ****
X--- 216,234 ----
X }
X *p = (*p & ~endmask) |
X (DoRop(alu, srcpix, *p) & endmask);
X+ #else /* PURDUE */
X+ while (nlw--)
X+ {
X+ DoRop(*p, alu, srcpix, *p);
X+ p++;
X+ }
X+
X+ {
X+ unsigned _p;
X+ DoRop(_p, alu, srcpix, *p);
X+ *p = (*p & ~endmask) | (_p & endmask);
X+ }
X+ #endif /* PURDUE */
X p += nlwExtra;
X }
X }
X***************
X*** 184,190 ****
X--- 241,251 ----
X nlw = nlwMiddle;
X while (nlw--)
X {
X+ #ifndef PURDUE
X *p = DoRop(alu, srcpix, *p);
X+ #else /* PURDUE */
X+ DoRop(*p, alu, srcpix, *p);
X+ #endif /* PURDUE */
X p++;
X }
X p += nlwExtra;
*-*-END-of-mfbtile.c.patch-*-*
echo x - maskbits.h.patch
sed 's/^X//' >maskbits.h.patch <<'*-*-END-of-maskbits.h.patch-*-*'
X*** /tmp/,RCSt1a00699 Fri Jan 20 21:38:29 1989
X--- ./ddx/mfb/maskbits.h Fri Jan 20 18:05:40 1989
X***************
X*** 1,3 ****
X--- 1,4 ----
X+ /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
X /***********************************************************
X Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
X and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X***************
X*** 4,16 ****
X
X All Rights Reserved
X
X! Permission to use, copy, modify, and distribute this software and its
X! documentation for any purpose and without fee is hereby granted,
X provided that the above copyright notice appear in all copies and that
X! both that copyright notice and this permission notice appear in
X supporting documentation, and that the names of Digital or MIT not be
X used in advertising or publicity pertaining to distribution of the
X! software without specific, written prior permission.
X
X DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
X ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
X--- 5,17 ----
X
X All Rights Reserved
X
X! Permission to use, copy, modify, and distribute this software and its
X! documentation for any purpose and without fee is hereby granted,
X provided that the above copyright notice appear in all copies and that
X! both that copyright notice and this permission notice appear in
X supporting documentation, and that the names of Digital or MIT not be
X used in advertising or publicity pertaining to distribution of the
X! software without specific, written prior permission.
X
X DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
X ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
X***************
X*** 28,35 ****
X--- 29,40 ----
X
X extern int starttab[];
X extern int endtab[];
X+ #ifndef PURDUE
X extern int startpartial[];
X extern int endpartial[];
X+ #else /* PURDUE */
X+ extern unsigned partmasks[32][32];
X+ #endif /* PURDUE */
X extern int rmask[];
X extern int mask[];
X
X***************
X*** 39,45 ****
X in this file and maskbits.c, left and right refer to screen coordinates,
X NOT bit numbering in registers.
X
X! starttab[n]
X bits[0,n-1] = 0 bits[n,31] = 1
X endtab[n] =
X bits[0,n-1] = 1 bits[n,31] = 0
X--- 44,50 ----
X in this file and maskbits.c, left and right refer to screen coordinates,
X NOT bit numbering in registers.
X
X! starttab[n]
X bits[0,n-1] = 0 bits[n,31] = 1
X endtab[n] =
X bits[0,n-1] = 1 bits[n,31] = 0
X***************
X*** 152,158 ****
X DoRop)
X
X putbitsrrop(src, x, w, pdst, ROP)
X! like putbits but calls DoRRop with the reduced rasterop ROP
X (see mfb.h for DoRRop)
X
X -----------------------------------------------------------------------
X--- 157,163 ----
X DoRop)
X
X putbitsrrop(src, x, w, pdst, ROP)
X! like putbits but calls DoRRop with the reduced rasterop ROP
X (see mfb.h for DoRRop)
X
X -----------------------------------------------------------------------
X***************
X*** 206,213 ****
X--- 211,223 ----
X else \
X nlw = (w) >> 5;
X
X+ #ifndef PURDUE
X #define maskpartialbits(x, w, mask) \
X mask = startpartial[(x) & 0x1f] & endpartial[((x) + (w)) & 0x1f];
X+ #else /* PURDUE */
X+ #define maskpartialbits(x, w, mask) \
X+ mask = partmasks[(x)&0x1f][(w)&0x1f];
X+ #endif /* PURDUE */
X
X #define mask32bits(x, w, startmask, endmask) \
X startmask = starttab[(x)&0x1f]; \
X***************
X*** 214,219 ****
X--- 224,231 ----
X endmask = endtab[((x)+(w)) & 0x1f];
X
X
X+ #ifndef PURDUE
X+
X #define getbits(psrc, x, w, dst) \
X if ( ((x) + (w)) <= 32) \
X { \
X***************
X*** 270,275 ****
X--- 282,288 ----
X *((pdst)+1) = (*((pdst)+1) & starttab[n]) | (t2 & endtab[n]); \
X }
X
X+
X #define putbitsrrop(src, x, w, pdst, rop) \
X if ( ((x)+(w)) <= 32) \
X { \
X***************
X*** 295,302 ****
X--- 308,501 ----
X *((pdst)+1) = (*((pdst)+1) & starttab[n]) | (t2 & endtab[n]); \
X }
X
X+ #else /* PURDUE */
X+
X+
X+ #ifdef __GNUC__
X+ #ifdef vax
X+ #define FASTGETBITS(psrc,x,w,dst) \
X+ asm ("extzv %1,%2,%3,%0" \
X+ : "g" (dst) \
X+ : "g" (x), "g" (w), "m" (*(char *)(psrc)))
X+ #define getbits(psrc,x,w,dst) FASTGETBITS(psrc,x,w,dst)
X+
X+ #define FASTPUTBITS(src, x, w, pdst) \
X+ asm ("insv %3,%1,%2,%0" \
X+ : "m" (*(char *)(pdst)) \
X+ : "g" (x), "g" (w), "g" (src))
X+ #define putbits(src, x, w, pdst) FASTPUTBITS(src, x, w, pdst)
X+ #endif vax
X+ #ifdef mc68020
X+ #define FASTGETBITS(psrc, x, w, dst) \
X+ asm ("bfextu %3{%1:%2},%0" \
X+ : "=d" (dst) : "di" (x), "di" (w), "o" (*(char *)(psrc)))
X+
X+ #define getbits(psrc,x,w,dst) \
X+ { \
X+ FASTGETBITS(psrc, x, w, dst);\
X+ dst <<= (32-(w)); \
X+ }
X+
X+ #define FASTPUTBITS(src, x, w, pdst) \
X+ asm ("bfins %3,%0{%1:%2}" \
X+ : "=o" (*(char *)(pdst)) \
X+ : "di" (x), "di" (w), "d" (src), "0" (*(char *) (pdst)))
X+
X+ #define putbits(src, x, w, pdst) FASTPUTBITS(((src) >> (32-(w))), x, w, pdst)
X+
X+ #endif mc68020
X+ #endif __GNUC__
X+
X+ /* The following version is used on 3/60+CG4 machines, and those
X+ * not defining FASTPUTBITS, above
X+ */
X+
X+ #define u_putbits(src, x, w, pdst) \
X+ { \
X+ register int n = (x)+(w)-32; \
X+ \
X+ if (n <= 0) \
X+ { \
X+ register int tmpmask; \
X+ maskpartialbits((x), (w), tmpmask); \
X+ *(pdst) = (*(pdst) & ~tmpmask) | \
X+ (SCRRIGHT((unsigned) src, x) & tmpmask); \
X+ } \
X+ else \
X+ { \
X+ register unsigned int *ptmp_ = (unsigned *) (pdst)+1; \
X+ *(pdst) = (*(pdst) & endtab[x]) | (SCRRIGHT((unsigned) (src), x)); \
X+ *ptmp_ = (*ptmp_ & starttab[n]) | \
X+ (SCRLEFT((unsigned) src, 32-(x)) & endtab[n]); \
X+ } \
X+ }
X+
X+ /* We don't need this flag unless we're dealing with Suns */
X+ #ifndef mc68020
X+ #define NO_3_60_CG4
X+ #endif
X+
X+ /* ...and we don't need this macro unless we have a 3/60+CG4 */
X+ #ifdef NO_3_60_CG4
X+ #undef u_putbits
X+ #define u_putbits(src, x, w, pdst) putbits(src, x, w, pdst)
X+ #endif /* NO_3_60_C64 */
X+
X+ /* Now if we have not gotten any really good bitfield macros, try some
X+ * moderately fast macros. Alas, I don't know how to do asm instructions
X+ * without gcc.
X+ */
X+
X+ #ifndef putbits
X+ #define putbits(src, x, w, pdst) u_putbits(src, x, w, pdst)
X+ #endif
X+
X+ #ifndef getbits
X+ #define getbits(psrc, x, w, dst) \
X+ { \
X+ dst = SCRLEFT((unsigned) *(psrc), (x)); \
X+ if ( ((x) + (w)) > 32) \
X+ dst |= (SCRRIGHT((unsigned) *((psrc)+1), 32-(x))); \
X+ }
X+ #endif
X+
X+ /* If our getbits and putbits are fast enough,
X+ * do this brute force, it's faster
X+ */
X+
X+ /* We have to special-case putbitsrop because of 3/60+CG4 combos
X+ */
X+
X+ #define u_putbitsrop(src, x, w, pdst, rop) \
X+ {\
X+ register int t1, t2; \
X+ register int n = (x)+(w)-32; \
X+ \
X+ t1 = SCRRIGHT((src), (x)); \
X+ DoRop(t2, rop, t1, *(pdst)); \
X+ \
X+ if (n <= 0) \
X+ { \
X+ register int tmpmask; \
X+ \
X+ maskpartialbits((x), (w), tmpmask); \
X+ *(pdst) = (*(pdst) & ~tmpmask) | (t2 & tmpmask); \
X+ } \
X+ else \
X+ { \
X+ int m = 32-(x); \
X+ register unsigned int *ptmp_ = (unsigned *) (pdst)+1; \
X+ *(pdst) = (*(pdst) & endtab[x]) | (t2 & starttab[x]); \
X+ t1 = SCRLEFT((src), m); \
X+ DoRop(t2, rop, t1, *ptmp_); \
X+ *ptmp_ = (*ptmp_ & starttab[n]) | (t2 & endtab[n]); \
X+ } \
X+ }
X+
X+ #if defined(FASTPUTBITS) && defined(FASTGETBITS)
X+
X+ #define putbitsrop(src, x, w, pdst, rop) \
X+ { \
X+ register int _tmp, _tmp2; \
X+ FASTGETBITS(pdst, x, w, _tmp); \
X+ _tmp2 = SCRRIGHT(src, 32-(w)); \
X+ DoRop(_tmp, rop, _tmp2, _tmp) \
X+ FASTPUTBITS(_tmp, x, w, pdst); \
X+ }
X+
X+ #ifdef NO_3_60_CG4
X+ #undef u_putbitsrop
X+ #else
X+ #undef putbitsrop
X+ #define putbitsrop(src, x, w, pdst, rop) u_putbitsrop(src, x, w, pdst, rop)
X+ #endif /* NO_3_60_C64 */
X+
X+ #define putbitsrrop(src, x, w, pdst, rop) \
X+ { \
X+ register int _tmp, _tmp2; \
X+ \
X+ FASTGETBITS(pdst, x, w, _tmp); \
X+ _tmp2 = SCRRIGHT(src, 32-(w)); \
X+ _tmp= DoRRop(rop, _tmp2, _tmp); \
X+ FASTPUTBITS(_tmp, x, w, pdst); \
X+ }
X+ #endif
X+
X+ #ifndef putbitsrrop
X+ #define putbitsrrop(src, x, w, pdst, rop) \
X+ {\
X+ register int t1, t2; \
X+ register int n = (x)+(w)-32; \
X+ \
X+ t1 = SCRRIGHT((src), (x)); \
X+ t2 = DoRRop(rop, t1, *(pdst)); \
X+ \
X+ if (n <= 0) \
X+ { \
X+ register int tmpmask; \
X+ \
X+ maskpartialbits((x), (w), tmpmask); \
X+ *(pdst) = (*(pdst) & ~tmpmask) | (t2 & tmpmask); \
X+ } \
X+ else \
X+ { \
X+ int m = 32-(x); \
X+ register unsigned int *ptmp_ = (unsigned *) (pdst)+1; \
X+ *(pdst) = (*(pdst) & endtab[x]) | (t2 & starttab[x]); \
X+ t1 = SCRLEFT((src), m); \
X+ t2 = DoRRop(rop, t1, *ptmp_); \
X+ *ptmp_ = (*ptmp_ & starttab[n]) | (t2 & endtab[n]); \
X+ } \
X+ }
X+ #endif
X+ #endif /* PURDUE */
X+
X #if GETLEFTBITS_ALIGNMENT == 1
X+ #ifndef PURDUE
X #define getleftbits(psrc, w, dst) getbits((unsigned int *)psrc, 0, w, dst)
X+ #else /* PURDUE */
X+ #define getleftbits(psrc, w, dst) dst = *((unsigned int *) psrc)
X+ #endif
X #endif /* GETLEFTBITS_ALIGNMENT == 1 */
X
X #if GETLEFTBITS_ALIGNMENT == 2
X***************
X*** 305,311 ****
X if ( ((int)(psrc)) & 0x01 ) \
X getbits( ((unsigned int *)(((char *)(psrc))-1)), 8, (w), (dst) ); \
X else \
X! getbits(psrc, 0, w, dst)
X }
X #endif /* GETLEFTBITS_ALIGNMENT == 2 */
X
X--- 504,510 ----
X if ( ((int)(psrc)) & 0x01 ) \
X getbits( ((unsigned int *)(((char *)(psrc))-1)), 8, (w), (dst) ); \
X else \
X! getbits(psrc, 0, w, dst) \
X }
X #endif /* GETLEFTBITS_ALIGNMENT == 2 */
X
X***************
X*** 326,329 ****
X--- 525,652 ----
X getleftbits((psrc), (w), (dst)); \
X dst = SCRLEFT((dst), (offset));
X
X+ #ifdef PURDUE
X+ /* FASTGETBITS and FASTPUTBITS are not necessarily correct implementations of
X+ * getbits and putbits, but they work if used together.
X+ *
X+ * On a MSBFirst machine, a cpu bitfield extract instruction (like bfextu)
X+ * could normally assign its result to a long word register in the screen
X+ * right position. This saves canceling register shifts by not fighting the
X+ * natural cpu byte order.
X+ *
X+ * Unfortunately, these fail on a 3/60+CG4 and cannot be used unmodified. Sigh.
X+ */
X+ #if defined(FASTGETBITS) && defined(FASTPUTBITS)
X+ #ifdef NO_3_60_CG4
X+ #define u_FASTPUT(aa, bb, cc, dd) FASTPUTBITS(aa, bb, cc, dd)
X+ #else
X+ #define u_FASTPUT(aa, bb, cc, dd) u_putbits(SCRLEFT(aa, 32-(cc)), bb, cc, dd)
X+ #endif
X
X+ #define getandputbits(psrc, srcbit, dstbit, width, pdst) \
X+ { \
X+ register unsigned int _tmpbits; \
X+ FASTGETBITS(psrc, srcbit, width, _tmpbits); \
X+ u_FASTPUT(_tmpbits, dstbit, width, pdst); \
X+ }
X+
X+ #define getandputrop(psrc, srcbit, dstbit, width, pdst, rop) \
X+ { \
X+ register unsigned int _tmpsrc, _tmpdst; \
X+ FASTGETBITS(pdst, dstbit, width, _tmpdst); \
X+ FASTGETBITS(psrc, srcbit, width, _tmpsrc); \
X+ DoRop(_tmpdst, rop, _tmpsrc, _tmpdst); \
X+ u_FASTPUT(_tmpdst, dstbit, width, pdst); \
X+ }
X+
X+ #define getandputrrop(psrc, srcbit, dstbit, width, pdst, rop) \
X+ { \
X+ register unsigned int _tmpsrc, _tmpdst; \
X+ FASTGETBITS(pdst, dstbit, width, _tmpdst); \
X+ FASTGETBITS(psrc, srcbit, width, _tmpsrc); \
X+ _tmpdst = DoRRop(rop, _tmpsrc, _tmpdst); \
X+ u_FASTPUT(_tmpdst, dstbit, width, pdst); \
X+ }
X+
X+ #define getandputbits0(psrc, srcbit, width, pdst) \
X+ getandputbits(psrc, srcbit, 0, width, pdst)
X+
X+ #define getandputrop0(psrc, srcbit, width, pdst, rop) \
X+ getandputrop(psrc, srcbit, 0, width, pdst, rop)
X+
X+ #define getandputrrop0(psrc, srcbit, width, pdst, rop) \
X+ getandputrrop(psrc, srcbit, 0, width, pdst, rop)
X+
X+
X+ #else /* Slow poke */
X+
X+ /* pairs of getbits/putbits happen frequently. Some of the code can
X+ * be shared or avoided in a few specific instances. It gets us a
X+ * small advantage, so we do it. The getandput...0 macros are the only ones
X+ * which speed things here. The others are here for compatibility w/the above
X+ * FAST ones
X+ */
X+
X+ #define getandputbits(psrc, srcbit, dstbit, width, pdst) \
X+ { \
X+ register unsigned int _tmpbits; \
X+ getbits(psrc, srcbit, width, _tmpbits); \
X+ putbits(_tmpbits, dstbit, width, pdst); \
X+ }
X+
X+ #define getandputrop(psrc, srcbit, dstbit, width, pdst, rop) \
X+ { \
X+ register unsigned int _tmpbits; \
X+ getbits(psrc, srcbit, width, _tmpbits) \
X+ putbitsrop(_tmpbits, dstbit, width, pdst, rop) \
X+ }
X+
X+ #define getandputrrop(psrc, srcbit, dstbit, width, pdst, rop) \
X+ { \
X+ register unsigned int _tmpbits; \
X+ getbits(psrc, srcbit, width, _tmpbits) \
X+ putbitsrrop(_tmpbits, dstbit, width, pdst, rop) \
X+ }
X+
X+
X+ #define getandputbits0(psrc, sbindex, width, pdst) \
X+ { /* unroll the whole damn thing to see how it * behaves */ \
X+ register int _flag = 32 - (sbindex); \
X+ register unsigned int _src; \
X+ \
X+ _src = SCRLEFT (*(psrc), (sbindex)); \
X+ if ((width) > _flag) \
X+ _src |= SCRRIGHT (*((psrc) + 1), _flag); \
X+ \
X+ *(pdst) = (*(pdst) & starttab[(width)]) | (_src & endtab[(width)]); \
X+ }
X+
X+
X+ #define getandputrop0(psrc, sbindex, width, pdst, rop) \
X+ { \
X+ register int _flag = 32 - (sbindex); \
X+ register unsigned int _src; \
X+ \
X+ _src = SCRLEFT (*(psrc), (sbindex)); \
X+ if ((width) > _flag) \
X+ _src |= SCRRIGHT (*((psrc) + 1), _flag); \
X+ DoRop(_src, rop, _src, *(pdst)); \
X+ \
X+ *(pdst) = (*(pdst) & starttab[(width)]) | (_src & endtab[(width)]); \
X+ }
X+
X+ #define getandputrrop0(psrc, sbindex, width, pdst, rop) \
X+ { \
X+ int _flag = 32 - (sbindex); \
X+ register unsigned int _src; \
X+ \
X+ _src = SCRLEFT (*(psrc), (sbindex)); \
X+ if ((width) > _flag) \
X+ _src |= SCRRIGHT (*((psrc) + 1), _flag); \
X+ _src = DoRRop(rop, _src, *(pdst)); \
X+ \
X+ *(pdst) = (*(pdst) & starttab[(width)]) | (_src & endtab[(width)]); \
X+ }
X+
X+ #endif /* FASTGETBITS && FASTPUTBITS */
X+ #endif /* PURDUE */
*-*-END-of-maskbits.h.patch-*-*
echo x - mfb.h.patch
sed 's/^X//' >mfb.h.patch <<'*-*-END-of-mfb.h.patch-*-*'
X*** /tmp/,RCSt1a01523 Wed Jan 18 23:14:56 1989
X--- ddx/mfb/mfb.h Tue Jan 17 23:39:05 1989
X***************
X*** 1,3 ****
X--- 1,4 ----
X+ /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
X /***********************************************************
X Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
X and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X***************
X*** 249,254 ****
X--- 250,256 ----
X #define fnNAND(src, dst) (~(src & dst))
X #define fnSET(src, dst) (~0)
X
X+ #ifndef PURDUE
X /* Binary search to figure out what to do for the raster op. It may
X * do 5 comparisons, but at least it does no function calls
X * Special cases copy because it's so frequent
X***************
X*** 270,275 ****
X--- 272,346 ----
X (((alu) >= GXandReverse) ? \
X (((alu) == GXandReverse) ? ((src) & ~(dst)) : (src)) : \
X (((alu) == GXand) ? ((src) & (dst)) : 0))) ) )
X+ #else /* PURDUE */
X+ /* Using a "switch" statement is much faster in most cases
X+ * since the compiler can do a look-up table or multi-way branch
X+ * instruction, depending on the architecture. The result on
X+ * A Sun 3/50 is at least 2.5 times faster, assuming a uniform
X+ * distribution of RasterOp operation types.
X+ *
X+ * However, doing some profiling on a running system reveals
X+ * GXcopy is the operation over 99.5% of the time and
X+ * GXcopy is the next most frequent (about .4%), so we make special
X+ * checks for those first.
X+ *
X+ * Note that this requires a change to the "calling sequence"
X+ * since we can't engineer a "switch" statement to have an lvalue.
X+ */
X+ #define DoRop(result, alu, src, dst) \
X+ { \
X+ if (alu == GXcopy) \
X+ result = fnCOPY (src, dst); \
X+ else if (alu == GXxor) \
X+ result = fnXOR (src, dst); \
X+ else \
X+ switch (alu) \
X+ { \
X+ case GXclear: \
X+ result = fnCLEAR (src, dst); \
X+ break; \
X+ case GXand: \
X+ result = fnAND (src, dst); \
X+ break; \
X+ case GXandReverse: \
X+ result = fnANDREVERSE (src, dst); \
X+ break; \
X+ case GXandInverted: \
X+ result = fnANDINVERTED (src, dst); \
X+ break; \
X+ case GXnoop: \
X+ result = fnNOOP (src, dst); \
X+ break; \
X+ case GXor: \
X+ result = fnOR (src, dst); \
X+ break; \
X+ case GXnor: \
X+ result = fnNOR (src, dst); \
X+ break; \
X+ case GXequiv: \
X+ result = fnEQUIV (src, dst); \
X+ break; \
X+ case GXinvert: \
X+ result = fnINVERT (src, dst); \
X+ break; \
X+ case GXorReverse: \
X+ result = fnORREVERSE (src, dst); \
X+ break; \
X+ case GXcopyInverted: \
X+ result = fnCOPYINVERTED (src, dst); \
X+ break; \
X+ case GXorInverted: \
X+ result = fnORINVERTED (src, dst); \
X+ break; \
X+ case GXnand: \
X+ result = fnNAND (src, dst); \
X+ break; \
X+ case GXset: \
X+ result = fnSET (src, dst); \
X+ break; \
X+ } \
X+ }
X+ #endif /* PURDUE */
X
X
X #define DoRRop(alu, src, dst) \
X***************
X*** 277,279 ****
X--- 348,370 ----
X ((alu) == RROP_WHITE) ? ((dst) | (src)) : \
X ((alu) == RROP_INVERT) ? ((dst) ^ (src)) : \
X (dst))
X+
X+ #ifdef PURDUE
X+ /* A generalized form of a x4 Duff's Device */
X+ #define Duff(counter, block) { \
X+ while (counter >= 4) {\
X+ { block; } \
X+ { block; } \
X+ { block; } \
X+ { block; } \
X+ counter -= 4; \
X+ } \
X+ switch (counter & 3) { \
X+ case 3: { block; } \
X+ case 2: { block; } \
X+ case 1: { block; } \
X+ case 0: \
X+ counter = 0; \
X+ } \
X+ }
X+ #endif /* PURDUE */
*-*-END-of-mfb.h.patch-*-*
exit
--
Mike Wexler(wyse!mikew) Phone: (408)433-1000 x1330
Moderator of comp.sources.x
More information about the Comp.sources.x
mailing list