1 # Copyright (C) 2001-2008, The Perl Foundation.
6 config/auto/pack.pm - Packing
10 Figures out how to C<pack()> Parrot's types.
19 use base
qw(Parrot::Configure::Step);
24 return { description
=> q{Figuring out how to pack() Parrot's types},
30 my ( $self, $conf ) = @_;
33 # Alas perl5.7.2 doesn't have an INTVAL flag for pack().
34 # The ! modifier only works for perl 5.6.x or greater.
37 my $intsize = $conf->data->get('intsize');
38 my $longsize = $conf->data->get('longsize');
39 my $ptrsize = $conf->data->get('ptrsize');
41 foreach ( 'intvalsize', 'opcode_t_size' ) {
42 my $which = $_ eq 'intvalsize' ?
'packtype_i' : 'packtype_op';
43 my $size = $conf->data->get($_);
45 if ( $size == $longsize
46 && $size == $conf->data->get_p5('longsize')
50 elsif ( $size == 4 ) {
54 || $conf->data->get_p5('use64bitint') eq 'define'
56 # pp_pack is annoying, and this won't work unless sizeof(UV) >= 8
59 warn "Configure.pl: Unable to find a suitable packtype for $_.\n"
62 my $test = eval { pack $format, 0 };
63 unless ( defined $test ) {
65 Configure.pl: Unable to find a functional packtype for $_.
70 unless ( length $test == $size ) {
71 warn sprintf <<"AARGH", $size, length $test;
72 Configure.pl: Unable to find a functional packtype for $_.
73 Need a format for %d bytes, but '$format' gave %d bytes.
81 $conf->data->set( $which => $format );
84 _set_packtypes
($conf);
86 # Find out what integer constant type we can use
88 _set_ptrconst
($conf, $ptrsize, $intsize, $longsize);
98 packtype_n
=> ( $conf->data->get('numvalsize') == 12 ?
'D' : 'd' )
103 my ($conf, $ptrsize, $intsize, $longsize) = @_;
105 if ( $intsize == $ptrsize ) {
106 $conf->data->set( ptrconst
=> "u" );
108 elsif ( $longsize == $ptrsize ) {
109 $conf->data->set( ptrconst
=> "ul" );
113 Configure.pl: Unable to find an integer type that fits a pointer.
122 # cperl-indent-level: 4
125 # vim: expandtab shiftwidth=4: