Re: Plan needed for switching m68k to 32-bit alignment

Thorsten Glaser <[email protected]>
Newsgroups gmane.linux.ports.m68k,gmane.linux.debian.ports.68k
Message-ID <[email protected]>
Finn Thain dixit:

>That would mean __alignof__(foo.b) == sizeof(foo.b) but that's not the
>case on my Linux/i686 system. 4 != 8:
>
>struct baa {
>        int a;
>        long long b;
>} foo;

That struct is just 12 bytes for you then?

That’s possible on i386 but almost nowhere else, and has multiple
penalties on i386 even (cacheline split, loss of atomicity, merging
of accesses, possible cross-page split, …).

Of course, in this case, the software author ought to have made the
padding explicit or, better, sorted the struct members. But if all
did that we wouldn’t have this problem.

>> More importantly, and relevant for Qt, struct baa is also 8-byte
>> aligned...
>
>If the struct itself is not naturally aligned, it too will eventually
>break someone's assumption of natural alignment.

No, structs are not naturally aligned but aligned to the max() of
the alignment of its members. Natural alignment is only applied to
primitive types.

bye,
//mirabilos
-- 
If Harry Potter gets a splitting headache in his scar
when he’s near Tom Riddle (aka Voldemort),
does Tom get pain in the arse when Harry is near him?
	-- me, wondering why it’s not Jerry Potter………
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.