File Coverage

blib/lib/IO/FD/Constants.pm
Criterion Covered Total %
statement 26 30 86.6
branch 5 14 35.7
condition n/a
subroutine 8 8 100.0
pod n/a
total 39 52 75.0


line stmt bran cond sub pod time code
1             package IO::FD::Constants;
2             our @names;
3             BEGIN {
4 1     1   795 @names=(
5             POLLIN=>0x0001,
6             POLLPRI=>0x0002,
7             POLLOUT=>0x0004,
8             POLLRDNORM=>0x0040,
9             POLLWRNORM=>POLLOUT,
10             POLLRDBAND=>0x0080,
11             POLLWRBAND=>0x0100,
12              
13             POLLEXTEND=>0x0200,
14             POLLATTRIB=>0x0400,
15             POLLNLINK=>0x0800,
16             POLLWRITE=>0x1000,
17              
18             POLLERR=>0x0008,
19             POLLHUP=>0x0010,
20             POLLNVAL=>0x0020,
21              
22             POLLSTANDARD=>(POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
23             POLLWRBAND|POLLERR|POLLHUP|POLLNVAL),
24              
25              
26             EVFILT_READ=>-1,
27             EVFILT_WRITE=>-2,
28             EVFILT_AIO=>-3,
29             EVFILT_VNODE=>-4,
30             EVFILT_PROC=>-5,
31             EVFILT_SIGNAL=>-6,
32             EVFILT_TIMER=>-7,
33             EVFILT_MACHPORT=>-8,
34             EVFILT_FS=>-9,
35             EVFILT_USER=>-10,
36             EVFILT_VM=>-12,
37             EVFILT_EXCEPT=>-15,
38             EVFILT_SYSCOUNT=>17,
39             EVFILT_THREADMARKER=>EVFILT_SYSCOUNT,
40             KEVENT_FLAG_NONE=>0x000000,
41             KEVENT_FLAG_IMMEDIATE=>0x000001,
42             KEVENT_FLAG_ERROR_EVENTS=>0x000002,
43             EV_ADD=>0x0001,
44             EV_DELETE=>0x0002,
45             EV_ENABLE=>0x0004,
46             EV_DISABLE=>0x0008,
47             EV_ONESHOT=>0x0010,
48             EV_CLEAR=>0x0020,
49             EV_RECEIPT=>0x0040,
50             EV_DISPATCH=>0x0080,
51             EV_UDATA_SPECIFIC=>0x0100,
52              
53             EV_DISPATCH2=>(EV_DISPATCH | EV_UDATA_SPECIFIC),
54              
55             EV_VANISHED=>0x0200,
56             EV_SYSFLAGS=>0xF000,
57             EV_FLAG0=>0x1000,
58             EV_FLAG1=>0x2000,
59             EV_EOF=>0x8000,
60             EV_ERROR=>0x4000,
61             EV_POLL=>EV_FLAG0,
62             EV_OOBAND=>EV_FLAG1,
63             NOTE_TRIGGER=>0x01000000,
64             NOTE_FFNOP=>0x00000000,
65             NOTE_FFAND=>0x40000000,
66             NOTE_FFOR=>0x80000000,
67             NOTE_FFCOPY=>0xc0000000,
68             NOTE_FFCTRLMASK=>0xc0000000,
69             NOTE_FFLAGSMASK=>0x00ffffff,
70             NOTE_LOWAT=>0x00000001,
71             NOTE_OOB=>0x00000002,
72             NOTE_DELETE=>0x00000001,
73             NOTE_WRITE=>0x00000002,
74             NOTE_EXTEND=>0x00000004,
75             NOTE_ATTRIB=>0x00000008,
76             NOTE_LINK=>0x00000010,
77             NOTE_RENAME=>0x00000020,
78             NOTE_REVOKE=>0x00000040,
79             NOTE_NONE=>0x00000080,
80             NOTE_FUNLOCK=>0x00000100,
81             NOTE_EXIT=>0x80000000,
82             NOTE_FORK=>0x40000000,
83             NOTE_EXEC=>0x20000000,
84             #NOTE_REAP,
85             NOTE_SIGNAL=>0x08000000,
86             NOTE_EXITSTATUS=>0x04000000,
87             NOTE_EXIT_DETAIL=>0x02000000,
88             NOTE_PDATAMASK=>0x000fffff,
89             NOTE_PCTRLMASK=>(~NOTE_PDATAMASK),
90              
91             #NOTE_EXIT_REPARENTED,
92             NOTE_EXIT_DETAIL_MASK=>0x00070000,
93             NOTE_EXIT_DECRYPTFAIL=>0x00010000,
94             NOTE_EXIT_MEMORY=>0x00020000,
95             NOTE_EXIT_CSERROR=>0x00040000,
96             NOTE_VM_PRESSURE=>0x80000000,
97             NOTE_VM_PRESSURE_TERMINATE=>0x40000000,
98             NOTE_VM_PRESSURE_SUDDEN_TERMINATE=>0x20000000,
99             NOTE_VM_ERROR=>0x10000000,
100             NOTE_SECONDS=>0x00000001,
101             NOTE_USECONDS=>0x00000002,
102             NOTE_NSECONDS=>0x00000004,
103             NOTE_ABSOLUTE=>0x00000008,
104             NOTE_LEEWAY=>0x00000010,
105             NOTE_CRITICAL=>0x00000020,
106             NOTE_BACKGROUND=>0x00000040,
107             NOTE_MACH_CONTINUOUS_TIME=>0x00000080,
108             NOTE_MACHTIME=>0x00000100,
109             NOTE_TRACK=>0x00000001,
110             NOTE_TRACKERR=>0x00000002,
111             NOTE_CHILD=>0x00000004,
112              
113             );
114             }
115              
116             my $kevent_packer;
117             my $poll_packer;
118             BEGIN {
119             #Max integer size
120 1     1   3 my $int_size= log(~0 +1)/log(2)/8;
121              
122 1         1 $kevent_packer=do {
123 1 50       5 if($^O =~ /darwin/){
    50          
124             #ON darwin we use the kevent64_s type
125 0 0       0 $packer=
126             $int_size==8
127             ? "QsSLqQQQ"
128             : "LsSLlLLL";
129              
130             }
131             elsif($^O=~ /bsd/){
132             #bsd kqueue only has this type
133 0 0       0 $int_size==8
134             ? "QsSLqQQQQQ"
135             : "LsSLlLLLLL"
136              
137             }
138             else {
139 1         3 "";
140             }
141             };
142 1         1 $poll_packer = do {
143 1 50       18 if($^O =~/darwin/){
    50          
    50          
144 0         0 "iss";
145             }
146             elsif ($^O =~/bsd/){
147 0         0 "iss";
148             }
149             elsif ($^O=~/linux/){
150 1         38 "iss";
151             }
152             };
153             }
154              
155 1     1   7 use constant {@names};
  1         2  
  1         612  
156 1     1   6 use constant POLLFD_PACKER=>"($poll_packer)*";
  1         1  
  1         44  
157 1     1   3 use constant KEVENT_PACKER=>"($kevent_packer)*";
  1         1  
  1         42  
158              
159 1     1   4 use constant POLLFD_PACKER_ONCE=>$poll_packer;
  1         0  
  1         33  
160 1     1   4 use constant KEVENT_PACKER_ONCE=>$kevent_packer;
  1         1  
  1         27  
161              
162 1     1   3 use Exporter "import";
  1         2  
  1         121  
163              
164             our @EXPORT_OK=("POLLFD_PACKER", "KEVENT_PACKER", "POLLFD_PACKER_ONCE", "KEVENT_PACKER_ONCE", map $names[$_], grep {!($_%2)} 0..@names-1);
165             our @EXPORT=@EXPORT_OK;
166             1;