| File: | config/auto/infnan.pm |
| Coverage: | 92.3% |
| line | stmt | bran | cond | sub | code |
|---|---|---|---|---|---|
| 1 | # Copyright (C) 2010, Parrot Foundation. | ||||
| 2 | # $Id$ | ||||
| 3 | |||||
| 4 - 12 | =head1 NAME config/auto/infnan.pm - detect INFINITY and NAN =head1 DESCRIPTION Determining if the system has INFINITY, NAN, isinf, and isnan defined in headers. =cut | ||||
| 13 | |||||
| 14 | package auto::infnan; | ||||
| 15 | |||||
| 16 | 2 2 2 | use strict; | |||
| 17 | 2 2 2 | use warnings; | |||
| 18 | |||||
| 19 | 2 2 2 | use base qw(Parrot::Configure::Step); | |||
| 20 | |||||
| 21 | 2 2 2 | use Parrot::Configure::Utils ':auto'; | |||
| 22 | |||||
| 23 | sub _init { | ||||
| 24 | 2 | my $self = shift; | |||
| 25 | 2 | my %data; | |||
| 26 | 2 | $data{description} = q{Is standard C Inf/NaN handling present}; | |||
| 27 | 2 | $data{result} = q{}; | |||
| 28 | 2 | return \%data; | |||
| 29 | } | ||||
| 30 | |||||
| 31 | sub runstep { | ||||
| 32 | 2 | my ( $self, $conf ) = @_; | |||
| 33 | |||||
| 34 | 2 | my $infnan = 0; | |||
| 35 | |||||
| 36 | 2 | $conf->cc_gen('config/auto/infnan/test_c.in'); | |||
| 37 | 2 2 | eval { $conf->cc_build(); }; | |||
| 38 | 2 | if (!$@) { | |||
| 39 | 2 2 | my $output = eval { $conf->cc_run() }; | |||
| 40 | 2 | if (!$@ && $output =~ /OK/) { | |||
| 41 | 2 | $infnan = 1; | |||
| 42 | } | ||||
| 43 | } | ||||
| 44 | 2 | $conf->cc_clean(); | |||
| 45 | |||||
| 46 | 2 | $self->_handle_infnan($conf, $infnan); | |||
| 47 | |||||
| 48 | 2 | return 1; | |||
| 49 | } | ||||
| 50 | |||||
| 51 | sub _handle_infnan { | ||||
| 52 | 4 | my ($self, $conf, $infnan) = @_; | |||
| 53 | 4 | if ($infnan) { | |||
| 54 | 3 | $conf->data->set( HAS_INF_NAN => 1 ); | |||
| 55 | 3 | $self->set_result('yes'); | |||
| 56 | } | ||||
| 57 | else { | ||||
| 58 | 1 | $conf->data->set( HAS_INF_NAN => 0 ); | |||
| 59 | 1 | $self->set_result('no'); | |||
| 60 | } | ||||
| 61 | } | ||||
| 62 | |||||
| 63 | 1; | ||||
| 64 | |||||
| 65 | # Local Variables: | ||||
| 66 | # mode: cperl | ||||
| 67 | # cperl-indent-level: 4 | ||||
| 68 | # fill-column: 100 | ||||
| 69 | # End: | ||||
| 70 | # vim: expandtab shiftwidth=4: | ||||
| 71 | |||||