summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1995-12-30 08:48:24 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1995-12-30 08:48:24 +0000
commitda10fa74772694cff97087eb39c83a311ba6eadc (patch)
treec2f7eb8915196cb758b2aabeb7ed60b0df6ffcd8 /sys
parentb9aee3c44417b6bdbb038f048472d3b1f05aaa8c (diff)
from netbsd: support more gcc versions
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/alpha/include/stdarg.h31
-rw-r--r--sys/arch/alpha/include/varargs.h42
-rw-r--r--sys/arch/i386/include/stdarg.h15
-rw-r--r--sys/arch/i386/include/varargs.h29
-rw-r--r--sys/arch/m68k/include/stdarg.h23
-rw-r--r--sys/arch/m68k/include/varargs.h32
-rw-r--r--sys/arch/pc532/include/stdarg.h17
-rw-r--r--sys/arch/pc532/include/varargs.h29
-rw-r--r--sys/arch/pmax/include/stdarg.h20
-rw-r--r--sys/arch/pmax/include/varargs.h29
-rw-r--r--sys/arch/sparc/include/stdarg.h94
-rw-r--r--sys/arch/sparc/include/varargs.h24
-rw-r--r--sys/arch/vax/include/stdarg.h24
-rw-r--r--sys/arch/vax/include/varargs.h27
14 files changed, 169 insertions, 267 deletions
diff --git a/sys/arch/alpha/include/stdarg.h b/sys/arch/alpha/include/stdarg.h
index d67aa9a7294..c6d328f30be 100644
--- a/sys/arch/alpha/include/stdarg.h
+++ b/sys/arch/alpha/include/stdarg.h
@@ -1,4 +1,4 @@
-/* $NetBSD: stdarg.h,v 1.2 1995/02/16 03:08:08 cgd Exp $ */
+/* $NetBSD: stdarg.h,v 1.3 1995/12/26 00:15:47 mycroft Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -35,33 +35,28 @@
* @(#)stdarg.h 8.1 (Berkeley) 6/10/93
*/
-#ifndef _STDARG_H_
-#define _STDARG_H_
+#ifndef _ALPHA_STDARG_H_
+#define _ALPHA_STDARG_H_
#include <machine/ansi.h>
typedef _BSD_VA_LIST_ va_list;
-/*
- * Note that these macros are significantly different than the 'standard'
- * ones. On the alpha, all arguments are passed as 64 bit quantities.
- */
-
-#define va_start(a, last) \
- (__builtin_next_arg(last), (a) = *(va_list *)__builtin_saveregs())
-
#define __va_size(type) \
(((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
+#define va_start(ap, last) \
+ (__builtin_next_arg(last), (ap) = *(va_list *)__builtin_saveregs())
+
#define __REAL_TYPE_CLASS 8
-#define __va_arg_offset(a, type) \
+#define __va_arg_offset(ap, type) \
((__builtin_classify_type(*(type *)0) == __REAL_TYPE_CLASS && \
- (a).offset <= (6 * 8) ? -(6 * 8) : 0) - __va_size(type))
+ (ap).offset <= (6 * 8) ? -(6 * 8) : 0) - __va_size(type))
-#define va_arg(a, type) \
- (*((a).offset += __va_size(type), \
- (type *)((a).base + (a).offset + __va_arg_offset(a, type))))
+#define va_arg(ap, type) \
+ (*(type *)((ap).offset += __va_size(type), \
+ (ap).base + (ap).offset + __va_arg_offset(ap, type)))
-#define va_end(a) ((void) 0)
+#define va_end(ap) ((void)0)
-#endif /* !_STDARG_H_ */
+#endif /* !_ALPHA_STDARG_H_ */
diff --git a/sys/arch/alpha/include/varargs.h b/sys/arch/alpha/include/varargs.h
index 183ae618b73..91e822923ee 100644
--- a/sys/arch/alpha/include/varargs.h
+++ b/sys/arch/alpha/include/varargs.h
@@ -1,4 +1,4 @@
-/* $NetBSD: varargs.h,v 1.2 1995/02/16 03:08:11 cgd Exp $ */
+/* $NetBSD: varargs.h,v 1.4 1995/12/26 01:16:24 mycroft Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -40,36 +40,22 @@
* @(#)varargs.h 8.2 (Berkeley) 3/22/94
*/
-#ifndef _VARARGS_H_
-#define _VARARGS_H_
+#ifndef _ALPHA_VARARGS_H_
+#define _ALPHA_VARARGS_H_
-#include <machine/ansi.h>
+#include <machine/stdarg.h>
-typedef _BSD_VA_LIST_ va_list;
-
-/*
- * Note that these macros are significantly different than the 'standard'
- * ones. On the alpha, all arguments are passed as 64 bit quantities.
- */
+#if __GNUC__ == 1
+#define __va_ellipsis
+#else
+#define __va_ellipsis ...
+#endif
#define va_alist __builtin_va_alist
-#define va_dcl va_list __builtin_va_alist; ...
-
-#define va_start(a) \
- ((a) = *(va_list *)__builtin_saveregs())
-
-#define __va_size(type) \
- (((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
-
-#define __REAL_TYPE_CLASS 8
-#define __va_arg_offset(a, type) \
- ((__builtin_classify_type(*(type *)0) == __REAL_TYPE_CLASS && \
- (a).offset <= (6 * 8) ? -(6 * 8) : 0) - __va_size(type))
-
-#define va_arg(a, type) \
- (*((a).offset += __va_size(type), \
- (type *)((a).base + (a).offset + __va_arg_offset(a, type))))
+#define va_dcl long __builtin_va_alist; __va_ellipsis
-#define va_end(a) ((void) 0)
+#undef va_start
+#define va_start(ap) \
+ ((ap) = *(va_list *)__builtin_saveregs())
-#endif /* !_VARARGS_H_ */
+#endif /* !_ALPHA_VARARGS_H_ */
diff --git a/sys/arch/i386/include/stdarg.h b/sys/arch/i386/include/stdarg.h
index be8a86d925b..ddf7c81c083 100644
--- a/sys/arch/i386/include/stdarg.h
+++ b/sys/arch/i386/include/stdarg.h
@@ -1,4 +1,4 @@
-/* $NetBSD: stdarg.h,v 1.9 1995/03/28 18:17:21 jtc Exp $ */
+/* $NetBSD: stdarg.h,v 1.12 1995/12/25 23:15:31 mycroft Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -42,19 +42,14 @@
typedef _BSD_VA_LIST_ va_list;
-#define __va_promote(type) \
- (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
+#define __va_size(type) \
+ (((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
#define va_start(ap, last) \
- (ap = ((char *)&(last) + __va_promote(last)))
+ ((ap) = (va_list)&(last) + __va_size(last))
-#ifdef _KERNEL
#define va_arg(ap, type) \
- ((type *)(ap += sizeof(type)))[-1]
-#else
-#define va_arg(ap, type) \
- ((type *)(ap += __va_promote(type), ap - __va_promote(type)))[0]
-#endif
+ (*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
#define va_end(ap) ((void)0)
diff --git a/sys/arch/i386/include/varargs.h b/sys/arch/i386/include/varargs.h
index 5ac55595c94..873f813f239 100644
--- a/sys/arch/i386/include/varargs.h
+++ b/sys/arch/i386/include/varargs.h
@@ -1,4 +1,4 @@
-/* $NetBSD: varargs.h,v 1.10 1995/03/28 18:17:27 jtc Exp $ */
+/* $NetBSD: varargs.h,v 1.14 1995/12/26 01:16:26 mycroft Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -43,26 +43,19 @@
#ifndef _I386_VARARGS_H_
#define _I386_VARARGS_H_
-#include <machine/ansi.h>
+#include <machine/stdarg.h>
-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
-
-#ifdef _KERNEL
-#define va_arg(ap, type) \
- ((type *)(ap += sizeof(type)))[-1]
+#if __GNUC__ == 1
+#define __va_ellipsis
#else
-#define va_arg(ap, type) \
- ((type *)(ap += __va_promote(type), ap - __va_promote(type)))[0]
+#define __va_ellipsis ...
#endif
-#define va_end(ap) ((void) 0)
+#define va_alist __builtin_va_alist
+#define va_dcl long __builtin_va_alist; __va_ellipsis
+
+#undef va_start
+#define va_start(ap) \
+ ((ap) = (va_list)&__builtin_va_alist)
#endif /* !_I386_VARARGS_H_ */
diff --git a/sys/arch/m68k/include/stdarg.h b/sys/arch/m68k/include/stdarg.h
index b34dd9e4c7b..0ec130709b4 100644
--- a/sys/arch/m68k/include/stdarg.h
+++ b/sys/arch/m68k/include/stdarg.h
@@ -1,4 +1,4 @@
-/* $NetBSD: stdarg.h,v 1.11 1995/09/07 01:20:15 jtc Exp $ */
+/* $NetBSD: stdarg.h,v 1.14 1995/12/25 23:15:33 mycroft Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -42,23 +42,18 @@
typedef _BSD_VA_LIST_ va_list;
-#define __va_promote(type) \
- (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
+#define __va_size(type) \
+ (((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
#define va_start(ap, last) \
- (ap = ((char *)&(last) + sizeof(last)))
+ ((ap) = (va_list)&(last) + __va_size(last))
-#ifdef _KERNEL
#define va_arg(ap, type) \
- ((type *)(ap += sizeof(type)))[-1]
-#else
-#define va_arg(ap, type) \
- ((type *)(ap += __va_promote(type), \
- ap - (sizeof(type) < sizeof(int) && \
- sizeof(type) != __va_promote(type) ? \
- sizeof(type) : __va_promote(type))))[0]
-#endif
+ (*(type *)((ap) += __va_size(type), \
+ (ap) - (sizeof(type) < sizeof(long) && \
+ sizeof(type) != __va_size(type) ? \
+ sizeof(type) : __va_size(type))))
-#define va_end(ap) ((void) 0)
+#define va_end(ap) ((void)0)
#endif /* !_M68K_STDARG_H_ */
diff --git a/sys/arch/m68k/include/varargs.h b/sys/arch/m68k/include/varargs.h
index d3a160453c0..925c1d21278 100644
--- a/sys/arch/m68k/include/varargs.h
+++ b/sys/arch/m68k/include/varargs.h
@@ -1,4 +1,4 @@
-/* $NetBSD: varargs.h,v 1.10 1995/03/26 17:08:41 briggs Exp $ */
+/* $NetBSD: varargs.h,v 1.14 1995/12/26 01:16:28 mycroft Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -43,29 +43,19 @@
#ifndef _M68K_VARARGS_H_
#define _M68K_VARARGS_H_
-#include <machine/ansi.h>
+#include <machine/stdarg.h>
-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
-
-#ifdef _KERNEL
-#define va_arg(ap, type) \
- ((type *)(ap += sizeof(type)))[-1]
+#if __GNUC__ == 1
+#define __va_ellipsis
#else
-#define va_arg(ap, type) \
- ((type *)(ap += __va_promote(type), \
- ap - (sizeof(type) < sizeof(int) && \
- sizeof(type) != __va_promote(type) ? \
- sizeof(type) : __va_promote(type))))[0]
+#define __va_ellipsis ...
#endif
-#define va_end(ap) ((void) 0)
+#define va_alist __builtin_va_alist
+#define va_dcl long __builtin_va_alist; __va_ellipsis
+
+#undef va_start
+#define va_start(ap) \
+ ((ap) = (va_list)&__builtin_va_alist)
#endif /* !_M68K_VARARGS_H_ */
diff --git a/sys/arch/pc532/include/stdarg.h b/sys/arch/pc532/include/stdarg.h
index 32a97df670c..ec5096edcbd 100644
--- a/sys/arch/pc532/include/stdarg.h
+++ b/sys/arch/pc532/include/stdarg.h
@@ -1,4 +1,4 @@
-/* $NetBSD: stdarg.h,v 1.9 1995/03/28 18:18:36 jtc Exp $ */
+/* $NetBSD: stdarg.h,v 1.12 1995/12/25 23:15:34 mycroft Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -42,20 +42,15 @@
typedef _BSD_VA_LIST_ va_list;
-#define __va_promote(type) \
- (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
+#define __va_size(type) \
+ (((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
#define va_start(ap, last) \
- (ap = ((char *)&(last) + __va_promote(last)))
+ ((ap) = (va_list)&(last) + __va_size(last))
-#ifdef _KERNEL
#define va_arg(ap, type) \
- ((type *)(ap += sizeof(type)))[-1]
-#else
-#define va_arg(ap, type) \
- ((type *)(ap += __va_promote(type), ap - __va_promote(type)))[0]
-#endif
+ (*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
-#define va_end(ap) ((void) 0)
+#define va_end(ap) ((void)0)
#endif /* !_PC532_STDARG_H_ */
diff --git a/sys/arch/pc532/include/varargs.h b/sys/arch/pc532/include/varargs.h
index 3980803f1ac..301235c4dd4 100644
--- a/sys/arch/pc532/include/varargs.h
+++ b/sys/arch/pc532/include/varargs.h
@@ -1,4 +1,4 @@
-/* $NetBSD: varargs.h,v 1.8 1995/03/28 18:18:40 jtc Exp $ */
+/* $NetBSD: varargs.h,v 1.12 1995/12/26 01:16:30 mycroft Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -43,26 +43,19 @@
#ifndef _PC532_VARARGS_H_
#define _PC532_VARARGS_H_
-#include <machine/ansi.h>
+#include <machine/stdarg.h>
-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
-
-#ifdef _KERNEL
-#define va_arg(ap, type) \
- ((type *)(ap += sizeof(type)))[-1]
+#if __GNUC__ == 1
+#define __va_ellipsis
#else
-#define va_arg(ap, type) \
- ((type *)(ap += __va_promote(type), ap - __va_promote(type)))[0]
+#define __va_ellipsis ...
#endif
-#define va_end(ap) ((void) 0)
+#define va_alist __builtin_va_alist
+#define va_dcl long __builtin_va_alist; __va_ellipsis
+
+#undef va_start
+#define va_start(ap) \
+ ((ap) = (va_list)&__builtin_va_alist)
#endif /* !_PC532_VARARGS_H_ */
diff --git a/sys/arch/pmax/include/stdarg.h b/sys/arch/pmax/include/stdarg.h
index 73f3b6e0a1a..c9a644c1ef8 100644
--- a/sys/arch/pmax/include/stdarg.h
+++ b/sys/arch/pmax/include/stdarg.h
@@ -1,4 +1,4 @@
-/* $NetBSD: stdarg.h,v 1.7 1995/03/28 18:19:28 jtc Exp $ */
+/* $NetBSD: stdarg.h,v 1.10 1995/12/25 23:15:35 mycroft Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -42,23 +42,15 @@
typedef _BSD_VA_LIST_ va_list;
-#define __va_promote(type) \
- (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
+#define __va_size(type) \
+ (((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
#define va_start(ap, last) \
- (ap = ((char *)&(last) + __va_promote(last)))
+ ((ap) = (va_list)&(last) + __va_size(last))
-#ifdef _KERNEL
#define va_arg(ap, type) \
- ((type *)(ap += sizeof(type)))[-1]
-#else
-#define va_arg(ap, type) \
- ((type *)(ap += sizeof(type) == sizeof(int) ? sizeof(type) : \
- sizeof(type) > sizeof(int) ? \
- (-(int)(ap) & (sizeof(type) - 1)) + sizeof(type) : \
- (abort(), 0)))[-1]
-#endif
+ (*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
-#define va_end(ap) ((void) 0)
+#define va_end(ap) ((void)0)
#endif /* !_PMAX_STDARG_H_ */
diff --git a/sys/arch/pmax/include/varargs.h b/sys/arch/pmax/include/varargs.h
index 8cb900dc521..db59d3d5892 100644
--- a/sys/arch/pmax/include/varargs.h
+++ b/sys/arch/pmax/include/varargs.h
@@ -1,4 +1,4 @@
-/* $NetBSD: varargs.h,v 1.8 1995/03/28 18:19:30 jtc Exp $ */
+/* $NetBSD: varargs.h,v 1.12 1995/12/26 01:16:31 mycroft Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -43,26 +43,19 @@
#ifndef _PMAX_VARARGS_H_
#define _PMAX_VARARGS_H_
-#include <machine/ansi.h>
+#include <machine/stdarg.h>
-typedef _BSD_VA_LIST_ va_list;
-
-#define va_dcl int va_alist; ...
-
-#define va_start(ap) \
- ap = (char *)&va_alist
-
-#ifdef _KERNEL
-#define va_arg(ap, type) \
- ((type *)(ap += sizeof(type)))[-1]
+#if __GNUC__ == 1
+#define __va_ellipsis
#else
-#define va_arg(ap, type) \
- ((type *)(ap += sizeof(type) == sizeof(int) ? sizeof(type) : \
- sizeof(type) > sizeof(int) ? \
- (-(int)(ap) & (sizeof(type) - 1)) + sizeof(type) : \
- (abort(), 0)))[-1]
+#define __va_ellipsis ...
#endif
-#define va_end(ap) ((void) 0)
+#define va_alist __builtin_va_alist
+#define va_dcl long __builtin_va_alist; __va_ellipsis
+
+#undef va_start
+#define va_start(ap) \
+ ((ap) = (va_list)&__builtin_va_alist)
#endif /* !_PMAX_VARARGS_H_ */
diff --git a/sys/arch/sparc/include/stdarg.h b/sys/arch/sparc/include/stdarg.h
index a1069e6a385..d61c5f8ec60 100644
--- a/sys/arch/sparc/include/stdarg.h
+++ b/sys/arch/sparc/include/stdarg.h
@@ -1,4 +1,4 @@
-/* $NetBSD: stdarg.h,v 1.6 1995/01/28 01:52:21 jtc Exp $ */
+/* $NetBSD: stdarg.h,v 1.8 1995/12/25 23:15:38 mycroft Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -44,10 +44,6 @@
* from: @(#)stdarg.h 8.2 (Berkeley) 9/27/93
*/
-/*
- * SPARC stdarg.h
- */
-
#ifndef _SPARC_STDARG_H_
#define _SPARC_STDARG_H_
@@ -55,64 +51,56 @@
typedef _BSD_VA_LIST_ va_list;
-/*
- * va_start sets ap to point to the first variable argument.
- * The `last fixed argument' parameter l is ignored (and should
- * never have been included in the ANSI standard!).
- *
- * va_end cleans up after va_start. There is nothing to do there.
- */
-#ifdef __GCC_NEW_VARARGS__ /* gcc 2.4.5 */
-#define va_start(ap, l) ((ap) = (va_list)__builtin_saveregs())
-#else /* gcc 2.3.3 */
-#define va_start(ap, l) (__builtin_saveregs(), \
- (ap) = (va_list)__builtin_next_arg())
-#endif
-#define va_end(ap) ((void) 0)
+#define __va_size(type) \
+ (((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
-#if __GNUC__ == 1
-#define __extension__ /* hack for bootstrapping via gcc 1.x */
+#ifdef __GCC_NEW_VARARGS__
+#define va_start(ap, last) \
+ (__builtin_next_arg(last), (ap) = (va_list)__builtin_saveregs())
+#else
+#define va_start(ap, last) \
+ (__builtin_saveregs(), (ap) = (va_list)__builtin_next_arg(last))
#endif
/*
- * va_arg picks up the next argument of type `ty'. Appending an
- * asterisk to ty must produce a pointer to ty (i.e., ty may not be,
- * e.g., `int (*)()'). In addition, ty must not be any type which
- * undergoes promotion to some other type (e.g., char): it must
- * be the promoted type instead.
+ * va_arg picks up the next argument of type `type'. Appending an
+ * asterisk to `type' must produce a pointer to `type' (i.e., `type'
+ * may not be, e.g., `int (*)()').
*
* Gcc-2.x tries to use ldd/std for double and quad_t values, but Sun's
- * brain-damaged calling convention does not quad-align these. Thus,
- * for 8-byte arguments, we have to pick up the actual value four bytes
- * at a time, and use type punning (i.e., a union) to produce the result.
+ * brain-damaged calling convention does not quad-align these. Thus, for
+ * 8-byte arguments, we have to pick up the actual value four bytes at a
+ * time, and use type punning (i.e., a union) to produce the result.
* (We could also do this with a libc function, actually, by returning
* 8 byte integers in %o0+%o1 and the same 8 bytes as a double in %f0+%f1.)
*
- * Note: we cannot use the union trick (which generates better code) for
- * C++, since `ty' might be a type with a constructor (these may not appear
- * in a union).
- *
- * The extraneous casts through `void *' avoid gcc alignment warnings.
+ * Note: We don't declare __d with type `type', since in C++ the type might
+ * have a constructor.
*/
-#ifdef __cplusplus
-#define __va_8byte(ap, ty) ({ \
- int __va_i[2]; \
- __va_i[0] = ((int *)(void *)(ap))[0]; \
- __va_i[1] = ((int *)(void *)(ap))[1]; \
- (ap) += 8; *(ty *)(void *)__va_i; })
-#else
-#define __va_8byte(ap, ty) ({ \
- union { ty __d; int __i[2]; } __va_u; \
- __va_u.__i[0] = ((int *)(void *)(ap))[0]; \
- __va_u.__i[1] = ((int *)(void *)(ap))[1]; \
- (ap) += 8; __va_u.__d; })
-#endif /* __cplusplus */
+#if __GNUC__ == 1
+#define __extension__
+#endif
+
+#define __va_8byte(ap, type) \
+ __extension__ ({ \
+ union { char __d[sizeof(type)]; int __i[2]; } __va_u; \
+ __va_u.__i[0] = ((int *)(void *)(ap))[0]; \
+ __va_u.__i[1] = ((int *)(void *)(ap))[1]; \
+ (ap) += 8; *(type *)(va_list)__va_u.__d; \
+ })
+
+#define __va_arg(ap, type) \
+ (*(type *)((ap) += __va_size(type), \
+ (ap) - (sizeof(type) < sizeof(long) && \
+ sizeof(type) != __va_size(type) ? \
+ sizeof(type) : __va_size(type))))
+
+#define __RECORD_TYPE_CLASS 12
+#define va_arg(ap, type) \
+ (__builtin_classify_type(*(type *)0) >= __RECORD_TYPE_CLASS ? \
+ *__va_arg(ap, type *) : __va_size(type) == 8 ? \
+ __va_8byte(ap, type) : __va_arg(ap, type))
-#define va_arg(ap, ty) __extension__ ({ \
- ty __va_temp; /* to check for invisible-ptr struct-valued args */ \
- __builtin_classify_type(__va_temp) >= 12 ? \
- ((ty **)(void *)((ap) += sizeof(ty *)))[-1][0] : \
- sizeof(ty) == 8 ? __va_8byte(ap, ty) : \
- ((ty *)(void *)(ap += sizeof(ty)))[-1]; })
+#define va_end(ap) ((void)0)
#endif /* !_SPARC_STDARG_H_ */
diff --git a/sys/arch/sparc/include/varargs.h b/sys/arch/sparc/include/varargs.h
index 5e06b12c6db..73e427e8dd4 100644
--- a/sys/arch/sparc/include/varargs.h
+++ b/sys/arch/sparc/include/varargs.h
@@ -1,4 +1,4 @@
-/* $NetBSD: varargs.h,v 1.6 1994/11/20 20:53:37 deraadt Exp $ */
+/* $NetBSD: varargs.h,v 1.9 1995/12/26 01:16:33 mycroft Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -54,24 +54,22 @@
#include <machine/stdarg.h>
-/* See <machine/stdarg.h> for comments. */
#if __GNUC__ == 1
-#define __extension__
-#define va_dcl int va_alist;
-#else /* gcc2 */
-#ifdef __GCC_NEW_VARARGS__ /* gcc 2.4.5 */
-#define va_alist __builtin_va_alist
-#define va_dcl int __builtin_va_alist; ...
-#else /* gcc 2.3.3 */
-#define va_dcl int va_alist; ...
-#endif
+#define __va_ellipsis
+#else
+#define __va_ellipsis ...
#endif
+#define va_alist __builtin_va_alist
+#define va_dcl long __builtin_va_alist; __va_ellipsis
+
#undef va_start
#ifdef __GCC_NEW_VARARGS__
-#define va_start(ap) ((ap) = (va_list)__builtin_saveregs())
+#define va_start(ap) \
+ ((ap) = (va_list)__builtin_saveregs())
#else
-#define va_start(ap) (__builtin_saveregs(), (ap) = (va_list)&va_alist)
+#define va_start(ap) \
+ (__builtin_saveregs(), (ap) = (va_list)&__builtin_va_alist)
#endif
#endif /* !_SPARC_VARARGS_H_ */
diff --git a/sys/arch/vax/include/stdarg.h b/sys/arch/vax/include/stdarg.h
index a6cb75347bb..41042c71d7d 100644
--- a/sys/arch/vax/include/stdarg.h
+++ b/sys/arch/vax/include/stdarg.h
@@ -1,4 +1,4 @@
-/* $NetBSD: stdarg.h,v 1.5 1995/03/28 18:21:25 jtc Exp $ */
+/* $NetBSD: stdarg.h,v 1.8 1995/12/25 23:15:37 mycroft Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
@@ -42,21 +42,15 @@
typedef _BSD_VA_LIST_ va_list;
-#define __va_promote(type) \
- (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
+#define __va_size(type) \
+ (((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
#define va_start(ap, last) \
- (ap = ((char *)&(last) + __va_promote(last)))
-
-#ifdef _KERNEL
-#define va_arg(ap, type) \
- ((type *)(ap += sizeof(type)))[-1]
-#else
-#define va_arg(ap, type) \
- ((type *)(ap += sizeof(type) < sizeof(int) ? \
- (abort(), 0) : sizeof(type)))[-1]
-#endif
-
-#define va_end(ap) ((void) 0)
+ ((ap) = (va_list)&(last) + __va_size(last))
+
+#define va_arg(ap, type) \
+ (*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
+
+#define va_end(ap) ((void)0)
#endif /* !_VAX_STDARG_H_ */
diff --git a/sys/arch/vax/include/varargs.h b/sys/arch/vax/include/varargs.h
index ec53db3e9d1..b365369de7f 100644
--- a/sys/arch/vax/include/varargs.h
+++ b/sys/arch/vax/include/varargs.h
@@ -1,4 +1,4 @@
-/* $NetBSD: varargs.h,v 1.5 1995/03/28 18:21:27 jtc Exp $ */
+/* $NetBSD: varargs.h,v 1.9 1995/12/26 01:16:35 mycroft Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -38,24 +38,19 @@
#ifndef _VAX_VARARGS_H_
#define _VAX_VARARGS_H_
-#include <machine/ansi.h>
+#include <machine/stdarg.h>
-typedef _BSD_VA_LIST_ va_list;
-
-#define va_dcl int va_alist; ...
-
-#define va_start(ap) \
- ap = (char *)&va_alist
-
-#ifdef _KERNEL
-#define va_arg(ap, type) \
- ((type *)(ap += sizeof(type)))[-1]
+#if __GNUC__ == 1
+#define __va_ellipsis
#else
-#define va_arg(ap, type) \
- ((type *)(ap += sizeof(type) < sizeof(int) ? \
- (abort(), 0) : sizeof(type)))[-1]
+#define __va_ellipsis ...
#endif
-#define va_end(ap) ((void) 0)
+#define va_alist __builtin_va_alist
+#define va_dcl long __builtin_va_alist; __va_ellipsis
+
+#undef va_start
+#define va_start(ap) \
+ ((ap) = (va_list)&__builtin_va_alist)
#endif /* !_VAX_VARARGS_H_ */