From 7b8535b5542931d0a4d82c61397f344f69fbd236 Mon Sep 17 00:00:00 2001 From: cgd Date: Wed, 28 Dec 1994 22:45:42 +0000 Subject: [PATCH] do the right thing with strange-sized varargs objects. --- sys/arch/i386/include/stdarg.h | 5 ++--- sys/arch/i386/include/varargs.h | 8 +++++--- sys/arch/m68k/include/stdarg.h | 8 +++++--- sys/arch/m68k/include/varargs.h | 11 ++++++++--- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/sys/arch/i386/include/stdarg.h b/sys/arch/i386/include/stdarg.h index e42b60b5d827..c3357c436c88 100644 --- a/sys/arch/i386/include/stdarg.h +++ b/sys/arch/i386/include/stdarg.h @@ -1,4 +1,4 @@ -/* $NetBSD: stdarg.h,v 1.6 1994/10/27 04:16:28 cgd Exp $ */ +/* $NetBSD: stdarg.h,v 1.7 1994/12/28 22:45:42 cgd Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -53,8 +53,7 @@ typedef _BSD_VA_LIST_ va_list; ((type *)(ap += sizeof(type)))[-1] #else #define va_arg(ap, type) \ - ((type *)(ap += sizeof(type) < sizeof(int) ? \ - (abort(), 0) : sizeof(type)))[-1] + ((type *)(ap += __va_promote(type), ap - __va_promote(type)))[0] #endif #define va_end(ap) diff --git a/sys/arch/i386/include/varargs.h b/sys/arch/i386/include/varargs.h index 48bd45ae954e..4da205f288d9 100644 --- a/sys/arch/i386/include/varargs.h +++ b/sys/arch/i386/include/varargs.h @@ -1,4 +1,4 @@ -/* $NetBSD: varargs.h,v 1.7 1994/10/27 04:16:33 cgd Exp $ */ +/* $NetBSD: varargs.h,v 1.8 1994/12/28 22:45:43 cgd Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -49,6 +49,9 @@ typedef _BSD_VA_LIST_ va_list; #define va_dcl int va_alist; +#define __va_promote(type) \ + (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int)) + #define va_start(ap) \ ap = (char *)&va_alist @@ -57,8 +60,7 @@ typedef _BSD_VA_LIST_ va_list; ((type *)(ap += sizeof(type)))[-1] #else #define va_arg(ap, type) \ - ((type *)(ap += sizeof(type) < sizeof(int) ? \ - (abort(), 0) : sizeof(type)))[-1] + ((type *)(ap += __va_promote(type), ap - __va_promote(type)))[0] #endif #define va_end(ap) diff --git a/sys/arch/m68k/include/stdarg.h b/sys/arch/m68k/include/stdarg.h index 6a5d086f873d..dec6c69f6590 100644 --- a/sys/arch/m68k/include/stdarg.h +++ b/sys/arch/m68k/include/stdarg.h @@ -1,4 +1,4 @@ -/* $NetBSD: stdarg.h,v 1.7 1994/10/26 07:50:55 cgd Exp $ */ +/* $NetBSD: stdarg.h,v 1.8 1994/12/28 22:45:46 cgd Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -53,8 +53,10 @@ typedef _BSD_VA_LIST_ va_list; ((type *)(ap += sizeof(type)))[-1] #else #define va_arg(ap, type) \ - ((type *)(ap += sizeof(type) < sizeof(int) ? \ - (abort(), 0) : sizeof(type)))[-1] + ((type *)(ap += __va_promote(type), \ + ap - (sizeof(type) < sizeof(int) && \ + sizeof(type) != __va_promote(type) ? \ + sizeof(type) : __va_promote(type))))[0] #endif #define va_end(ap) diff --git a/sys/arch/m68k/include/varargs.h b/sys/arch/m68k/include/varargs.h index d7b94aa24f73..2dabdc3fa99f 100644 --- a/sys/arch/m68k/include/varargs.h +++ b/sys/arch/m68k/include/varargs.h @@ -1,4 +1,4 @@ -/* $NetBSD: varargs.h,v 1.7 1994/10/26 07:50:58 cgd Exp $ */ +/* $NetBSD: varargs.h,v 1.8 1994/12/28 22:45:47 cgd Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -49,6 +49,9 @@ typedef _BSD_VA_LIST_ va_list; #define va_dcl int va_alist; +#define __va_promote(type) \ + (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int)) + #define va_start(ap) \ ap = (char *)&va_alist @@ -57,8 +60,10 @@ typedef _BSD_VA_LIST_ va_list; ((type *)(ap += sizeof(type)))[-1] #else #define va_arg(ap, type) \ - ((type *)(ap += sizeof(type) < sizeof(int) ? \ - (abort(), 0) : sizeof(type)))[-1] + ((type *)(ap += __va_promote(type), \ + ap - (sizeof(type) < sizeof(int) && \ + sizeof(type) != __va_promote(type) ? \ + sizeof(type) : __va_promote(type))))[0] #endif #define va_end(ap)