Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/i386/include Make varargs and stdarg work with GCC ...



details:   https://anonhg.NetBSD.org/src/rev/b8d7cb194b26
branches:  trunk
changeset: 485723:b8d7cb194b26
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed May 03 21:54:06 2000 +0000

description:
Make varargs and stdarg work with GCC 2.96 and later.

diffstat:

 sys/arch/i386/include/ansi.h    |   7 ++++++-
 sys/arch/i386/include/stdarg.h  |  25 +++++++++++++++++++------
 sys/arch/i386/include/varargs.h |  11 ++++++++---
 3 files changed, 33 insertions(+), 10 deletions(-)

diffs (107 lines):

diff -r 7988989ffef4 -r b8d7cb194b26 sys/arch/i386/include/ansi.h
--- a/sys/arch/i386/include/ansi.h      Wed May 03 21:41:43 2000 +0000
+++ b/sys/arch/i386/include/ansi.h      Wed May 03 21:54:06 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ansi.h,v 1.9 1998/04/27 17:39:10 kleink Exp $  */
+/*     $NetBSD: ansi.h,v 1.10 2000/05/03 21:54:06 thorpej Exp $        */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -52,7 +52,12 @@
 #define        _BSD_SIZE_T_            unsigned int    /* sizeof() */
 #define        _BSD_SSIZE_T_           int             /* byte count or error */
 #define        _BSD_TIME_T_            long            /* time() */
+#if (__GNUC__ - 0) && \
+    ((__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || (__GNUC__ > 2))
+#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 */
diff -r 7988989ffef4 -r b8d7cb194b26 sys/arch/i386/include/stdarg.h
--- a/sys/arch/i386/include/stdarg.h    Wed May 03 21:41:43 2000 +0000
+++ b/sys/arch/i386/include/stdarg.h    Wed May 03 21:54:06 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: stdarg.h,v 1.17 2000/02/03 16:16:07 kleink Exp $       */
+/*     $NetBSD: stdarg.h,v 1.18 2000/05/03 21:54:06 thorpej Exp $      */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -44,9 +44,20 @@
 typedef _BSD_VA_LIST_  va_list;
 
 #ifdef __lint__
-#define __builtin_next_arg(t) ((t) ? 0 : 0)
+#define __builtin_next_arg(t)          ((t) ? 0 : 0)
+#define        __builtin_stdarg_start(a, l)    ((a) = ((l) ? 0 : 0))
+#define        __builtin_va_arg(a, t)          ((a) ? 0 : 0)
+#define        __builtin_va_end                /* nothing */
+#define        __builtin_va_copy(d, s)         ((d) = (s))
 #endif
 
+#if (__GNUC__ - 0) && \
+    ((__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || (__GNUC__ > 2))
+#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_size(type) \
        (((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
 
@@ -56,13 +67,15 @@
 #define        va_arg(ap, type) \
        (*(type *)(void *)((ap) += __va_size(type), (ap) - __va_size(type)))
 
+#define        va_end(ap)      
+
+#define        __va_copy(dest, src)    ((dest) = (src))
+#endif
+
 #if !defined(_ANSI_SOURCE) && \
     (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) || \
      defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L)
-#define        va_copy(dest, src) \
-       ((dest) = (src))
+#define        va_copy(dest, src)      __va_copy((dest), (src))
 #endif
 
-#define        va_end(ap)      
-
 #endif /* !_I386_STDARG_H_ */
diff -r 7988989ffef4 -r b8d7cb194b26 sys/arch/i386/include/varargs.h
--- a/sys/arch/i386/include/varargs.h   Wed May 03 21:41:43 2000 +0000
+++ b/sys/arch/i386/include/varargs.h   Wed May 03 21:54:06 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: varargs.h,v 1.14 1995/12/26 01:16:26 mycroft Exp $     */
+/*     $NetBSD: varargs.h,v 1.15 2000/05/03 21:54:06 thorpej Exp $     */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -45,17 +45,22 @@
 
 #include <machine/stdarg.h>
 
-#if __GNUC__ == 1
+#if (__GNUC__ - 0) == 1
 #define        __va_ellipsis
 #else
 #define        __va_ellipsis   ...
 #endif
 
 #define        va_alist        __builtin_va_alist
-#define        va_dcl          long __builtin_va_alist; __va_ellipsis
+#define        va_dcl          __builtin_va_alist_t __builtin_va_alist; __va_ellipsis
 
 #undef va_start
+#if (__GNUC__ - 0) && \
+    ((__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || (__GNUC__ > 2))
+#define        va_start(ap)    __builtin_varargs_start((ap))
+#else
 #define        va_start(ap) \
        ((ap) = (va_list)&__builtin_va_alist)
+#endif
 
 #endif /* !_I386_VARARGS_H_ */



Home | Main Index | Thread Index | Old Index