On Wednesday 07 February 2007 3:04 am, Phil Endecott wrote:
> I won't pretend to understand all the subtleties of
> __attribute__((packed)), but I did learn something about it when I
> hacked USB/IP to run on ARM, for the NSLU2, last year. The issue
> boiled down to this:
>
> struct S {
> int intfield;
> char charfield;
> } /* maybe add: __attribute__((packed)) here */ ;
>
> f(struct S * s) {
> ...
> (s->intfield)++;
> ...
> }
>
> ...
>
> What happens when we add __attribute__((packed)) to struct S? ...
> will work, but a lot more slowly. However, the ++ in f() WILL NOT
> WORK! The compiler assumes that the pointer that is passed IS
> NATURALLY ALIGNED, and when you pass an unaligned pointer from g() IT
> DOES NOT ISSUE A WARNING!
Looks like a bug in your version of the toolchain. I just tried
this not a minute ago (gcc 3.4.3) and it works correctly: not only
do both versions of the function handle the "intfield" misaligned
for loads, they also do so for the store.
> Based on my experiece - it took me a long time to debug this -
Compiler bugs are that way, yes. Maybe that was associated with
using the big-endian compile options?
- Dave
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel