R2000 stack alignment question
Bent Hagemark
bh at sgi.com
Fri May 31 06:01:22 AEST 1991
In article <9105281723.AA11513 at crow.omni.co> rpaul at crow.UUCP (Rodian Paul) writes:
>> After some hours of digging through assembly code I've finally found out
>> that varargs.h depends on the stack being aligned to an 8-byte boundary,
>> and the C compiler does its utmost to keep it like that (unlike me).
>>
>Don't use varargs(5) it is non-standard, use stdarg(5) instead if you want
>portabilty via ANSI C.
Absolutely (use stdarg(5)). The following is from the 4.0 stdarg(5) man page:
The va_start (ap, ParmN) macro initializes ap for subsequent use by
va_arg and va_end. va_start must be called before any use of va_arg.
* The ANSI C Standard (ANSI X3.159-1989) restricts the type of parmN to one
* of the types resulting from the default argument promotions, currently
* int, unsigned int, pointer, or double. If va_start is invoked with a
* parmN which is not one of these types (e.g., if parmN is short or char)
* the behavior is undefined.
After learing this the hard way I asked that the *'ed lines be added
to the stdarg(5) man page.
The default argument promotion rules are described in section 2.7
of K&R C, 2nd Edition.
Bent
More information about the Comp.sys.sgi
mailing list