Re: usb: descriptor structures have to be packed

"Phil Endecott" <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
David Brownell wrote:
> On Wednesday 07 February 2007 10:41 am, Phil Endecott wr
>> void inc(int* i) {
>>    (*i)++;
>> }

>> here's a quote from Paul Brook (http://gcc.gnu.org/ml/gcc-help/2006-12/msg00115.html):
>> 
>>    " the compiler is allowed to assume that the low 2 bits of an int* 
>> are zero. "
>
> Unless it's declared as packed ... a fact which is 100% clear in the
> definition of "packed".

Dave, how would you propose to re-write my "inc" function (above) to 
declare i as a "packed int*"?  I have tried various things like

void inc(int __attribute__((packed)) * i)
void inc(int * __attribute__((packed)) i)
void inc(int * i __attribute__((packed)))
void inc(int __attribute__((aligned(1))) * i)
void inc(int * __attribute__((aligned(1))) i)
void inc(int * i __attribute__((aligned(1))))

and I get variously

warning: ‘packed’ attribute ignored
error: alignment may not be specified for ‘i’

or no message at all, and I only ever get loadword-add-storeword code 
generated.  My feeling is that there is no way to declare a "packed" or 
"unaligned" pointer to an int, and so Paul is right.

Phil.

-------------------------------------------------------------------------
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.