Mail Archives: djgpp-workers/2000/06/18/15:01:18
It makes use of them, when GCC is 2.96 or later.
Also, it is possible to implement new C99 macro,
va_copy. However, this patch doesn't do that, because
I don't know how to implement it for GCC 2.95 or
earlier (w/o builtins)
Note that sys/djtypes patch include wint_t change too,
as 'cvs diff' gave it to me. OK to commit?
Laurynas
Index: stdarg.h
===================================================================
RCS file: /cvs/djgpp/djgpp/include/stdarg.h,v
retrieving revision 1.3
diff -u -r1.3 stdarg.h
--- stdarg.h 1996/07/25 23:49:42 1.3
+++ stdarg.h 2000/06/18 18:53:06
@@ -1,3 +1,4 @@
+/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#ifndef __dj_include_stdarg_h_
@@ -18,6 +19,15 @@
__DJ_va_list
#undef __DJ_va_list
#define __DJ_va_list
+
+/* New va_list builtins from GCC 2.96 or later */
+#if ((__GNUC_ == 2) && (__GNUC_MINOR__ >= 96) || (__GNUC__ >= 3))
+
+#define va_arg __builtin_va_arg
+#define va_end __builtin_va_end
+#define va_start(ap, last_arg) __builtin_stdarg_start((ap), (last_arg))
+
+#else /* #if ((__GNUC_ == 2) && (__GNUC_MINOR__ >= 96) || (__GNUC__ >= 3)) */
#define __dj_va_rounded_size(T) \
(((sizeof (T) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
@@ -30,6 +40,8 @@
#define va_start(ap, last_arg) \
(ap = ((va_list) __builtin_next_arg (last_arg)))
+
+#endif /* #if ((__GNUC_ == 2) && (__GNUC_MINOR__ >= 96) || (__GNUC__ >= 3)) */
#ifndef __STRICT_ANSI__
Index: varargs.h
===================================================================
RCS file: /cvs/djgpp/djgpp/include/varargs.h,v
retrieving revision 1.1
diff -u -r1.1 varargs.h
--- varargs.h 1995/04/29 06:34:30 1.1
+++ varargs.h 2000/06/18 18:53:07
@@ -1,3 +1,4 @@
+/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#ifndef __dj_include_vararg_h_
#define __dj_include_vararg_h_
@@ -18,6 +19,18 @@
#undef __DJ_va_list
#define __DJ_va_list
+/* For GCC 2.96 or later we use its builtin va_list */
+#if ((__GNUC_ == 2) && (__GNUC_MINOR__ >= 96) || (__GNUC__ >= 3))
+
+#define va_alist __builtin_va_alist
+#define va_dcl int __builtin_va_alist __attribute__((__mode__(__word__))); ...
+#define va_start(ap) __builtin_varargs_start((ap))
+#define va_end __builtin_va_end
+#define va_arg __builtin_va_arg
+
+
+#else /* #if ((__GNUC_ == 2) && (__GNUC_MINOR__ >= 96) || (__GNUC__ >= 3)) */
+
#define va_alist __dj_last_arg
#define va_dcl int __dj_last_arg;
@@ -32,6 +45,8 @@
#define va_end(ap)
#define va_start(ap) (ap=(char *)(&__dj_last_arg))
+
+#endif /* #if ((__GNUC_ == 2) && (__GNUC_MINOR__ >= 96) || (__GNUC__ >= 3)) */
#ifndef __STRICT_ANSI__
/* Implementation defined types */
Index: sys/djtypes.h
===================================================================
RCS file: /cvs/djgpp/djgpp/include/sys/djtypes.h,v
retrieving revision 1.4
diff -u -r1.4 djtypes.h
--- djtypes.h 1999/12/14 11:57:45 1.4
+++ djtypes.h 2000/06/18 18:53:43
@@ -1,3 +1,4 @@
+/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
@@ -12,7 +13,13 @@
#define __DJ_ssize_t typedef int ssize_t;
#define __DJ_time_t typedef unsigned int time_t;
#define __DJ_uid_t typedef int uid_t;
+
+/* Under GCC 2.96 or later, we use its builtin va_list management. */
+#if ((__GNUC_ == 2) && (__GNUC_MINOR__ >= 96) || (__GNUC__ >= 3))
+#define __DJ_va_list typedef __builtin_va_list va_list
+#else
#define __DJ_va_list typedef void *va_list;
+#endif
#if defined(__cplusplus) && ( (__GNUC_MINOR__ >= 8 && __GNUC__ == 2 ) || __GNUC__ >= 3 )
/* wchar_t is now a keyword in C++ */
@@ -22,6 +29,6 @@
#define __DJ_wchar_t typedef unsigned short wchar_t;
#endif
-#define __DJ_wint_t typedef int wint_t;
+#define __DJ_wint_t typedef unsigned int wint_t;
#endif
- Raw text -