diff options
author | phk <phk@FreeBSD.org> | 1997-02-07 20:22:15 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1997-02-07 20:22:15 +0000 |
commit | 27e71d1e4801443f6b036937c234d526fe50bf97 (patch) | |
tree | 23749b2a8c573f2b06163588d5f83fdaab063de4 /sys/i386/include/varargs.h | |
parent | 66962bcc3da4afa0d7f918d7addd5dc8d6437a8d (diff) | |
download | FreeBSD-src-27e71d1e4801443f6b036937c234d526fe50bf97.zip FreeBSD-src-27e71d1e4801443f6b036937c234d526fe50bf97.tar.gz |
I have no idea what this is all about, but it works and Bruce hasn't
complained so it cannot be entirely bad :-)
I include the email that probably explains it for people who already know:
> >Compiling with -O3 inlines functions. However the function that is being
> >inlined in makeinfo.c (add_word_args()) is a vararg function and must not be
> >inlined.
> >
> >The code in question is K&R style, and AFIK, there is no way for the compiler
> >to determine that the function uses vararg. Either change the code to use
> >prototypes, or use stdarg, or add a directive to prevent inlining.
>
> Not declaring a varargs function as varargs before it is used gives
> undefined behaviour.
>
> However, in practice the bug is probably in FreeBSD's <varargs.h>, which
> doesn't use gcc's __builtin_next_arg(). gcc should notice that it is
> used and not inline functions that have it. <stdarg.h.> uses it, but I
> think there's another gcc builtin that it should be using.
Patch attached. The ellipsis causes gcc to flag this as a varargs function,
and the name "__builtin_va_alist" is special cased in gcc to hide the last
argument in the arglist.
Reviewed by: bde & phk
Submitted by: jlemon@americantv.com (Jonathan Lemon)
Diffstat (limited to 'sys/i386/include/varargs.h')
-rw-r--r-- | sys/i386/include/varargs.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/i386/include/varargs.h b/sys/i386/include/varargs.h index 8f16773..b213d88 100644 --- a/sys/i386/include/varargs.h +++ b/sys/i386/include/varargs.h @@ -44,7 +44,12 @@ typedef char *va_list; -#define va_dcl int va_alist; +#ifdef __GNUC__ +#define va_alist __builtin_va_alist +#define va_dcl int va_alist; ... +#else /* !__GNUC__ */ +#define va_dcl int va_alist; +#endif #define va_start(ap) \ ap = (char *)&va_alist |