[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] [Emutos-devel] Emutos and gcc-4.2.2



Thomas Huth wrote:
 Hi!

On Nov 24, 2007 12:34 AM, Vincent Rivière
<vriviere@users.sourceforge.net> wrote:
I would like to speak about another "feature" : alignment.

By default, GCC aligns structure members on 4-byte boundaries, producing
useless 2-byte holes in a structure where longs and shorts are mixed. I
patched it long ago to use a 2-byte default alignment, so no space is
wasted. Some people said that the 68020+ CPU have faster memory access
to longs aligned on 32-bit boundaries. Is it true on Atari computers ?

Yes, on Atari TT and Falcon030. It's true for any system with 68020+, which all have 32 bit data buses.

I've heard that, too, but I am not an expert here ... that's maybe a
better question to the MiNT developers since they are more likely
working on 68030 machines than the folks here on the EmuTOS mailing
list.

I recently discovered another "feature" of GCC. When function arguments
are pushed on the stack, they are aligned on an "int" boundary. When
compiling with -mshort, there is no additional filler. But when -mshort
is not used, pushing a short then a long causes the long to be aligned 2
bytes further. A short filler is inserted between the 2 values. Just
like structure alignment, it seems to me that such alignment is useless
on the Atari platform. I plan to remove this alignment in my next build.

Bad idea.

Well, I think the default size of items that are pushed on the stack
should be sizeof(int).
For example when you have declared following function in one file:

int myfunc(int a, int b)
{
    return a + b;
}

And in another file you call myfunc(3, 5), but there is no prototype
for myfunc before...
... this is perfectly valid C (despite it's ugly due to the missing
prototype), but it will fail as soon as you disable this "filler"
values on the stack. I think it's better not to disable these
"fillers".

Right.

--
  -- Howard Chu
  Chief Architect, Symas Corp.  http://www.symas.com
  Director, Highland Sun        http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP     http://www.openldap.org/project/