… | |
… | |
5 | use Config; |
5 | use Config; |
6 | |
6 | |
7 | # when built as part of perl, these are not available |
7 | # when built as part of perl, these are not available |
8 | BEGIN { eval "use Socket ()" } |
8 | BEGIN { eval "use Socket ()" } |
9 | BEGIN { eval "use Fcntl ()" } |
9 | BEGIN { eval "use Fcntl ()" } |
|
|
10 | BEGIN { eval "use POSIX ()" } |
10 | |
11 | |
11 | open my $fh, ">lib/AnyEvent/constants.pl" |
12 | open my $fh, ">lib/AnyEvent/constants.pl" |
12 | or die "lib/AnyEvent/constants.pl: $_[0]\n"; |
13 | or die "lib/AnyEvent/constants.pl: $_[0]\n"; |
13 | |
14 | |
14 | my $oldstdout = select $fh; |
15 | my $oldstdout = select $fh; |
… | |
… | |
30 | # used a lot |
31 | # used a lot |
31 | i CYGWIN => $^O =~ /cygwin/i; |
32 | i CYGWIN => $^O =~ /cygwin/i; |
32 | i WIN32 => $WIN32; |
33 | i WIN32 => $WIN32; |
33 | |
34 | |
34 | # add these purely to avoid loading Fcntl, which is slow and bloated. |
35 | # add these purely to avoid loading Fcntl, which is slow and bloated. |
35 | use Fcntl (); |
|
|
36 | |
36 | |
37 | i F_SETFD => eval { Fcntl::F_SETFD() } || 2; |
37 | i F_SETFD => eval { Fcntl::F_SETFD() } || 2; |
38 | i F_SETFL => eval { Fcntl::F_SETFL() } || 4; |
38 | i F_SETFL => eval { Fcntl::F_SETFL() } || 4; |
39 | i O_NONBLOCK => eval { Fcntl::O_NONBLOCK() } || 04000; |
39 | i O_NONBLOCK => eval { Fcntl::O_NONBLOCK() } || 04000; |
40 | i FD_CLOEXEC => eval { Fcntl::FD_CLOEXEC() } || 1; |
40 | i FD_CLOEXEC => eval { Fcntl::FD_CLOEXEC() } || 1; |
|
|
41 | |
|
|
42 | print "package AnyEvent::Base;\n"; |
|
|
43 | |
|
|
44 | # add these purely to avoid loading POSIX, which is slow and bloated. |
|
|
45 | |
|
|
46 | i WNOHANG => eval { POSIX::WNOHANG() } || 1; |
|
|
47 | |
|
|
48 | print "package AnyEvent::IO;\n"; |
|
|
49 | |
|
|
50 | i O_RDONLY => eval { Fcntl::O_RDONLY() } || 0; |
|
|
51 | i O_WRONLY => eval { Fcntl::O_WRONLY() } || 1; |
|
|
52 | i O_RDWR => eval { Fcntl::O_RDWR () } || 2; |
|
|
53 | i O_CREAT => eval { Fcntl::O_CREAT () } || 64; |
|
|
54 | i O_EXCL => eval { Fcntl::O_EXCL () } || 128; |
|
|
55 | i O_TRUNC => eval { Fcntl::O_TRUNC () } || 512; |
|
|
56 | i O_APPEND => eval { Fcntl::O_APPEND() } || 1024; |
41 | |
57 | |
42 | print "package AnyEvent::Util;\n"; |
58 | print "package AnyEvent::Util;\n"; |
43 | |
59 | |
44 | # broken windows perls use undocumented error codes... |
60 | # broken windows perls use undocumented error codes... |
45 | if ($WIN32) { |
61 | if ($WIN32) { |