parrot/parrot — Issue #236: config/auto/memalign.pm is broken
Author: gerdr
Created: 2011-12-20 22:56:32+00:00
State: open

`config/auto/memalign.pm` determines the type for pointer-sized integers and creates the configuration value `ptrcast`.

Currently, the code only checks if pointers have the same size as `int` and assumes `long` otherwise. However, this assumption does not hold in general, and is wrong for Win64 specifically.

A preliminary patch could look like this:

diff --git a/config/auto/memalign.pm b/config/auto/memalign.pm
index 9cf5408..95fb6f4 100644
--- a/config/auto/memalign.pm
+++ b/config/auto/memalign.pm
@@ -76,12 +76,27 @@ sub _set_malloc_header {

sub _set_ptrcast {
my $conf = shift;
- if ( $conf->data->get('ptrsize') == $conf->data->get('intsize') ) {
- $conf->data->set( ptrcast => 'int' );
+
+ my $ptrsize = $conf->data->get('ptrsize');
+ my $ptrcast = $conf->data->get("int${ptrsize}_t");
+
+ # FIXME: find out if this actually does the right thing if intXX_t is
+ # not available
+ if ( defined $ptrcast ) {}
+ elsif ( $ptrsize == $conf->data->get('intsize') ) {
+ $ptrcast = 'int';
+ }
+ elsif ( $ptrsize == $conf->data->get('longsize') ) {
+ $ptrcast = 'long';
+ }
+ elsif ( $ptrsize == $conf->data->get('longlongsize') ) {
+ $ptrcast = 'long long';
}
else {
- $conf->data->set( ptrcast => 'long' );
+ # TODO: fail properly
}
+
+ $conf->data->set( ptrcast => $ptrcast );
}

sub _set_memalign {