Re: Unaligned access question

Andreas Schwab
2003-09-25T08:32:25Z

[-- Attachment #1: Type: text/plain, Size: 980 bytes --]

Martin Pool <mbp@samba.org> writes:

> On 25 Sep 2003, Ian Wienand <ianw@gelato.unsw.edu.au> wrote:
>> Hi,
>>
>> This isn't directly related to kernel development, but I am a bit
>> stumped as to why my test program below causes an unaligned access
>> when 'i' is 7 (that is, when it tries to access across a 64 bit
>> boundary of 'array'). It's counter intuitive to me, I would have
>> expected it either fault on all loads (for every value of 'i') or to
>> have not faulted at all.
>
> I think adding
>
> __attribute__ ((aligned (1)))

You cannot decrease alignment with the aligned attribute, for that you
need the packed attribute. This sets alignment to 1, which you can
increase again with the aligned attribute.

Andreas.

--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."

[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]