1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | # this file is unfortunately only executed at Makefile.PL time |
3 | # this file is unfortunately only executed at Makefile.PL time |
4 | |
4 | |
|
|
5 | my ($fh, $oldstdout); |
|
|
6 | |
|
|
7 | BEGIN { |
|
|
8 | open $fh, ">lib/AnyEvent/constants.pl" |
|
|
9 | or die "lib/AnyEvent/constants.pl: $!\n"; |
|
|
10 | |
|
|
11 | $oldstdout = select $fh; |
|
|
12 | |
|
|
13 | print "# automatically generated from constants.pl.PL\n"; |
|
|
14 | } |
|
|
15 | |
|
|
16 | { |
|
|
17 | # from common::sense 3.74 |
|
|
18 | use strict qw(vars subs); |
|
|
19 | no warnings; |
|
|
20 | use warnings qw(FATAL closed threads internal debugging pack malloc portable prototype |
|
|
21 | inplace io pipe unpack glob digit printf |
|
|
22 | layer reserved taint closure semicolon); |
|
|
23 | no warnings qw(exec newline unopened); |
|
|
24 | |
|
|
25 | BEGIN { |
|
|
26 | print "sub AnyEvent::common_sense {\n"; |
|
|
27 | printf " local \$^W;\n"; |
|
|
28 | printf " \${^WARNING_BITS} ^= \${^WARNING_BITS} ^ \"%s\";\n", |
|
|
29 | join "", map "\\x$_", unpack "(H2)*", ${^WARNING_BITS}; |
|
|
30 | # use strict, use utf8; |
|
|
31 | printf " \$^H |= 0x%x;\n", $^H; |
|
|
32 | print "}\n"; |
|
|
33 | } |
|
|
34 | } |
|
|
35 | |
5 | use Config; |
36 | use Config; |
6 | use Socket; |
|
|
7 | |
37 | |
8 | open my $fh, ">lib/AnyEvent/constants.pl" |
|
|
9 | or die "lib/AnyEvent/constants.pl: $_[0]\n"; |
|
|
10 | |
|
|
11 | my $oldstdout = select $fh; |
|
|
12 | |
|
|
13 | print "# automatically generated from constants.pl.PL for perl $] built for $Config{archname}\n"; |
38 | print "# generated for perl $] built for $Config{archname}\n"; |
|
|
39 | |
|
|
40 | # when built as part of perl, these are not available |
|
|
41 | BEGIN { eval "use Socket ()" } |
|
|
42 | BEGIN { eval "use Fcntl ()" } |
|
|
43 | BEGIN { eval "use POSIX ()" } |
14 | |
44 | |
15 | sub i($$) { |
45 | sub i($$) { |
16 | print "sub $_[0](){", $_[1]*1, "}\n"; |
46 | print "sub $_[0](){", $_[1]*1, "}\n"; |
17 | } |
47 | } |
18 | |
48 | |
… | |
… | |
27 | # used a lot |
57 | # used a lot |
28 | i CYGWIN => $^O =~ /cygwin/i; |
58 | i CYGWIN => $^O =~ /cygwin/i; |
29 | i WIN32 => $WIN32; |
59 | i WIN32 => $WIN32; |
30 | |
60 | |
31 | # add these purely to avoid loading Fcntl, which is slow and bloated. |
61 | # add these purely to avoid loading Fcntl, which is slow and bloated. |
32 | use Fcntl (); |
|
|
33 | |
62 | |
34 | i F_SETFL => eval { Fcntl::F_SETFL() }; |
|
|
35 | i F_SETFD => eval { Fcntl::F_SETFD() }; |
63 | i F_SETFD => eval { Fcntl::F_SETFD() } || 2; |
|
|
64 | i F_SETFL => eval { Fcntl::F_SETFL() } || 4; |
36 | i O_NONBLOCK => eval { Fcntl::O_NONBLOCK() }; |
65 | i O_NONBLOCK => eval { Fcntl::O_NONBLOCK() } || 04000; |
37 | i FD_CLOEXEC => eval { Fcntl::FD_CLOEXEC() }; |
66 | i FD_CLOEXEC => eval { Fcntl::FD_CLOEXEC() } || 1; |
|
|
67 | |
|
|
68 | print "package AnyEvent::Base;\n"; |
|
|
69 | |
|
|
70 | # add these purely to avoid loading POSIX, which is slow and bloated. |
|
|
71 | |
|
|
72 | i WNOHANG => eval { POSIX::WNOHANG() } || 1; |
|
|
73 | |
|
|
74 | print "package AnyEvent::IO;\n"; |
|
|
75 | |
|
|
76 | i O_RDONLY => eval { Fcntl::O_RDONLY() } || 0; |
|
|
77 | i O_WRONLY => eval { Fcntl::O_WRONLY() } || 1; |
|
|
78 | i O_RDWR => eval { Fcntl::O_RDWR () } || 2; |
|
|
79 | i O_CREAT => eval { Fcntl::O_CREAT () } || 64; |
|
|
80 | i O_EXCL => eval { Fcntl::O_EXCL () } || 128; |
|
|
81 | i O_TRUNC => eval { Fcntl::O_TRUNC () } || 512; |
|
|
82 | i O_APPEND => eval { Fcntl::O_APPEND() } || 1024; |
38 | |
83 | |
39 | print "package AnyEvent::Util;\n"; |
84 | print "package AnyEvent::Util;\n"; |
40 | |
85 | |
41 | # broken windows perls use undocumented error codes... |
86 | # broken windows perls use undocumented error codes... |
42 | if ($WIN32) { |
87 | if ($WIN32) { |
… | |
… | |
118 | linux TCP_WINDOW_CLAMP 10 |
163 | linux TCP_WINDOW_CLAMP 10 |
119 | linux TCP_INFO 11 |
164 | linux TCP_INFO 11 |
120 | linux TCP_QUICKACK 12 |
165 | linux TCP_QUICKACK 12 |
121 | linux TCP_CONGESTION 13 |
166 | linux TCP_CONGESTION 13 |
122 | linux TCP_MD5SIG 14 |
167 | linux TCP_MD5SIG 14 |
|
|
168 | linux TCP_FASTOPEN 23 |
|
|
169 | linux MSG_DONTWAIT 0x0040 |
|
|
170 | linux MSG_NOSIGNAL 0x4000 |
|
|
171 | linux MSG_MORE 0x8000 |
|
|
172 | linux MSG_FASTOPEN 0x20000000 |
123 | netbsd TCP_MAXSEG 2 |
173 | netbsd TCP_MAXSEG 2 |
124 | netbsd TCP_KEEPIDLE 3 |
174 | netbsd TCP_KEEPIDLE 3 |
125 | netbsd TCP_NOPUSH 4 |
175 | netbsd TCP_NOPUSH 4 |
126 | netbsd TCP_KEEPINTVL 5 |
176 | netbsd TCP_KEEPINTVL 5 |
127 | netbsd TCP_KEEPCNT 6 |
177 | netbsd TCP_KEEPCNT 6 |
128 | netbsd TCP_KEEPINIT 7 |
178 | netbsd TCP_KEEPINIT 7 |
129 | netbsd TCP_NOOPT 8 |
179 | netbsd TCP_NOOPT 8 |
130 | netbsd TCP_MD5SIG 0x10 |
180 | netbsd TCP_MD5SIG 0x10 |
131 | netbsd TCP_CONGESTION 0x20 |
181 | netbsd TCP_CONGESTION 0x20 |
|
|
182 | netbsd MSG_NOSIGNAL 0x0400 |
132 | cygwin TCP_MAXSEG 0x02 |
183 | cygwin TCP_MAXSEG 0x02 |
133 | cygwin TCP_NOPUSH 0x04 |
184 | cygwin TCP_NOPUSH 0x04 |
134 | cygwin TCP_NOOPT 0x08 |
185 | cygwin TCP_NOOPT 0x08 |
135 | freebsd TCP_MAXSEG 0x02 |
186 | freebsd TCP_MAXSEG 0x02 |
136 | freebsd TCP_NOPUSH 0x04 |
187 | freebsd TCP_NOPUSH 0x04 |
137 | freebsd TCP_NOOPT 0x08 |
188 | freebsd TCP_NOOPT 0x08 |
138 | freebsd TCP_MD5SIG 0x10 |
189 | freebsd TCP_MD5SIG 0x10 |
139 | freebsd TCP_INFO 0x20 |
190 | freebsd TCP_INFO 0x20 |
140 | freebsd TCP_CONGESTION 0x40 |
191 | freebsd TCP_CONGESTION 0x40 |
|
|
192 | freebsd MSG_NOSIGNAL 0x20000 |
141 | solaris TCP_CORK 0x18 |
193 | solaris TCP_CORK 0x18 |
142 | solaris TCP_LINGER2 0x1C |
194 | solaris TCP_LINGER2 0x1C |
143 | solaris TCP_INIT_CWND 0x15 |
195 | solaris TCP_INIT_CWND 0x15 |
144 | solaris TCP_KEEPALIVE 0x8 |
196 | solaris TCP_KEEPALIVE 0x8 |
145 | solaris TCP_MAXSEG 0x02 |
197 | solaris TCP_MAXSEG 0x02 |