1 # Copyright (C) 2001-2003, The Perl Foundation.
6 config/auto/memalign.pm - Memory Alignment
10 Determines if the C library supports C<memalign()>.
14 package auto
::memalign
;
19 use base
qw(Parrot::Configure::Step);
21 use Parrot
::Configure
::Utils
':auto';
27 $data{description
} = q{Determining if your C library supports memalign};
33 my ( $self, $conf ) = @_;
35 if ( $conf->options->get('miniparrot') ) {
36 $conf->data->set( memalign
=> '' );
37 $self->set_result('skipped');
41 if ( defined $conf->data->get('memalign') ) {
43 # already set; leave it alone
44 $self->set_result('already set');
49 _set_malloc_header
($conf);
53 $conf->cc_gen('config/auto/memalign/test_c.in');
54 eval { $conf->cc_build(); };
55 unless ( $@
|| $conf->cc_run_capture() !~ /ok/ ) {
62 $conf->cc_gen('config/auto/memalign/test_c2.in');
63 eval { $conf->cc_build(); };
64 unless ( $@
|| $conf->cc_run_capture() !~ /ok/ ) {
69 $self->_set_memalign($conf, $test, $test2);
74 sub _set_malloc_header
{
76 if ( $conf->data->get('i_malloc') ) {
77 $conf->data->set( malloc_header
=> 'malloc.h' );
80 $conf->data->set( malloc_header
=> 'stdlib.h' );
86 if ( $conf->data->get('ptrsize') == $conf->data->get('intsize') ) {
87 $conf->data->set( ptrcast
=> 'int' );
90 $conf->data->set( ptrcast
=> 'long' );
96 my ($conf, $test, $test2) = @_;
97 $conf->data->set( malloc_header
=> undef );
100 $test2 ?
'posix_memalign'
103 $conf->data->set( memalign
=> $f );
104 print( $test ?
" (Yep:$f) " : " (no) " ) if $conf->options->get('verbose');
105 $self->set_result( $test ?
'yes' : 'no' );
112 # cperl-indent-level: 4
115 # vim: expandtab shiftwidth=4: