cvsuser     02/05/06 19:14:00

  Modified:    .        Configure.pl
  Log:
  Figure out byteorder on our own, don't use Perl5 Config's since
  Parrot might not have the same wordsize.
  
  Revision  Changes    Path
  1.109     +52 -5     parrot/Configure.pl
  
  Index: Configure.pl
  ===================================================================
  RCS file: /cvs/public/parrot/Configure.pl,v
  retrieving revision 1.108
  retrieving revision 1.109
  diff -u -w -r1.108 -r1.109
  --- Configure.pl      6 May 2002 06:30:10 -0000       1.108
  +++ Configure.pl      7 May 2002 02:14:00 -0000       1.109
  @@ -2,7 +2,7 @@
   #
   # Configure.pl
   #
  -# $Id: Configure.pl,v 1.108 2002/05/06 06:30:10 mrjoltcola Exp $
  +# $Id: Configure.pl,v 1.109 2002/05/07 02:14:00 mrjoltcola Exp $
   #
   # Author: Brent Dax
   #
  @@ -77,7 +77,7 @@
   
   if($opt_version) {
       print "Parrot Version $parrot_version Configure\n";
  -    print '$Id: Configure.pl,v 1.108 2002/05/06 06:30:10 mrjoltcola Exp $' . "\n";
  +    print '$Id: Configure.pl,v 1.109 2002/05/07 02:14:00 mrjoltcola Exp $' . "\n";
       exit;
   }
   
  @@ -177,7 +177,7 @@
   
       opcode_t      => ($Config{ivtype} || 'long'),
       longsize      => undef,
  -    byteorder     => $Config{byteorder},
  +    perl5byteorder => $Config{byteorder},
   
       intvalfmt     => '%ld',
       floatvalfmt     => '%f',
  @@ -545,6 +545,7 @@
   END
   }
   
  +
   #
   # Alas perl5.7.2 doesn't have an INTVAL flag for pack().
   # The ! modifier only works for perl 5.6.x or greater.
  @@ -604,6 +605,54 @@
   AARGH
   }
   
  +
  +print <<"END";
  +
  +Computing native byteorder for Parrot's wordsize...
  +
  +Ignore warning about overflow...
  +
  +END
  +
  +{
  +    my $testc = "testbyteorder.c";
  +    my $int = $c{iv};
  +    open TESTC, ">$testc" or die "Error opening $testc for byteorder config: $!";
  +print TESTC<<"END";
  +int main() {
  +     int i;
  +     union W {
  +             unsigned char b[sizeof($int)/sizeof(unsigned char)];
  +             $int w;
  +     } w;
  +     if(sizeof(w) == 4) {
  +             w.w = 0x04030201;
  +     }
  +     else {
  +             w.w = 0x0807060504030201;
  +     }
  +
  +     for(i = 0; i < sizeof(w.b); i++) {
  +             printf("%1u", w.b[i]);
  +     }
  +     printf("\\n");
  +     exit(0);
  +     return 0;
  +}
  +END
  +    close(TESTC);
  +
  +    compiletestc("testbyteorder");
  +    $c{byteorder}=runtestc("testbyteorder") or die "Can't run the testbyteorder 
program: $!";
  +    chop $c{byteorder};
  +    print "\nNative byte-order appears to be [", $c{byteorder}, "]\n";
  +    if(length($c{byteorder}) != length($c{perl5byteorder})) {
  +        print "Note, the sizeof Perl5 INTs appear to be different from Parrot's\n";
  +        print "for this configuration, if this is expected, ignore this.\n";
  +    }
  +}
  +
  +
   #"
   # Determine format strings for INTVAL and FLOATVAL.
   #
  @@ -625,8 +674,6 @@
   } else {
       die "Configure.pl:  Can't find a printf-style format specifier for type 
\"$c{nv}\"\n";
   }
  -
  -print "\nYour byteorder seems to be [", $c{byteorder}, "]\n";
   
   #
   # Build config.h, the Makfefiles and Types.pm:
  
  
  


Reply via email to