# New Ticket Created by  Steve Fink 
# Please include the string:  [perl #19163]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=19163 >


I'm a little confused by the va_list* stuff for sprintf*. At one
point, people were saying that ppc does va_list differently, though
I'm guessing that was a different compiler than gcc. Now, it seems
like everything uses the same mechanism (and it was just patched to be
this way by Dan). Are there architectures out there that do an extra
level of pointers, or was the whole thing cleaned up by using va_list
pointers in the first place, or what? In meddling with this, I
generated the attached patch to probe for something that now seems to
be a figment of somebody's imagination.

 -- a confused Fink


-- attachment  1 ------------------------------------------------------
url: http://rt.perl.org/rt2/attach/45502/35713/e3eb68/va_list.patch

Index: config/gen/feature_h/feature_h.in
===================================================================
RCS file: /cvs/public/parrot/config/gen/feature_h/feature_h.in,v
retrieving revision 1.3
diff -u -r1.3 feature_h.in
--- config/gen/feature_h/feature_h.in   15 Dec 2002 19:20:42 -0000      1.3
+++ config/gen/feature_h/feature_h.in   16 Dec 2002 05:27:15 -0000
@@ -3,8 +3,8 @@
  */
 
 
-#if !defined(PARROT_FEATRUE_H_GUARD)
-#define PARROT_FEATRUE_H_GUARD
+#if !defined(PARROT_FEATURE_H_GUARD)
+#define PARROT_FEATURE_H_GUARD
 
 #perl - all below here gets evaled by perl, OUT is the filehandle
 
@@ -15,9 +15,17 @@
        print OUT "#endif\n";
 }
 
+if (${va_list_ptr} eq 'direct') {
+    print OUT <<'END';
+#define VA_TO_VAPTR(x) (x)
+END
+} elsif (${va_list_ptr} eq 'address') {
     print OUT <<'END';
 #define VA_TO_VAPTR(x) (&(x))
 END
+} else {
+    die "Hey! Need to know how to get a va_list* !!";
+}
 
 #endif guard
 print OUT "\n\n#endif\n"
Index: lib/Parrot/Configure/RunSteps.pm
===================================================================
RCS file: /cvs/public/parrot/lib/Parrot/Configure/RunSteps.pm,v
retrieving revision 1.16
diff -u -r1.16 RunSteps.pm
--- lib/Parrot/Configure/RunSteps.pm    12 Dec 2002 11:21:36 -0000      1.16
+++ lib/Parrot/Configure/RunSteps.pm    16 Dec 2002 05:27:15 -0000
@@ -27,6 +27,7 @@
        auto/funcptr.pl
        auto/cgoto.pl
        auto/gc.pl
+        auto/varargs.pl
        gen/config_h.pl
        gen/feature_h.pl
        gen/config_pm.pl
--- /dev/null   Thu Apr 11 07:25:15 2002
+++ config/auto/varargs.pl      Sun Dec 15 21:27:51 2002
@@ -0,0 +1,24 @@
+package Configure::Step;
+
+use strict;
+use vars qw($description @args);
+use Parrot::Configure::Step ':auto';
+
+$description="Determining how to access va_list...";
+
+sub runstep {
+    my $method = "unknown";
+    cc_gen('config/auto/varargs/test_c.in');
+    cc_build();
+    $method = "direct" if (cc_run_capture(1) =~ /yes/);
+    $method = "address" if (cc_run_capture(2) =~ /yes/);
+    cc_clean();
+
+    if ($method eq "unknown") {
+        die "Can't determine how to get a ptr to a va_list!\n";
+    }
+
+    Configure::Data->set(va_list_ptr => $method);
+}
+
+1;
--- /dev/null   Thu Apr 11 07:25:15 2002
+++ config/auto/varargs/test_c.in       Sun Dec 15 21:28:06 2002
@@ -0,0 +1,61 @@
+/*
+ * testvarargs.c - figure out how to get a pointer to a va_list
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#define UNKNOWN 0
+#define ADDRESS_OF 1
+#define DIRECT 2
+
+int
+test_address(int first_arg, ...)
+{
+    va_list args;
+    va_list* ptr;
+    int value;
+    va_start(args, first_arg);
+    ptr = (va_list*) &args;
+    value = va_arg(*ptr, int);
+    va_end(args);
+    return (value == 7531);
+}
+
+int
+test_direct(int first_arg, ...)
+{
+    va_list args;
+    va_list* ptr;
+    int value;
+    va_start(args, first_arg);
+    ptr = (va_list*) args;
+    value = va_arg(*ptr, int);
+    va_end(args);
+    return (value == 7531);
+}
+
+int
+main(int argc, char *argv[])
+{
+    if (argv[1][0] == '1' && test_direct(0, 7531)) {
+        printf("yes\n");
+        return 0;
+    } else if (argv[1][0] == '2' && test_address(0, 7531)) {
+        printf("yes\n");
+        return 0;
+    } else {
+        printf("unknown\n");
+        return 1;
+    }
+}
+
+/*
+ * Local variables:
+ * c-indentation-style: bsd
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+ */

Reply via email to