Path: utzoo!attcan!uunet!yale!husc6!purdue!spaf From: spaf@cs.purdue.EDU (Gene Spafford) Newsgroups: comp.windows.x Subject: Speedups for X11.2 Xsun (CORRECTION) Message-ID: <4219@medusa.cs.purdue.edu> Date: 28 May 88 06:35:10 GMT References: <4211@medusa.cs.purdue.edu> Reply-To: spaf@cs.purdue.edu (Gene Spafford) Organization: Department of Computer Science, Purdue University Lines: 108 Adam de Boor (deboor@nutmeg.berkeley.edu) has pointed out to us that some braindamaged compilers may not like some of the code we changed in maskbits.h (the IBM RT was an example he gave). Since we're using well-behaved compilers, we'll take his word on that. He suggested some restatements of the code to avoid those bugs, and since they have the same effect as our code without adding extra operations, we'll present them so our enhancements work for everyone's machines. Adam also pointed out a small flaw in what we did in putbits (which we never triggered in our testing, it appears), and a fix for that is included as well. Thus, use the following as the patch to maskbits.h rather than the one we posted yesterday. *** maskbits.h.orig Wed May 25 22:38:33 1988 --- maskbits.h Sat May 28 01:28:45 1988 *************** *** 28,35 **** --- 28,39 ---- extern int starttab[]; extern int endtab[]; + #ifndef PURDUE extern int startpartial[]; extern int endpartial[]; + #else PURDUE + extern unsigned partmasks[32][32]; + #endif PURDUE extern int rmask[32]; extern int mask[32]; *************** *** 206,213 **** --- 210,222 ---- else \ nlw = (w) >> 5; + #ifndef PURDUE #define maskpartialbits(x, w, mask) \ mask = startpartial[(x) & 0x1f] & endpartial[((x) + (w)) & 0x1f]; + #else PURDUE + #define maskpartialbits(x, w, mask) \ + mask = partmasks[(x)&0x1f][(w)&0x1f]; + #endif PURDUE #define mask32bits(x, w, startmask, endmask) \ startmask = starttab[(x)&0x1f]; \ *************** *** 214,219 **** --- 223,230 ---- endmask = endtab[((x)+(w)) & 0x1f]; + #ifndef PURDUE + #define getbits(psrc, x, w, dst) \ if ( ((x) + (w)) <= 32) \ { \ *************** *** 244,249 **** --- 255,293 ---- *(pdst) = (*(pdst) & endtab[x]) | (SCRRIGHT(src, x) & starttab[x]); \ *((pdst)+1) = (*((pdst)+1) & starttab[n]) | (SCRLEFT(src, m) & endtab[n]); \ } + + #else PURDUE + #define getbits(psrc, x, w, dst) \ + if ( ((x) + (w)) <= 32) \ + { \ + dst = SCRLEFT((unsigned) *(psrc), (x)); \ + } \ + else \ + { \ + dst = (SCRLEFT((unsigned) *(psrc), (x))) | \ + (SCRRIGHT((unsigned) *((psrc)+1), 32-(x))); \ + } + + #define putbits(src, x, w, pdst) \ + { \ + int n = (x)+(w)-32; \ + if (n <= 0) \ + { \ + unsigned tmpmask; \ + maskpartialbits((x), (w), tmpmask); \ + *(pdst) = (*(pdst) & ~tmpmask) | \ + (SCRRIGHT((unsigned) src, x) & tmpmask); \ + } \ + else \ + { \ + unsigned int *ptmp_ = (pdst)+1; \ + int m = 32-(x); \ + *(pdst) = (*(pdst) & endtab[x]) | (SCRRIGHT((unsigned) (src), x)); \ + *ptmp_ = (*ptmp_ & starttab[n]) | \ + (SCRLEFT((unsigned) src, m) & endtab[n]); \ + } \ + } + #endif PURDUE #define putbitsrop(src, x, w, pdst, rop) \ if ( ((x)+(w)) <= 32) \ -- Gene Spafford NSF/Purdue/U of Florida Software Engineering Research Center, Dept. of Computer Sciences, Purdue University, W. Lafayette IN 47907-2004 Internet: spaf@cs.purdue.edu uucp: ...!{decwrl,gatech,ucbvax}!purdue!spaf