Fix va_arg for structures larger than 8 bytes.

From-SVN: r2089
This commit is contained in:
Michael Meissner 1992-09-09 14:12:07 +00:00
parent f167e25de4
commit 027b4a722d

View File

@ -29,29 +29,31 @@ typedef char * __gnuc_va_list;
#define __va_ellipsis
#endif
#define __va_rounded_size(TYPE) \
(((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
#define __va_rounded_size(__TYPE) \
(((sizeof (__TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
#ifdef _STDARG_H
#define va_start(AP, LASTARG) \
(AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG)))
#define va_start(__AP, __LASTARG) \
(__AP = ((char *) &(__LASTARG) + __va_rounded_size (__LASTARG)))
#else
#define va_alist __builtin_va_alist
#define va_dcl int __builtin_va_alist; __va_ellipsis
#define va_start(AP) AP = (char *) &__builtin_va_alist
#define va_start(__AP) __AP = (char *) &__builtin_va_alist
#endif
void va_end (__gnuc_va_list); /* Defined in libgcc.a */
#define va_end(AP)
#define va_end(__AP)
#ifdef lint /* complains about constant in conditional context */
#define va_arg(list, mode) ((mode *)(list += sizeof(mode)))[-1]
#define va_arg(list, mode) ((mode *)(list += __va_rounded_size(mode)))[-1]
#else /* !lint */
#define va_arg(AP, mode) \
((mode *)(AP = (char *) (__alignof(mode) > 4 \
? ((int)AP + 2*8 - 1) & -8 \
: ((int)AP + 2*4 - 1) & -4)))[-1]
#define va_arg(__AP, __type) \
((__type *)(__AP = (char *) ((__alignof(__type) > 4 \
? ((int)__AP + 8 - 1) & -8 \
: ((int)__AP + 4 - 1) & -4) \
+ __va_rounded_size(__type))))[-1]
#endif /* lint */
#endif /* defined (_STDARG_H) || defined (_VARARGS_H) */