Re: Problems with EGCS 1.1 vs GCC 2.7.2.3

Michael Meissner (meissner@cygnus.com)
Fri, 1 Jan 1999 12:03:15 -0500


On Wed, Dec 30, 1998 at 06:26:05PM +0100, Matthias Andree wrote:
> On Mon, Dec 28, 1998 at 11:42:58PM +0000, Alan Cox wrote:
> > __attribute__((regparm(0))) int printk(const char *, ...)
> >
> > That is needed because a user might turn on register parameter passing too
> > and that would break when called from assembler unless marked with
> > regparm.
>
> Is not that an egcs bug? The ... var stuff requires stack parameters in
> the first place (for that <stdargs.h> va_* stuff) so even with register
> parameter passing, the compiler NEEDS to fall back to stack passing,
> does not it?

As long as you properly prototype the function (which BTW is required by ISO C
for varidic functions), egcs will pass everything on the stack. The code that
does this has been part of the egcs code base since the beginning (of egcs),
though Jeff Law did modify one of the lines on the second of November 1997.
I'm pretty sure I put in the check when I first did the regparm stuff 4+ years
ago for gcc 2.6.x, but I'm not motivated to really dig through the archives any
further.

However, your statement:

... the compiler NEEDS to fall back to stack passing

is only true as it concerns the x86 implementation of varargs. In the 12+
ports I've worked on with GCC, the majority of systems pass varadic arguments
in registers. Some of them in fact make the handling of varardic arguments
fairly complecated at runtime (the PowerPC System V ABI which is used in Linux
and eABI situations is an example of this).

Also, regarding the prototyping rule, I have worked on ports which pass
arguments completely differently for varadic functions as opposed to normal
functions, which means you must always include stdio.h for instance in order to
call printf.

-- 
Michael Meissner, Cygnus Solutions (Massachusetts office)
4th floor, 955 Massachusetts Avenue, Cambridge, MA 02139, USA
meissner@cygnus.com,	617-354-5416 (office),	617-354-7161 (fax)

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/