Re: [gamin] [patch] gamin bus error on sparc



On Thu, Sep 08, 2005 at 12:30:02PM -0400, Daniel Veillard wrote:
> On Fri, Aug 26, 2005 at 07:46:03PM +0200, Sjoerd Simons wrote:
> > Hi
> > 
> >   In gam_connection.c gam_connection_data shifts the GAMPacketPtr over the
> >   request buffer. This can cause the req pointer to be unaligned.
> > 
> >   Although that works fine on x86 and some other archs, on a sparc it causes
> >   a bus error when accessing it's len field.
> > 
> >   Patch with a fix attached.
> 
>   I realized I didn't processed your patch. While Unaligned accesses
> can be extremely expensive or prohibited on some arches on others the
> penalty is quite lower than memmov'ing the whole set of data read 
> each time a new fragment is processed. So I would really prefer a 
> patch conditional to your architecture. But I can't test it and
> I'm not sure #ifdef sparc is a portable macro for this. Can you check ?

Afaik #ifdef __sparc__ is portable.. But i would suggest doing it the other
way around. That is do memmov by default and only use potential unaligned
access on arch where it's known to be allowed and cheap enough. 

Patch attached which does potentially unalligned access on i386 and memmove on
others.

  Sjoerd
-- 
Quantum Mechanics is a lovely introduction to Hilbert Spaces!
		-- Overheard at last year's Archimedeans' Garden Party
Index: server/gam_connection.c
===================================================================
RCS file: /cvs/gnome/gamin/server/gam_connection.c,v
retrieving revision 1.26
diff -u -r1.26 gam_connection.c
--- server/gam_connection.c	8 Sep 2005 10:12:03 -0000	1.26
+++ server/gam_connection.c	9 Sep 2005 12:53:21 -0000
@@ -499,8 +499,11 @@
         conn->request_len -= req->len;
         if (conn->request_len == 0)
             break;
-
+#if defined (__i386__)  
 	req = (void *) req + req->len;
+#else
+	memmove(&conn->request, (void *)req + req->len, conn->request_len);
+#endif
     }
 
     if (conn->request_len > 0 && req != &conn->request)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]