Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Harald Koenig <koenig@tat.physik.uni-tuebingen.de>
Subject: one more alignment trap
Date: Tue, 7 May 1996 09:56:32 +0200 (MET DST)	[thread overview]
Message-ID: <9605070748.AA16866@nova.tat.physik.uni-tuebingen.de> (raw)

my first fix for s3im.c wasn't sufficient.  there may be odd addresses
too which was showed by some "x11perf" runs last night.

so here is a more gerenal (and ugly) fix relative to the original sources.
I havent tested this one (only compiled,not run yet) so look at it 
and be careful.

Harald
-------------------------------------------------------------------------------
--- /soft/r6/xc/programs/Xserver/hw/xfree86/accel/s3/s3im.c.Df	Sun Apr 28 23:56:35 1996
+++ /soft/r6/xc/programs/Xserver/hw/xfree86/accel/s3/s3im.c	Tue May  7 09:49:40 1996
@@ -882,7 +882,7 @@
       short *psrcs = (short *)&psrc[px*s3Bpp];
       for (i = 0; i < w; ) {
 	 if (s3InfoRec.bitsPerPixel == 32) {
-	    outl (PIX_TRANS, *((long*)(psrcs)));
+	    outl (PIX_TRANS, *((int*)(psrcs)));
 	    psrcs+=2;
 	    i += 4;
 	 }
@@ -1164,11 +1164,48 @@
 				       ((unsigned char *)(ptmp) + (srcx >> 3));
 		    x2 = srcx & 7;		/* Offset within byte. */
 		    if( np >= 16 ) {
+#ifdef __alpha__ /* alignment check */
+		      switch ((long)pnt & 3) {
+		      case 0:
 			pix = (unsigned short)(*((unsigned int *)(pnt)) >> x2);
+			break;
+		      case 2:
+			pix = (unsigned short)((*pnt | (*(pnt+1)<<16)) >> x2);
+			break;			  
+		      default:
+			pix = (unsigned short)(( ((unsigned char *)(pnt))[0]<<0  |
+						 ((unsigned char *)(pnt))[1]<<8  |
+						 ((unsigned char *)(pnt))[2]<<16 |
+						 ((unsigned char *)(pnt))[3]<<24 ) >> x2);
+			break;
+		      }
+#else
+		      pix = (unsigned short)(*((unsigned int *)(pnt)) >> x2);
+#endif
 		    }
 		    else if( pw >= 16 ) {
+#ifdef __alpha__ /* alignment check */
+		      switch ((long)pnt & 3) {
+		      case 0:
 			pix = (unsigned short)((*((unsigned int *)(pnt)) >> x2)
-						 & MSKBIT(np)) | (*ptmp << np);
+					       & MSKBIT(np)) | (*ptmp << np);
+			break;
+		      case 2:
+			pix = (unsigned short)(((*pnt | (*(pnt+1)<<16)) >> x2)
+					       & MSKBIT(np)) | (*ptmp << np);
+			break;			  
+		      default:
+			pix = (unsigned short)(((((unsigned char *)(pnt))[0]<<0  |
+						 ((unsigned char *)(pnt))[1]<<8  |
+						 ((unsigned char *)(pnt))[2]<<16 |
+						 ((unsigned char *)(pnt))[3]<<24 ) >> x2)
+					       & MSKBIT(np)) | (*ptmp << np);
+			break;
+		      }
+#else
+		      pix = (unsigned short)((*((unsigned int *)(pnt)) >> x2)
+					     & MSKBIT(np)) | (*ptmp << np);
+#endif
 		    }
 		    else if( pw >= 8 ) {
 			pix = ((*pnt >> x2) & MSKBIT(np)) | (*ptmp << np)
-------------------------------------------------------------------------------

-- 
All SCSI disks will from now on                     ___       _____
be required to send an email notice                0--,|    /OOOOOOO\
24 hours prior to complete hardware failure!      <_/  /  /OOOOOOOOOOO\
                                                    \  \/OOOOOOOOOOOOOOO\
                                                      \ OOOOOOOOOOOOOOOOO|//
Harald Koenig,                                         \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik                              //  /     \\  \
koenig@tat.physik.uni-tuebingen.de                     ^^^^^       ^^^^^

                 reply	other threads:[~1996-05-07  7:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox