From ece2fea13db64b72fa79e093ca7679e7a491fdd3 Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Mon, 7 Jun 2004 20:44:19 +0000 Subject: Correctly handle an unaligned long long parameter on stack in varargs functions; makes some rare situations in the a.out ar working again. --- sys/arch/m88k/include/va-m88k.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'sys/arch/m88k/include/va-m88k.h') diff --git a/sys/arch/m88k/include/va-m88k.h b/sys/arch/m88k/include/va-m88k.h index e076b50299c..ff418f05ecd 100644 --- a/sys/arch/m88k/include/va-m88k.h +++ b/sys/arch/m88k/include/va-m88k.h @@ -1,4 +1,4 @@ -/* $OpenBSD: va-m88k.h,v 1.2 2004/05/19 21:40:30 miod Exp $ */ +/* $OpenBSD: va-m88k.h,v 1.3 2004/06/07 20:44:18 miod Exp $ */ /* Define __gnuc_va_list. */ @@ -21,6 +21,8 @@ typedef struct __va_list_tag { __extension__ ({ \ (AP) = (struct __va_list_tag *)__builtin_alloca(sizeof(__gnuc_va_list)); \ __builtin_memcpy ((AP), __builtin_saveregs (), sizeof(__gnuc_va_list)); \ + if ((AP)->__va_arg > 8) \ + (AP)->__va_stk += ((AP)->__va_arg - 8); \ }) #ifdef _STDARG_H /* stdarg.h support */ @@ -64,6 +66,10 @@ __extension__(*({ \ __ptr = (TYPE *) (void *) ((AP)->__va_reg + \ (AP)->__va_arg - __va_size(TYPE)); \ } else { \ + if (((unsigned int)((AP)->__va_stk) & 4) != 0 && \ + __alignof__(*(TYPE *)0) > 4) { \ + (AP)->__va_stk++; \ +} \ __ptr = (TYPE *) (AP)->__va_stk; \ (AP)->__va_stk += __va_size(TYPE); \ } \ -- cgit v1.2.3