Boltar wrote:
>
On Mar 20, 11:39 am, jacob navia <ja...@nospam.c omwrote:
Boltar wrote:
If I use #pragma pack to byte align structures to non word size , will
this cause the program to run slightly slower if it is accessing and
setting non word aligned integers etc in the struct?
yes
Is there any
realignment going on silently underneath when the var is read and
written to memory?
no
I presume it must use 2 seperate get/put operations for a variable
crossing a word boundary then?
"Best case scenario", probably.
However, there are other possibilities. Some hardware simply doesn't
allow such access, and causes an interrupt. On some platforms, this
will cause the program to crash. On others, the O/S will emulate the
unaligned access ability in the interrupt handler. For example, on
an unaligned read, it will read the two aligned chunks, pull out the
bits that you wanted, put then in the destination, and return from
the interrupt handler. (Hardly a simple "2 bus reads" degradation
in efficiency.)
You may want to look back at why you feel you need to pack the
structs.
--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody |
www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net |
www.fptech.com | <std_disclaimer .h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th***** ********@gmail. com>