| File: | config/auto/signal.pm |
| Coverage: | 89.1% |
| line | stmt | bran | cond | sub | code |
|---|---|---|---|---|---|
| 1 | # Copyright (C) 2001-2009, Parrot Foundation. | ||||
| 2 | |||||
| 3 - 11 | =head1 NAME config/auto/signal.pm - Signals =head1 DESCRIPTION Determines some signal stuff. =cut | ||||
| 12 | |||||
| 13 | package auto::signal; | ||||
| 14 | |||||
| 15 | 2 2 2 | use strict; | |||
| 16 | 2 2 2 | use warnings; | |||
| 17 | |||||
| 18 | 2 2 2 | use base qw(Parrot::Configure::Step); | |||
| 19 | |||||
| 20 | 2 2 2 | use Parrot::Configure::Utils ':auto'; | |||
| 21 | |||||
| 22 | |||||
| 23 | sub _init { | ||||
| 24 | 3 | my $self = shift; | |||
| 25 | 3 | my %data; | |||
| 26 | 3 | $data{description} = q{Determine some signal stuff}; | |||
| 27 | 3 | $data{result} = q{}; | |||
| 28 | 3 | return \%data; | |||
| 29 | } | ||||
| 30 | |||||
| 31 | sub runstep { | ||||
| 32 | 1 | my ( $self, $conf ) = @_; | |||
| 33 | |||||
| 34 | 1 | $conf->data->set( | |||
| 35 | has___sighandler_t => undef, | ||||
| 36 | has_sigatomic_t => undef, | ||||
| 37 | has_sigaction => undef, | ||||
| 38 | has_setitimer => undef | ||||
| 39 | ); | ||||
| 40 | |||||
| 41 | 1 | $conf->cc_gen('config/auto/signal/test1_c.in'); | |||
| 42 | 1 1 | eval { $conf->cc_build(); }; | |||
| 43 | 1 | unless ( $@ || $conf->cc_run() !~ /ok/ ) { | |||
| 44 | 1 | _handle__sighandler_t($conf); | |||
| 45 | } | ||||
| 46 | 1 | $conf->cc_clean(); | |||
| 47 | |||||
| 48 | 1 | $conf->cc_gen('config/auto/signal/test2_c.in'); | |||
| 49 | 1 1 | eval { $conf->cc_build(); }; | |||
| 50 | 1 | unless ( $@ || $conf->cc_run() !~ /ok/ ) { | |||
| 51 | 1 | _handle_sigaction($conf); | |||
| 52 | } | ||||
| 53 | 1 | $conf->cc_clean(); | |||
| 54 | |||||
| 55 | 1 | $conf->cc_gen('config/auto/signal/test_itimer_c.in'); | |||
| 56 | 1 1 | eval { $conf->cc_build(); }; | |||
| 57 | 1 | unless ( $@ || $conf->cc_run() !~ /ok/ ) { | |||
| 58 | 1 | _handle_setitimer($conf); | |||
| 59 | } | ||||
| 60 | 1 | $conf->cc_clean(); | |||
| 61 | |||||
| 62 | # now generate signal constants | ||||
| 63 | 1 | my $signalpasm = "runtime/parrot/include/signal.pasm"; | |||
| 64 | 1 | _print_signalpasm($conf, $signalpasm); | |||
| 65 | |||||
| 66 | 1 | return 1; | |||
| 67 | } | ||||
| 68 | |||||
| 69 | sub _handle__sighandler_t { | ||||
| 70 | 3 | my ($conf) = @_; | |||
| 71 | 3 | $conf->data->set( has___sighandler_t => 'define' ); | |||
| 72 | 3 | $conf->debug(" (__sighandler_t)"); | |||
| 73 | 3 | return 1; | |||
| 74 | } | ||||
| 75 | |||||
| 76 | sub _handle_sigaction { | ||||
| 77 | 3 | my ($conf) = @_; | |||
| 78 | 3 | $conf->data->set( has_sigaction => 'define' ); | |||
| 79 | 3 | $conf->debug(" (sigaction)"); | |||
| 80 | 3 | return 1; | |||
| 81 | } | ||||
| 82 | |||||
| 83 | sub _handle_setitimer { | ||||
| 84 | 3 | my ($conf) = @_; | |||
| 85 | 3 | $conf->data->set( | |||
| 86 | has_setitimer => 'define', | ||||
| 87 | has_sig_atomic_t => 'define', | ||||
| 88 | ); | ||||
| 89 | 3 | $conf->debug(" (setitimer) "); | |||
| 90 | 3 | return 1; | |||
| 91 | } | ||||
| 92 | |||||
| 93 | sub _print_signalpasm { | ||||
| 94 | 2 | my ($conf, $signalpasm) = @_; | |||
| 95 | 2 | open my $O, ">", $signalpasm | |||
| 96 | or die "Cant write $signalpasm"; | ||||
| 97 | 2 2 | print {$O} <<"EOF"; | |||
| 98 | # DO NOT EDIT THIS FILE. | ||||
| 99 | # | ||||
| 100 | # This file is generated automatically by config/auto/signal.pm | ||||
| 101 | # | ||||
| 102 | # Any changes made here will be lost. | ||||
| 103 | # | ||||
| 104 | EOF | ||||
| 105 | 2 | my ( $i, $name ); | |||
| 106 | 2 | $i = 0; | |||
| 107 | 2 | foreach $name ( split( ' ', $conf->data->get('sig_name_provisional') ) ) { | |||
| 108 | 138 136 | print {$O} ".macro_const SIG$name\t$i\n" if $i; | |||
| 109 | 138 | $i++; | |||
| 110 | } | ||||
| 111 | 2 | close $O; | |||
| 112 | } | ||||
| 113 | |||||
| 114 | 1; | ||||
| 115 | |||||
| 116 | # Local Variables: | ||||
| 117 | # mode: cperl | ||||
| 118 | # cperl-indent-level: 4 | ||||
| 119 | # fill-column: 100 | ||||
| 120 | # End: | ||||
| 121 | # vim: expandtab shiftwidth=4: | ||||