Subject: Re: unaligned access: how to track ?
To: Manuel Bouyer <bouyer@antioche.lip6.fr>
From: Chris G. Demetriou <cgd@netbsd.org>
List: port-alpha
Date: 06/07/2000 10:07:12
Manuel Bouyer <bouyer@antioche.lip6.fr> writes:
> Hum ok, so we should pad the key to the alignement required by the
> architecture.

uh...

As far as the 'db' API is concerned, it can return keys/data at random
offsets, completely disregarding the alignment of anything you supply.

No amount of padding you do on the input side will help that (because
who knows what it's packing them _against_, for all you know it's got
some internal structures that it uses which really are byte
strings... at least, it's allowed to).

The only solution is to copy the data after lookup, before accessing
them, if they're not aligned.  You can use ALIGN to help you check
this (but that's not portable code, if you care), or you can do the
conservative thing and always copy.


cgd
-- 
Chris Demetriou - cgd@netbsd.org - http://www.netbsd.org/People/Pages/cgd.html
Disclaimer: Not speaking for NetBSD, just expressing my own opinion.