RE: [Bluez-devel] Alignment issue

Marcel Holtmann
2004-08-12T09:27:14Z

Hi David,

> > this is what the Linux kernel is using and we will notice it if some
> > compiler version will optimize it in future. I committed that change to
> > CVS.
>
> The Linux kernel isn't the best example to follow when it comes to
> relying on undocumented and unguaranteed compiler behaviour. Don't be so
> sure the kernel would notice -- we have to fix up alignment trap in the
> kernel _anyway_ so the use of get_unaligned() is only an optimisation
> there.
>
> I'd be more inclined to play with using char * pointers in the memcpy,
> and/or __attribute__((packed)).

I am not an expert when it comes to specific compiler stuff and I can't
make the best decision with my limited information. What I realized is
that we need our own unaligned access implementation, because we can't
rely on the asm/unaligned.h. So I started to put our own in bluetooth.h
for general access. If this was wrong, please correct me.

Some platforms can do unaligned access by themself and some are not. At
the moment only the i386 is listed, but we should list others like AMD64
and PowerPC. Patches and hints are welcome. For the rest the generic way
is to use memcpy, but actually every architecture uses memmove, because
of the GCC __builtin_memcpy problem. Some of them like Alpha and ARM are
using specific implementations, but using the macro with memmove seems
also to work fine there. I like to keep the unaligned macros as short as
possible.

Do anyone wrote an autoconf macro for checking if memmove works like
expected or if it gets optimized by the compiler?

Regards

Marcel

-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.