| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Test::Stream::Capabilities; | 
| 2 | 109 |  |  | 109 |  | 1019 | use strict; | 
|  | 109 |  |  |  |  | 188 |  | 
|  | 109 |  |  |  |  | 2688 |  | 
| 3 | 109 |  |  | 109 |  | 514 | use warnings; | 
|  | 109 |  |  |  |  | 187 |  | 
|  | 109 |  |  |  |  | 2462 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 109 |  |  | 109 |  | 488 | use Config; | 
|  | 109 |  |  |  |  | 191 |  | 
|  | 109 |  |  |  |  | 4829 |  | 
| 6 | 109 |  |  | 109 |  | 515 | use Carp qw/croak/; | 
|  | 109 |  |  |  |  | 192 |  | 
|  | 109 |  |  |  |  | 15254 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | sub import { | 
| 9 | 235 |  |  | 235 |  | 594 | my $class = shift; | 
| 10 | 235 |  |  |  |  | 556 | my $caller = caller; | 
| 11 |  |  |  |  |  |  |  | 
| 12 | 235 |  |  |  |  | 610 | for my $check (@_) { | 
| 13 | 247 | 50 | 33 |  |  | 3594 | croak "'$check' is not a known capability" | 
| 14 |  |  |  |  |  |  | unless $check =~ m/^CAN_/ && $class->can("$check"); | 
| 15 |  |  |  |  |  |  |  | 
| 16 | 247 |  |  |  |  | 732 | my $const = get_const($check); | 
| 17 | 109 |  |  | 109 |  | 602 | no strict 'refs'; | 
|  | 109 |  |  |  |  | 186 |  | 
|  | 109 |  |  |  |  | 44665 |  | 
| 18 | 247 |  |  |  |  | 376 | *{"$caller\::$check"} = $const; | 
|  | 247 |  |  |  |  | 11795 |  | 
| 19 |  |  |  |  |  |  | } | 
| 20 |  |  |  |  |  |  | } | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | my %LOOKUP; | 
| 23 |  |  |  |  |  |  | sub get_const { | 
| 24 | 251 |  |  | 251 | 0 | 413 | my $check = shift; | 
| 25 |  |  |  |  |  |  |  | 
| 26 | 251 | 100 |  |  |  | 842 | unless ($LOOKUP{$check}) { | 
| 27 | 228 |  |  |  |  | 688 | my $bool = __PACKAGE__->$check; | 
| 28 | 228 |  |  | 0 |  | 2277 | $LOOKUP{$check} = sub() { $bool }; | 
|  | 0 |  |  |  |  | 0 |  | 
| 29 |  |  |  |  |  |  | } | 
| 30 |  |  |  |  |  |  |  | 
| 31 | 251 |  |  |  |  | 709 | return $LOOKUP{$check}; | 
| 32 |  |  |  |  |  |  | } | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | sub CAN_REALLY_FORK { | 
| 35 | 10 | 50 |  | 10 | 1 | 142 | return 1 if $Config{d_fork}; | 
| 36 | 0 |  |  |  |  | 0 | return 0; | 
| 37 |  |  |  |  |  |  | } | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | sub CAN_FORK { | 
| 40 | 109 | 50 |  | 109 | 1 | 7715 | return 1 if $Config{d_fork}; | 
| 41 | 0 | 0 | 0 |  |  | 0 | return 0 unless $^O eq 'MSWin32' || $^O eq 'NetWare'; | 
| 42 | 0 | 0 |  |  |  | 0 | return 0 unless $Config{useithreads}; | 
| 43 | 0 | 0 |  |  |  | 0 | return 0 unless $Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/; | 
| 44 |  |  |  |  |  |  |  | 
| 45 | 0 |  |  |  |  | 0 | my $thread_const = get_const('CAN_THREAD'); | 
| 46 |  |  |  |  |  |  |  | 
| 47 | 0 |  |  |  |  | 0 | return $thread_const->(); | 
| 48 |  |  |  |  |  |  | } | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | sub CAN_THREAD { | 
| 51 | 109 | 50 |  | 109 | 1 | 520 | return 0 unless $] >= 5.008001; | 
| 52 | 109 | 50 |  |  |  | 1207 | return 0 unless $Config{'useithreads'}; | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | # Threads are broken on perl 5.10.0 built with gcc 4.8+ | 
| 55 | 0 | 0 | 0 |  |  |  | if ($] == 5.010000 && $Config{'ccname'} eq 'gcc' && $Config{'gccversion'}) { | 
|  |  |  | 0 |  |  |  |  | 
| 56 | 0 |  |  |  |  |  | my @parts = split /\./, $Config{'gccversion'}; | 
| 57 | 0 | 0 | 0 |  |  |  | return 0 if $parts[0] >= 4 && $parts[1] >= 8; | 
| 58 |  |  |  |  |  |  | } | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | # Change to a version check if this ever changes | 
| 61 | 0 | 0 |  |  |  |  | return 0 if $INC{'Devel/Cover.pm'}; | 
| 62 | 0 |  |  |  |  |  | return 1; | 
| 63 |  |  |  |  |  |  | } | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | 1; | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | __END__ |