File Coverage

blib/lib/IO/FD.pm
Criterion Covered Total %
statement 24 40 60.0
branch 1 8 12.5
condition n/a
subroutine 8 11 72.7
pod 0 1 0.0
total 33 60 55.0


line stmt bran cond sub pod time code
1             package IO::FD;
2              
3 22     22   2641581 use strict;
  22         40  
  22         848  
4 22     22   112 use warnings;
  22         42  
  22         1496  
5 22     22   137 use Carp;
  22         42  
  22         2057  
6              
7 22     22   131 use Exporter "import";
  22         64  
  22         913  
8 22     22   11763 use AutoLoader;
  22         42731  
  22         150  
9              
10             #our @ISA = qw(Exporter);
11              
12             # Items to export into callers namespace by default. Note: do not export
13             # names by default without a very good reason. Use EXPORT_OK instead.
14             # Do not simply export all your public functions/methods/constants.
15              
16             # This allows declaration use IO::FD ':all';
17             # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
18             # will save memory.
19             our %EXPORT_TAGS = ( 'all' => [ qw(
20             accept
21             accept_multiple
22             accept4
23             listen
24             socket
25             sockatmark
26             bind
27             connect
28              
29             sysopen
30             sysopen4
31             openat
32             open
33             close
34              
35             sysread
36             sysread3
37             sysread4
38              
39             syswrite
40             syswrite2
41             syswrite3
42             syswrite4
43              
44             pread
45             pwrite
46              
47             mkfifo
48             mkfifoat
49              
50             pipe
51             socketpair
52             sysseek
53              
54             dup
55             dup2
56              
57             fcntl
58             ioctl
59              
60             stat
61             lstat
62              
63             getsockopt
64             setsockopt
65             getpeername
66             getsockname
67             shutdown
68             select
69             poll
70              
71             mkstemp
72             mktemp
73              
74             readline
75             fileno
76              
77              
78             pread
79             pwrite
80              
81             recv
82             send
83             sendfile
84              
85             ) ] );
86              
87             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
88              
89             our @EXPORT = qw(
90            
91             );
92              
93             our $VERSION = 'v0.3.11';
94              
95 22     22   13581 use constant::more();
  22         26253  
  22         2269  
96             #use constant();
97             #use Socket qw;
98             my $non_block;
99             my $cloexec;
100             #Define constants for non linux systems (looked up from a ubuntu machine...)
101             BEGIN {
102 22 50   22   180 if($^O =~ /darwin/i){
103             #Make belive values
104 0         0 $cloexec=0x10000000;
105 0         0 $non_block=0x20000000;
106 0         0 constant::more->import(SOCK_NONBLOCK=> $non_block);
107 0         0 constant::more->import(SOCK_CLOEXEC=> $cloexec);
108             }
109             else {
110 22         65 $cloexec=0;
111 22         3815 $non_block=0;
112             }
113             }
114              
115              
116              
117             sub fileno :prototype($) {
118 0 0   0 0   ref($_[0])
119             ?fileno $_[0]
120             : $_[0];
121             }
122              
123             sub AUTOLOAD {
124             # This AUTOLOAD is used to 'autoload' constants from the constant()
125             # XS function.
126              
127 0     0     my $constname;
128 0           our $AUTOLOAD;
129 0           ($constname = $AUTOLOAD) =~ s/.*:://;
130 0 0         croak "&IO::FD::constant not defined" if $constname eq 'constant';
131 0           my ($error, $val) = constant($constname);
132 0 0         if ($error) { croak $error; }
  0            
133             {
134 22     22   212 no strict 'refs';
  22         35  
  22         3240  
  0            
135             # Fixed between 5.005_53 and 5.005_61
136             #XXX if ($] >= 5.00561) {
137             #XXX *$AUTOLOAD = sub () { $val };
138             #XXX }
139             #XXX else {
140 0     0     *$AUTOLOAD = sub { $val };
  0            
141             #XXX }
142             }
143 0           goto &$AUTOLOAD;
144             }
145              
146             require XSLoader;
147             XSLoader::load('IO::FD', $VERSION);
148              
149             # Preloaded methods go here.
150              
151             # Autoload methods go after =cut, and are processed by the autosplit program.
152              
153             1;
154             __END__