The previous approach of using sizeof(void *) is flat out wrong on a 64 bit
system. The right answer is 3. It gives 4. Which isn't a problem once the
pointer rotation code in check_new() isn't buggy, but isn't as efficient as
desired.
use 5.008;
use ExtUtils::MakeMaker;
+use Config;
+(unpack "B*", pack "N", $Config{ptrsize}) =~ /^0+1(0+)$/
+ or die "Your pointer size of $Config{ptrsize} is very confusing";
+my $ptr_bits = length $1;
+
WriteMakefile(
NAME => 'Devel::Size',
VERSION_FROM => 'lib/Devel/Size.pm',
+ DEFINE => "-DALIGN_BITS=$ptr_bits",
($ExtUtils::MakeMaker::VERSION >= 6.47 ? (MIN_PERL_VERSION => '5.008') : ()),
($ExtUtils::MakeMaker::VERSION >= 6.31 ? (LICENSE => 'perl') : ()),
);
without excessive memory needs. The assumption is that your CPU cache
works :-) (And that we're not going to bust it) */
-#define ALIGN_BITS ( sizeof(void*) >> 1 )
#define BYTE_BITS 3
#define LEAF_BITS (16 - BYTE_BITS)
#define LEAF_MASK 0x1FFF