On Thu, 3 Jan 2002, Nicholas Clark wrote:

> On Thu, Jan 03, 2002 at 08:46:31AM -0600, David M. Lloyd wrote:
> >
> > Maybe we should be using the Configure output to determine what postfix to
> > use, based on the size of ints, longs, long longs, etc., and pointers,
> > rather than "almost always" being right?

And here's a patch that does that (feel free to tweak).
Note that the 'u' and friends are moved inside the ().
This passes tests in stack and pmc.t for Solaris 64-bit and (I
assume) other 64-bits as well.

===================================================================
RCS file: /home/perlcvs/parrot/Configure.pl,v
retrieving revision 1.65
diff -u -r1.65 Configure.pl
--- Configure.pl        2 Jan 2002 16:27:42 -0000       1.65
+++ Configure.pl        3 Jan 2002 20:01:55 -0000
@@ -141,11 +141,12 @@
     debugging     => $opt_debugging,
     rm_f          => 'rm -f',
     rm_rf         => 'rm -rf',
-    stacklow      => '(~0xfff)U',
-    intlow        => '(~0xfff)U',
-    numlow        => '(~0xfff)U',
-    strlow        => '(~0xfff)U',
-    pmclow        => '(~0xfff)U',
+    ptrconst      => 'u',
+    stacklow      => '(~0xfffu)',
+    intlow        => '(~0xfffu)',
+    numlow        => '(~0xfffu)',
+    strlow        => '(~0xfffu)',
+    pmclow        => '(~0xfffu)',
     make          => $Config{make},
     make_set_make => $Config{make_set_make},

@@ -429,6 +430,24 @@

 $c{packtype_n} = 'd';

+#
+# Find out what integer constant type we can use
+# for pointers.
+#
+
+print "Figuring out what integer type we can mix with pointers...\n";
+
+if ($c{intsize} == $c{ptrsize}) {
+    print "We'll use 'unsigned int'.\n";
+    $c{ptrconst} = "u";
+} elsif ($c{longsize} == $c{ptrsize}) {
+    print "We'll use 'unsigned long'.\n";
+    $c{ptrconst} = "ul";
+} else {
+    die <<"AARGH";
+Configure.pl:  Unable to find an integer type that fits a pointer.
+AARGH
+}

 #
 # Build config.h, the Makfefiles and Types.pm:
@@ -701,7 +720,7 @@
         my $vector = unpack("b*", pack("V", $_));
         my $offset = rindex($vector, "1")+1;
         my $mask = 2**$offset - 1;
-        push @returns, "(~0x".sprintf("%x", $mask)."U)";
+        push @returns, "(~0x".sprintf("%x", $mask).$c{ptrconst}.")";
     }

     return @returns;


- D

<[EMAIL PROTECTED]>

Reply via email to