RE: [Bluez-devel] Alignment issue

Marcel Holtmann
2004-08-13T09:58:42Z

Hi David,

> These should do it right on all architectures -- I've checked with a gcc
> hacker and verified that at least the get_unaligned() version does the
> right thing on both FR-V and i386. On FR-V it loads each byte and shifts
> it into place, while on i386 it just loads it.
>
> #define get_unaligned(ptr) \
> ({ \
> struct __attribute__((packed)) { \
> typeof(*(ptr)) __v; \
> } *__p = (ptr); \
> __p->__v; \
> })
>
> #define put_unaligned(ptr, val) \
> do { \
> struct __attribute__((packed)) { \
> typeof(*(ptr)) __v; \
> } *__p = (ptr); \
> __p->__v = (val); \
> } while(0)

is it verified that this works with every GCC release? Some people still
use a 2.95 or older.

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.