I need to read raw data from a OS preference resource. On OS4 machines, it's simply a matter of locking down the returned resource handle and casting it to the appropriate OS-defined structure pointer. However, on OS5, ARM alignment and byte ordering take effect, so it becomes more difficult.

I have learned so far:

1) You must byte-swap 16-bit and 32-bit values
2) ARM enforces DWord alignment

I understand and can do #1, no problem. I can't wrap my head around "DWord alignment", however. Does this mean that any value that is smaller than a 32 bits ALWAYS becomes padded with enough zeros to make it 32 bits? So this structure:

struct {
UInt8  byVal1;
UInt8  byVal2;
UInt8  byVal3;
}

would occupy 32 + 32 + 32 bits?

Or does the compiler just pad an extra 8 bits to the structure? Exactly where do these extra bits go? What if we had:

struct {
UInt8 byVal1;
UInt8 byVal2;
UInt8 byVal3;
UInt16 wVal4;
UInt8 byVal5;
}

Is there some online reference manual or FAQ somewhere that might lay down the law for this? I would very much appreciate it!

Thanks,
-Jeff


-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/

Reply via email to