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.7 |
|
|
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 deprecated glob digit printf |
|
|
22 | layer reserved taint closure semicolon); |
|
|
23 | no warnings qw(exec newline unopened); |
|
|
24 | |
|
|
25 | BEGIN { |
|
|
26 | my $H = $^H; |
|
|
27 | my $WARN = ${^WARNING_BITS}; |
|
|
28 | |
|
|
29 | print "sub AnyEvent::common_sense {\n"; |
|
|
30 | printf " local \$^W;\n"; |
|
|
31 | printf " \${^WARNING_BITS} ^= \${^WARNING_BITS} ^ \"%s\";\n", |
|
|
32 | join "", map "\\x$_", unpack "(H2)*", ${^WARNING_BITS}; |
|
|
33 | # use strict, use utf8; |
|
|
34 | printf " \$^H |= 0x%x;\n", $^H; |
|
|
35 | print "}\n"; |
|
|
36 | } |
|
|
37 | } |
|
|
38 | |
5 | use Config; |
39 | use Config; |
|
|
40 | |
|
|
41 | print "# generated for perl $] built for $Config{archname}\n"; |
6 | |
42 | |
7 | # when built as part of perl, these are not available |
43 | # when built as part of perl, these are not available |
8 | BEGIN { eval "use Socket ()" } |
44 | BEGIN { eval "use Socket ()" } |
9 | BEGIN { eval "use Fcntl ()" } |
45 | BEGIN { eval "use Fcntl ()" } |
10 | |
46 | BEGIN { eval "use POSIX ()" } |
11 | open my $fh, ">lib/AnyEvent/constants.pl" |
|
|
12 | or die "lib/AnyEvent/constants.pl: $_[0]\n"; |
|
|
13 | |
|
|
14 | my $oldstdout = select $fh; |
|
|
15 | |
|
|
16 | print "# automatically generated from constants.pl.PL for perl $] built for $Config{archname}\n"; |
|
|
17 | |
47 | |
18 | sub i($$) { |
48 | sub i($$) { |
19 | print "sub $_[0](){", $_[1]*1, "}\n"; |
49 | print "sub $_[0](){", $_[1]*1, "}\n"; |
20 | } |
50 | } |
21 | |
51 | |
… | |
… | |
30 | # used a lot |
60 | # used a lot |
31 | i CYGWIN => $^O =~ /cygwin/i; |
61 | i CYGWIN => $^O =~ /cygwin/i; |
32 | i WIN32 => $WIN32; |
62 | i WIN32 => $WIN32; |
33 | |
63 | |
34 | # add these purely to avoid loading Fcntl, which is slow and bloated. |
64 | # add these purely to avoid loading Fcntl, which is slow and bloated. |
35 | use Fcntl (); |
|
|
36 | |
65 | |
37 | i F_SETFD => eval { Fcntl::F_SETFD() } || 2; |
66 | i F_SETFD => eval { Fcntl::F_SETFD() } || 2; |
38 | i F_SETFL => eval { Fcntl::F_SETFL() } || 4; |
67 | i F_SETFL => eval { Fcntl::F_SETFL() } || 4; |
39 | i O_NONBLOCK => eval { Fcntl::O_NONBLOCK() } || 04000; |
68 | i O_NONBLOCK => eval { Fcntl::O_NONBLOCK() } || 04000; |
40 | i FD_CLOEXEC => eval { Fcntl::FD_CLOEXEC() } || 1; |
69 | i FD_CLOEXEC => eval { Fcntl::FD_CLOEXEC() } || 1; |
|
|
70 | |
|
|
71 | print "package AnyEvent::Base;\n"; |
|
|
72 | |
|
|
73 | # add these purely to avoid loading POSIX, which is slow and bloated. |
|
|
74 | |
|
|
75 | i WNOHANG => eval { POSIX::WNOHANG() } || 1; |
|
|
76 | |
|
|
77 | print "package AnyEvent::IO;\n"; |
|
|
78 | |
|
|
79 | i O_RDONLY => eval { Fcntl::O_RDONLY() } || 0; |
|
|
80 | i O_WRONLY => eval { Fcntl::O_WRONLY() } || 1; |
|
|
81 | i O_RDWR => eval { Fcntl::O_RDWR () } || 2; |
|
|
82 | i O_CREAT => eval { Fcntl::O_CREAT () } || 64; |
|
|
83 | i O_EXCL => eval { Fcntl::O_EXCL () } || 128; |
|
|
84 | i O_TRUNC => eval { Fcntl::O_TRUNC () } || 512; |
|
|
85 | i O_APPEND => eval { Fcntl::O_APPEND() } || 1024; |
41 | |
86 | |
42 | print "package AnyEvent::Util;\n"; |
87 | print "package AnyEvent::Util;\n"; |
43 | |
88 | |
44 | # broken windows perls use undocumented error codes... |
89 | # broken windows perls use undocumented error codes... |
45 | if ($WIN32) { |
90 | if ($WIN32) { |