Subject: fix stdarg for gcc3
To: None <port-mips@netbsd.org, tech-toolchain@netbsd.org>
From: Matthias Drochner <M.Drochner@fz-juelich.de>
List: port-mips
Date: 10/24/2003 16:53:23
This is a multipart MIME message.

--==_Exmh_30750117745000
Content-Type: text/plain; charset=us-ascii


Hi -
is the appended patch OK?
It fixes variable argument list passing for me.
It might even fix the 64-bit ABI case -- at least it would
be the compiler's responsibility then...

best regards
Matthias



--==_Exmh_30750117745000
Content-Type: text/plain ; name="mipsva.txt"; charset=us-ascii
Content-Description: mipsva.txt
Content-Disposition: attachment; filename="mipsva.txt"

Index: include/ansi.h
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/include/ansi.h,v
retrieving revision 1.18
diff -u -p -r1.18 ansi.h
--- include/ansi.h	7 Aug 2003 16:28:26 -0000	1.18
+++ include/ansi.h	24 Oct 2003 14:42:56 -0000
@@ -34,6 +34,8 @@
 #ifndef	_ANSI_H_
 #define	_ANSI_H_
 
+#include <sys/cdefs.h>
+
 #include <machine/int_types.h>
 
 /*
@@ -57,7 +59,11 @@
 #define	_BSD_SSIZE_T_		int		/* byte count or error */
 #define	_BSD_TIME_T_		long		/* time() */
 #endif /* _LP64 */
+#if __GNUC_PREREQ__(3, 3)
+#define _BSD_VA_LIST_		__builtin_va_list /* GCC built-in type */
+#else
 #define	_BSD_VA_LIST_		char *		/* va_list */
+#endif
 #define	_BSD_CLOCKID_T_		int		/* clockid_t */
 #define	_BSD_TIMER_T_		int		/* timer_t */
 #define	_BSD_SUSECONDS_T_	int		/* suseconds_t */
Index: include/stdarg.h
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/include/stdarg.h,v
retrieving revision 1.24
diff -u -p -r1.24 stdarg.h
--- include/stdarg.h	7 Aug 2003 16:28:29 -0000	1.24
+++ include/stdarg.h	24 Oct 2003 14:42:56 -0000
@@ -50,6 +50,15 @@ typedef _BSD_VA_LIST_	va_list;
 #define	__alignof__(t) (4)
 #endif
 
+#if __GNUC_PREREQ__(3, 3)
+
+#define va_start(ap, last)	__builtin_stdarg_start((ap), (last))
+#define va_arg			__builtin_va_arg
+#define va_end			__builtin_va_end
+#define __va_copy(dest, src)	__builtin_va_copy((dest), (src))
+
+#else
+
 #define	va_start(ap, last) \
 	((ap) = (va_list)__builtin_next_arg(last))
 
@@ -69,13 +78,16 @@ typedef _BSD_VA_LIST_	va_list;
  	))[-1])
 #endif
 
+#define __va_copy(dest, src)	((dest) = (src))
+
+#define va_end(ap)
+
+#endif /* gcc3 */
+
 #if !defined(_ANSI_SOURCE) &&						\
     (defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L ||	\
      defined(_NETBSD_SOURCE))
-#define	va_copy(dest, src)						\
-	((dest) = (src))
+#define	va_copy(dest, src)	__va_copy((dest), (src))
 #endif
-
-#define	va_end(ap)
 
 #endif /* !_MIPS_STDARG_H_ */

--==_Exmh_30750117745000--