Mail Archives: djgpp-workers/2000/06/20/16:52:28
Eli Zaretskii wrote:
>
> > Date: Tue, 20 Jun 2000 17:58:51 +0200
> > From: Laurynas Biveinis <lauras AT softhome DOT net>
> >
> > int main(void)
> > {
> > magic_sum(1, 2, 3, 4, 0);
> > return 0;
> > }
>
> Does this work if you call magic_sum with double or long long
> arguments, instead of int's?
Yes. (Of course, with type adjustments in magic_sum)
magic_sum(1, 2.1, 3.2, 4.3, 0.0);
will print
Now 10.600000
Now 21.200000
And finally 25.500000
magic_sum(1, 21000000000000LL, 32000000000000LL, 4300000000000000LL, 0LL);
will print
Now 4353000000000001
Now 8706000000000002
And finally 13006000000000002
I get the same thing under both 2.95 and 2.96 and these values are correct.
IMHO you should not be chasing the type differences, but if va_copy fully
reflects its source va_list after all possible kinds of operations with
it. (And the copied va_list should not track original as it changes).
So, is the va_copy OK?
Now some worse news: when I was testing the changes, I decided to see
preprocesor's output for this program to ensure that builtins are used with
2.96 and not 2.95. I realized that 2.96 was _not_ using builtins! It was
caused by a typo in my changes (__GNUC_ instead of __GNUC__), although I
was more than sure that I _did_ test with preprocessor before commiting...
Ugh. I am very sorry. Fixing that typo exposed another, and after fixing
both everything works, including the test program for va_copy (and I
tested with preprocesor (Yeah, whatever, I've said the same to myself then too...))
Anyway, I've commited following as obvious bugfix:
Laurynas
Index: stdarg.h
===================================================================
RCS file: /cvs/djgpp/djgpp/include/stdarg.h,v
retrieving revision 1.4
diff -u -r1.4 stdarg.h
--- stdarg.h 2000/06/19 08:05:31 1.4
+++ stdarg.h 2000/06/20 20:49:23
@@ -21,13 +21,13 @@
#define __DJ_va_list
/* New va_list builtins from GCC 2.96 or later */
-#if ((__GNUC_ == 2) && (__GNUC_MINOR__ >= 96)) || (__GNUC__ >= 3)
+#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) */
+#else /* #if ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 96)) || (__GNUC__ >= 3) */
#define __dj_va_rounded_size(T) \
(((sizeof (T) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
@@ -41,7 +41,7 @@
#define va_start(ap, last_arg) \
(ap = ((va_list) __builtin_next_arg (last_arg)))
-#endif /* #if ((__GNUC_ == 2) && (__GNUC_MINOR__ >= 96)) || (__GNUC__ >= 3) */
+#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.2
diff -u -r1.2 varargs.h
--- varargs.h 2000/06/19 08:05:31 1.2
+++ varargs.h 2000/06/20 20:49:23
@@ -20,7 +20,7 @@
#define __DJ_va_list
/* For GCC 2.96 or later we use its builtin va_list */
-#if ((__GNUC_ == 2) && (__GNUC_MINOR__ >= 96)) || (__GNUC__ >= 3)
+#if ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 96)) || (__GNUC__ >= 3)
#define va_alist __builtin_va_alist
#define va_dcl int __builtin_va_alist __attribute__((__mode__(__word__))); ...
@@ -29,7 +29,7 @@
#define va_arg __builtin_va_arg
-#else /* #if ((__GNUC_ == 2) && (__GNUC_MINOR__ >= 96)) || (__GNUC__ >= 3) */
+#else /* #if ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 96)) || (__GNUC__ >= 3) */
#define va_alist __dj_last_arg
@@ -46,7 +46,7 @@
#define va_start(ap) (ap=(char *)(&__dj_last_arg))
-#endif /* #if ((__GNUC_ == 2) && (__GNUC_MINOR__ >= 96)) || (__GNUC__ >= 3) */
+#endif /* #if ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 96)) || (__GNUC__ >= 3) */
#ifndef __STRICT_ANSI__
Index: djtypes.h
===================================================================
RCS file: /cvs/djgpp/djgpp/include/sys/djtypes.h,v
retrieving revision 1.6
diff -u -r1.6 djtypes.h
--- djtypes.h 2000/06/19 18:00:55 1.6
+++ djtypes.h 2000/06/20 20:49:40
@@ -16,8 +16,8 @@
#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
+#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
- Raw text -