[comp.windows.x] Patch failure for Purdue speedups

jepeway@rastaban.cs.utk.edu (Chris Jepeway) (12/19/88)

I just ftp'ed the Purdue mfb speedups down and tried applying the patches.
Hunk #11 failed for the patch to ./ddx/mfb/mfbline.c.  I've tried the -l option
and fudge factors up to 6 without luck.  I've even tried to apply the patch by
hand with a text editor, and I'm too poor a Sorceror's Apprentice to get it
right.  Any help would be appreciated.

C. Jepeway
Systems Programmer
University of TN, Knoxville

phil@BRL.MIL (Phil Dykstra) (12/20/88)

In the PURDUE speedups patch for ./ddx/mfb/mfbline.c there were a couple
of curly braces indented differently in the version Gene Spafford diffed
against than in the original MIT code.  Their location was such that
patch looses context (they were immediately after some inserted code).

Below is a new patch file for mfbline.c that corrects the indentation
problem that causes patch to fail.  I reported this to Gene a week or
so ago but got no response.  He could do the world (another) favor by
updating the file on expo.  Hope this helps.

- Phil
<phil@brl.mil>
uunet!brl!phil

Apply this one INSTEAD OF (not in addition to) the one in the Purdue patches.
===========================
*** ./ddx/mfb/mfbline.c.orig	Tue Sep  6 14:53:25 1988
--- ./ddx/mfb/mfbline.c	Mon Dec  5 12:36:50 1988
***************
*** 110,116 ****
--- 110,120 ----
  #define round(dividend, divisor) \
  ( (((dividend)<<1) + (divisor)) / ((divisor)<<1) )
  
+ #ifndef PURDUE
  #define ceiling(m,n) ( ((m) + (n) -1)/(n) )
+ #else
+ #define ceiling(m,n)  (((m)-1)/(n) + 1)
+ #endif  /* PURDUE */
  
  #define SignTimes(sign, n) ((sign) * ((int)(n)))
  
***************
*** 119,124 ****
--- 123,129 ----
      ( ((sign)<0) ? -(n) : (n) )
  */
  
+ #ifndef PURDUE
  #define SWAPPT(p1, p2, pttmp) \
  pttmp = p1; \
  p1 = p2; \
***************
*** 129,134 ****
--- 134,155 ----
  i = j; \
  j = t;
  
+ #else
+ #define SWAPINT(i, j) \
+ {  register int _t = i; \
+    i = j; \
+    j = _t; \
+ }
+ 
+ #define SWAPPT(i, j) \
+ {  register DDXPointRec _t; \
+    _t = i; \
+    i = j; \
+    j = _t; \
+ }
+ #endif  /* PURDUE */
+    
+ 
  void
  mfbLineSS(pDrawable, pGC, mode, npt, pptInit)
      DrawablePtr pDrawable;
***************
*** 200,210 ****
--- 221,235 ----
      nptTmp = npt;
      if (mode == CoordModeOrigin)
      {
+ #ifndef PURDUE
  	while(nptTmp--)
  	{
  	    ppt->x += xorg;
  	    ppt++->y += yorg;
  	}
+ #else
+ 	Duff(nptTmp, ppt->x += xorg; ppt++->y += yorg);
+ #endif  /* PURDUE */
      }
      else
      {
***************
*** 211,216 ****
--- 236,242 ----
  	ppt->x += xorg;
  	ppt->y += yorg;
  	nptTmp--;
+ #ifndef PURDUE
  	while(nptTmp--)
  	{
  	    ppt++;
***************
*** 217,222 ****
--- 243,251 ----
  	    ppt->x += (ppt-1)->x;
  	    ppt->y += (ppt-1)->y;
  	}
+ #else
+ 	Duff(nptTmp, ppt++; ppt->x += (ppt-1)->x; ppt->y += (ppt-1)->y);
+ #endif  /* PURDUE */
      }
  
      ppt = pptInit;
***************
*** 235,240 ****
--- 264,272 ----
  	    */
  	    if (pt1.y > pt2.y)
  	    {
+ #ifdef PURDUE
+ 		register int tmp;
+ #endif
  		tmp = pt2.y;
  		pt2.y = pt1.y + 1;
  		pt1.y = tmp + 1;
***************
*** 277,282 ****
--- 309,317 ----
  	    */
  	    if (pt1.x > pt2.x)
  	    {
+ #ifdef PURDUE
+ 		register int tmp;
+ #endif
  		tmp = pt2.x;
  		pt2.x = pt1.x + 1;
  		pt1.x = tmp + 1;
***************
*** 308,314 ****
--- 343,353 ----
  		    if (pbox->x1 >= pt2.x)
  		    {
  			nbox = 0;
+ #ifndef PURDUE
  			continue;
+ #else
+ 			break;
+ #endif  /* PURDUE */
  		    }
  
  		    x1 = max(pt1.x, pbox->x1);
***************
*** 440,445 ****
--- 479,485 ----
  	 (ppt->y != pptInit->y) ||
  	 (ppt == pptInit + 1)))
      {
+ #ifndef PURDUE
  	pt1 = *ppt;
  
  	nbox = nboxInit;
***************
*** 469,474 ****
--- 509,553 ----
  	    else
  		pbox++;
  	}
+ #else
+ 	unsigned int _mask;
+ 	int _incr,  _rop = ((mfbPrivGC *)(pGC->devPriv))->rop;
+ 
+ 	pt1 = *ppt;
+ 	if (_rop == RROP_BLACK)
+ 		_mask = rmask[pt1.x & 0x1f];
+ 	else
+ 		_mask = mask[pt1.x & 0x1f];
+ 	_incr = (pt1.y * nlwidth) + (pt1.x >> 5);
+ 
+ 	nbox = nboxInit;
+ 	pbox = pboxInit;
+ 	while (nbox--)
+ 	{
+ 	    if ((pt1.x >= pbox->x1) &&
+ 		(pt1.y >= pbox->y1) &&
+ 		(pt1.x <  pbox->x2) &&
+ 		(pt1.y <  pbox->y2))
+ 	    {
+ 		addrl += _incr;
+ 		switch(_rop)
+ 		{
+ 		    case RROP_BLACK:
+ 		        *addrl &= _mask;
+ 			break;
+ 		    case RROP_WHITE:
+ 		        *addrl |= _mask;
+ 			break;
+ 		    case RROP_INVERT:
+ 		        *addrl ^= _mask;
+ 			break;
+ 		}
+ 		break;
+ 	    }
+ 	    else
+ 		pbox++;
+ 	}
+ #endif  /* PURDUE */
      }
  }
  
***************
*** 570,580 ****
--- 649,663 ----
      nptTmp = npt;
      if (mode == CoordModeOrigin)
      {
+ #ifndef PURDUE
  	while(nptTmp--)
  	{
  	    ppt->x += xorg;
  	    ppt++->y += yorg;
  	}
+ #else
+ 	Duff(nptTmp, ppt->x += xorg; ppt++->y += yorg );
+ #endif  /* PURDUE */
      }
      else
      {
***************
*** 581,586 ****
--- 664,670 ----
  	ppt->x += xorg;
  	ppt->y += yorg;
  	nptTmp--;
+ #ifndef PURDUE
  	while(nptTmp--)
  	{
  	    ppt++;
***************
*** 587,592 ****
--- 671,679 ----
  	    ppt->x += (ppt-1)->x;
  	    ppt->y += (ppt-1)->y;
  	}
+ #else
+ 	Duff (nptTmp, ppt++; ppt->x += (ppt-1)->x; ppt->y += (ppt-1)->y);
+ #endif
      }
  
  
***************
*** 766,774 ****
--- 853,867 ----
  	    clipDone = 1;
  	    if (swapped)
  	    {
+ #ifndef PURDUE
  	        SWAPPT(pt1, pt2, ptTmp);
  	        SWAPINT(oc1, oc2, tmp);
  	        SWAPINT(clip1, clip2, tmp);
+ #else
+ 	        SWAPPT(pt1, pt2);
+ 	        SWAPINT(oc1, oc2);
+ 	        SWAPINT(clip1, clip2);
+ #endif  /* PURDUE */
  	    }
          }
          else /* have to clip */
***************
*** 776,784 ****
--- 869,883 ----
  	    /* only clip one point at a time */
  	    if (!oc1)
  	    {
+ #ifndef PURDUE
  	        SWAPPT(pt1, pt2, ptTmp);
  	        SWAPINT(oc1, oc2, tmp);
  	        SWAPINT(clip1, clip2, tmp);
+ #else
+ 	        SWAPPT(pt1, pt2);
+ 	        SWAPINT(oc1, oc2);
+ 	        SWAPINT(clip1, clip2);
+ #endif  /* PURDUE */
  	        swapped = !swapped;
  	    }