Subject: Re: CVS commit: syssrc/sys/arch/powerpc/include
To: Todd Vierling <tv@pobox.com>
From: Matt Thomas <matt@3am-software.com>
List: tech-toolchain
Date: 08/07/2002 10:24:29
At 09:13 AM 8/7/2002, Todd Vierling wrote:
>On Wed, 7 Aug 2002, Matt Thomas wrote:
>
>: It is not compatible with GCC 2.95 because the new
>:
>: typedef __builtin_va_list __va_list;
>:
>: only happens on GCC 3.0 or above.  That's what the __GNUC_PREREQ__(3,0)
>: test is doing.  If the compiler is older than GCC 3.0, the old definition is
>: used.  As for it doesn't work, I bootstraped GCC 3.3 with the above diff in
>: place which used the 2.95 for the first stage compile without problems.
>
>Personally, I'd only be curious to make sure that the GCC 3.0 builtin
>definition matches the previous definition -- for the purposes of ABI
>compatibility.  If the ABI matches, there's no problem; if it doesn't match,
>you've created a flag day.  8-)

It does match.  If the va_list was not being passed in the old manner
then the following program would cause a coredump:

#include <stdarg.h>
#include <stdio.h>

int amask = 1;

void
xlog(int a, const char *fmt, ...)
{
         if (a & amask) {
                 va_list ap;
                 va_start(ap, fmt);
                 vprintf(fmt, ap);
                 vprintf(fmt, ap);
                 va_end(ap);
         }
}

main(void)
{
         xlog(1, "%s%s", "Hello ", "World\n");
}

Now since I pass the va_list to vprintf twice, if not being passed by value,
the second vprintf call should break.  It doesn't.  The above program produces
the same output when compiled by either GCC 3.* or GCC 2.95.3 (with libraries
compiled by 2.95.3).  This is on a 1.6D userland.

-- 
Matt Thomas               Internet:   matt@3am-software.com
3am Software Foundry      WWW URL:    http://www.3am-software.com/bio/matt/
Cupertino, CA             Disclaimer: I avow all knowledge of this message