On Tue, Feb 06, 2007 at 11:00:14PM -0800, David Brownell wrote:
> On Tuesday 06 February 2007 5:58 pm, Oleg Verych wrote:
> > 
> > Would you clarify "non aligned access issue" on well known platforms
> > (*x86-*). I see on gcc's output, that they are not carry much about it:
> 
> X86 has hardware logic to handle misaligned access directly.
> Which is why GCC output doesn't pay attention to that issue.

As `C' became `embedded' not so long ago, maybe all this discussion
isn't much on-topic, anyway.


(system programmer) [ C ]  -->  [ ASM ]  -->  [ HEX/BIN ] (CPU)
                           (0)           (1)

You've described (1), what is all good, except one thing:

  while data is being always in *bytes*, access to this data is in
  *words*. So, how large code to handle unaligned access, depends on
  *word* size.

In case (0), i.e "high" level language to assembler: if access size
(word) is always equals to width of the memory bus, than C *must* align
everything to match memory-access layout, small members of structs are
padded (or joined), if possible.

If we will speak about RISC, where all commands are with same size, i.e
toggle bit 3 in port A is, say, 16 bits, `iret' 16 bits also (unlike
there, where i've grow up: 8086 :), to _pad_ and use more RAM was
better, that bloat ROM with code, even if RAM was expensive and in
relatively small (but enough) amounts (case of Harvard architecture, of
course).

But in case of "over-designed" or sometimes just from air data
structures (your "on-the-wire" example), code bloating is *much* more
or hardware gives up with SIGBUS (if compiler also against it).

 
> I mean that using "packed" is not magic, but is simple and easy
> to follow and maintain.  Where that "old style" is complex and
> hard to follow, plus it's error-prone to maintain.

Thus, C compiler on particular platform must be instructed about
"on-the-wire" structures (gcc's packed), if everything else with memory
layout is OK.

And what Phil Endecott told is just a bug in GCC! I don't know if he
tried with and without optimization.

In avr-gcc i had `do {} while()' counting 127 (with strong
optimization) instead of 128.

____

-------------------------------------------------------------------------
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
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to