Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Jul 1996 23:15:25 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@zeta.org.au, jau@aphrodite.funet.fi
Cc:        hackers@freebsd.org
Subject:   Re: POSIX.4 signals + other POSIX.4 stuff to FreeBSD...
Message-ID:  <199607011315.XAA27282@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>> >> >	void	(*sa_handler) _P((int, ...));
>> 
>> >	then some" implementation. Those dots were put there just to keep
>> >	the compiler quiet when I needed the BSD style extended argument
>> >	list. They don't break anything really, but for reasons of strict
>> 
>> They break the possibility of compiling (all) applications with -mrtd on
>> i386's, and they break implementations where the equivalent of -mrtd or
>> some other complicated (efficient) arg passing convention is standard.

>	How do you think one could compile a signal handler to assume
>	there is the size of the argument list saved in the stack if the
>	system does not use the same convention?

The kernel has to know the convention(s) used by applications.
Nonstandard ones could be specified using special sigaction flags.

I just tried -mrtd (for the i386 gcc-2.6.3).  It seems to imply
-mregparm, and -mno-regparm doesn't affect this.

>	If both the system and the signal handlers have been compiled to
>	use the same calling convention the stack pointer will be modified
>	correctly anyway independent of whether the calling method expects
>	ret or rtd to be used.

Except possibly with your union :-).  It gives multiple conventions that
are different in practice if -mrtd or maybe -mregparm is used, and
FreeBSD only supports one convention.

>	A system using rtd return convention would be expected to save the
>	correct size of the argument list in the stack anyway. Right?

No, it would be expected to be fully prototyped so that the callee
always knows the number of args for non-varargs functions and the caller
and the callee agree which functions are varargs so that only the caller
cleans up the args for varargs functions.  Passing the size of the args
would usually be larger and slower than cleaning up the args in the
caller in all cases.

This is one reason why sa_handler shouldn't be varargs.  The kernel must
pass exactly the right number of args so that cleaning up the args in
the callee can work.

>	BTW - As far as I know -mrtd has no meaning on iX86 machines. It is
>	a valid option only for 680X0 family of processors.

It has always sort of worked for i386's and seems to be fully supported
in gcc-2.7.2 because it is a standard Windows NT convention.  2.7.2 also
has new attributes "stdcall" which gives per-function callee-pop, "regparm"
which gives per-function args in registers, and "cdecl" which cancels any
-mregparm -mrtd to give the "normal" (slow) C calling convention.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199607011315.XAA27282>