Author: leo
Date: Tue Nov 15 06:20:12 2005
New Revision: 9983

Added:
   trunk/config/auto/va_ptr/
   trunk/config/auto/va_ptr.pm   (contents, props changed)
   trunk/config/auto/va_ptr/test_c.in   (contents, props changed)
Modified:
   trunk/MANIFEST
   trunk/lib/Parrot/Configure/RunSteps.pm
Log:
A new configure step - va_ptr

* test which type of va_ptr we have
* set config var 'va_ptr_type' to 'x86' or 'ppc'



Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST      (original)
+++ trunk/MANIFEST      Tue Nov 15 06:20:12 2005
@@ -209,6 +209,8 @@ config/auto/sizes/test2_c.in            
 config/auto/sizes/test_c.in                       []
 config/auto/snprintf.pm                           []
 config/auto/snprintf/test.in                      []
+config/auto/va_ptr.pm                             []
+config/auto/va_ptr/test_c.in                      []
 config/gen/config_h.pm                            []
 config/gen/config_h/config_h.in                   []
 config/gen/config_h/feature_h.in                  []

Added: trunk/config/auto/va_ptr.pm
==============================================================================
--- (empty file)
+++ trunk/config/auto/va_ptr.pm Tue Nov 15 06:20:12 2005
@@ -0,0 +1,46 @@
+# Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
+# $Id$
+
+=head1 NAME
+
+config/auto/va_ptr.pl - va_list to va_ptr conversion test
+
+=head1 DESCRIPTION
+
+Tests which kind of PARROT_VA_TO_VAPTR to use.
+
+=cut
+
+package Configure::Step;
+
+use strict;
+use vars qw($description @args);
+use Parrot::Configure::Step ':auto';
+
+$description="Test the type of va_ptr (this test is likely to segfault)...";
+
[EMAIL PROTECTED](verbose);
+
+sub runstep {
+    my $va_type;
+    cc_gen('config/auto/va_ptr/test_c.in');
+    eval { cc_build('-DVA_TYPE_X86'); };
+
+    if ($@ || cc_run() !~ /^ok/) {
+       eval { cc_build('-DVA_TYPE_PPC'); };
+       if ($@ || cc_run() !~ /^ok/) {
+           die "Unknown va_ptr type";
+       }
+       $va_type = 'ppc';
+    }
+    else  {
+       $va_type = 'x86';
+    }
+    cc_clean();
+    $Configure::Step::result = $va_type;
+    Parrot::Configure::Data->set(
+       va_ptr_type => $va_type,
+    );
+}
+
+1;

Added: trunk/config/auto/va_ptr/test_c.in
==============================================================================
--- (empty file)
+++ trunk/config/auto/va_ptr/test_c.in  Tue Nov 15 06:20:12 2005
@@ -0,0 +1,55 @@
+#include <stdio.h>
+#include <stdarg.h>
+
+#if defined VA_TYPE_PPC
+#  define PARROT_VA_TO_VAPTR(x) (x)
+#endif
+#if defined VA_TYPE_X86
+#  define PARROT_VA_TO_VAPTR(x) (&(x))
+#endif
+
+typedef struct a_t {
+    void *args;
+} arg;
+
+static void
+test2(arg *a) {
+
+    va_list *ap = (va_list*)a->args;
+    int i;
+    double d;
+    char *s;
+
+    i = va_arg(*ap, int);
+    d = va_arg(*ap, double);
+    s = va_arg(*ap, char *);
+    if (i == 42 && d == 2.0)
+       printf("%s\n",s);
+    else
+       printf("nok\n");
+}
+
+static void
+test1(va_list ap)
+{
+    arg a;
+    a.args = PARROT_VA_TO_VAPTR(ap);
+    test2(&a);
+}
+
+static void
+test0(int n, ...)
+{
+    va_list ap;
+    va_start(ap, n);
+    test1(ap);
+    va_end(ap);
+}
+
+int main(int argc, char *argv[])
+{
+    test0(3, 42, 2.0, "ok");
+    return 0;
+}
+
+

Modified: trunk/lib/Parrot/Configure/RunSteps.pm
==============================================================================
--- trunk/lib/Parrot/Configure/RunSteps.pm      (original)
+++ trunk/lib/Parrot/Configure/RunSteps.pm      Tue Nov 15 06:20:12 2005
@@ -48,6 +48,7 @@ use Parrot::Configure::Data;
     auto/headers.pm
     auto/sizes.pm
     auto/byteorder.pm
+    auto/va_ptr.pm
     auto/pack.pm
     auto/format.pm
     auto/isreg.pm
@@ -127,7 +128,7 @@ sub runsteps {
         }
 
         print "..." if $args{verbose} && $args{verbose} == 2;
-        print "." x (71 - length($Configure::Step::description) 
+        print "." x (71 - length($Configure::Step::description)
                         - length($Configure::Step::result));
         print "$Configure::Step::result." unless m{^inter/} && $args{ask};
 

Reply via email to