~ubuntu-branches/ubuntu/wily/parrot/wily-proposed

« back to all changes in this revision

Viewing changes to config/auto/expect.pm

  • Committer: Package Import Robot
  • Author(s): Dominique Dumont
  • Date: 2014-04-26 08:41:44 UTC
  • mfrom: (1.1.20)
  • Revision ID: package-import@ubuntu.com-20140426084144-ycocevtjth7nij5s
Tags: 6.3.0-1
ImportedĀ UpstreamĀ versionĀ 6.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2014, Parrot Foundation.
 
2
 
 
3
=head1 NAME
 
4
 
 
5
config/auto/expect.pm - HAS_BUILTIN_EXPECT
 
6
 
 
7
=head1 DESCRIPTION
 
8
 
 
9
Check if the compiler understands __builtin_expect
 
10
 
 
11
=cut
 
12
 
 
13
package auto::expect;
 
14
 
 
15
use strict;
 
16
use warnings;
 
17
 
 
18
use base qw(Parrot::Configure::Step);
 
19
 
 
20
use Parrot::Configure::Utils ':auto';
 
21
 
 
22
sub _init {
 
23
    my $self = shift;
 
24
    my %data;
 
25
    $data{description} = q{Does your compiler support __builtin_expect};
 
26
    $data{result}      = q{};
 
27
    return \%data;
 
28
}
 
29
 
 
30
sub runstep {
 
31
    my ( $self, $conf ) = @_;
 
32
 
 
33
    # gcc and clang should have it
 
34
    if (_test($conf)) {
 
35
        $conf->data->set( 'HAS_BUILTIN_EXPECT' => 1 );
 
36
        $conf->debug("DEBUG: __builtin_expect detected\n");
 
37
        $self->set_result('yes');
 
38
    }
 
39
    else {
 
40
        $conf->data->set( 'HAS_BUILTIN_EXPECT' => 0 );
 
41
        $conf->debug("DEBUG: __builtin_expect not detected\n");
 
42
        $self->set_result('no');
 
43
    }
 
44
    return 1;
 
45
}
 
46
 
 
47
#################### INTERNAL SUBROUTINES ####################
 
48
 
 
49
sub _test {
 
50
    my ($conf) = @_;
 
51
 
 
52
    $conf->cc_gen('config/auto/expect/test_c.in');
 
53
    eval { $conf->cc_build() };
 
54
    my $ret = $@ ? 0 : eval $conf->cc_run();
 
55
    $conf->cc_clean();
 
56
 
 
57
    return $ret;
 
58
}
 
59
 
 
60
1;
 
61
 
 
62
# Local Variables:
 
63
#   mode: cperl
 
64
#   cperl-indent-level: 4
 
65
#   fill-column: 100
 
66
# End:
 
67
# vim: expandtab shiftwidth=4: