[Olsr-dev] alignment problems on FreeBSD-arm with inbuf and msg_buffer

John Hay (spam-protected)
Mon Mar 23 13:46:36 CET 2009


On Mon, Mar 23, 2009 at 01:34:05PM +0100, Henning Rogge wrote:
> On Montag 23 M?rz 2009 13:24:18 John Hay wrote:
> > Hi,
> >
> > Trying to get the latest 0.5.6 tip working on FreeBSD-current on an ARM
> > processor, I encountered bus errors which I traced back to the inbuf
> > and msg_buffer arrays that are non-aligned and cause the bus error as
> > soon as a 16 bit or 32 bit variable is read or written to it.
> >
> > I do not understand why I have not encountered it before because it
> > looks like inbuf and msg_buffer has been like that for some time.
> > Maybe the compiler changed or the functions used to access those
> > variables.
> >
> > My fix was to put the arrays in an union with an int. Is there a
> > better way?
> What do you think about this ?
> 
> > -static char inbuf[MAXMESSAGESIZE + 1];
> > +static uint32_t inbuf_alinged[(MAXMESSAGESIZE+4)/sizeof(uint32_t)];
> > +static char *inbuf = (char *)inbuf_aligned;

That would also work.

John
-- 
John Hay -- (spam-protected) / (spam-protected)




More information about the Olsr-dev mailing list