1 |
root |
1.1 |
#! perl |
2 |
|
|
|
3 |
root |
1.4 |
# this file is unfortunately only executed at Makefile.PL time |
4 |
|
|
|
5 |
root |
1.3 |
open my $fh, ">lib/AnyEvent/constants.pl" |
6 |
|
|
or die "lib/AnyEvent/constants.pl: $_[0]\n"; |
7 |
|
|
|
8 |
|
|
my $oldstdout = select $fh; |
9 |
root |
1.1 |
|
10 |
|
|
sub i($$) { |
11 |
|
|
print "sub $_[0] () { ", $_[1]*1, " }\n"; |
12 |
|
|
} |
13 |
|
|
|
14 |
|
|
print "package AnyEvent;\n"; |
15 |
|
|
|
16 |
|
|
our $WIN32 = $^O =~ /mswin32/i; |
17 |
|
|
|
18 |
|
|
i CYGWIN => $^O =~ /cygwin/i; |
19 |
|
|
i WIN32 => $WIN32; |
20 |
|
|
|
21 |
|
|
use Fcntl (); |
22 |
|
|
|
23 |
root |
1.2 |
i F_SETFL => eval { Fcntl::F_SETFL() }; |
24 |
|
|
i F_SETFD => eval { Fcntl::F_SETFD() }; |
25 |
|
|
i O_NONBLOCK => eval { Fcntl::O_NONBLOCK() }; |
26 |
|
|
i FD_CLOEXEC => eval { Fcntl::FD_CLOEXEC() }; |
27 |
root |
1.1 |
|
28 |
|
|
print "package AnyEvent::Util;\n"; |
29 |
|
|
|
30 |
|
|
# broken windows perls use undocumented error codes... |
31 |
|
|
if ($WIN32) { |
32 |
|
|
i WSAEINVAL => 10022; |
33 |
|
|
i WSAEWOULDBLOCK => 10035; |
34 |
|
|
i WSAEINPROGRESS => 10036; |
35 |
|
|
} else { |
36 |
|
|
# these should never match any errno value |
37 |
|
|
i WSAEINVAL => -1e99; |
38 |
|
|
i WSAEWOULDBLOCK => -1e99; |
39 |
|
|
i WSAEINPROGRESS => -1e99; |
40 |
|
|
} |
41 |
|
|
|
42 |
|
|
my $af_inet6; |
43 |
|
|
|
44 |
root |
1.2 |
$af_inet6 ||= eval { require Socket ; Socket::AF_INET6 () }; |
45 |
root |
1.5 |
$af_inet6 ||= eval { require Socket6; Socket6::AF_INET6() }; |
46 |
root |
1.1 |
|
47 |
|
|
# uhoh |
48 |
|
|
$af_inet6 ||= 10 if $^O =~ /linux/; |
49 |
|
|
$af_inet6 ||= 23 if $^O =~ /cygwin/i; |
50 |
|
|
$af_inet6 ||= 23 if AnyEvent::WIN32; |
51 |
|
|
$af_inet6 ||= 24 if $^O =~ /openbsd|netbsd/; |
52 |
|
|
$af_inet6 ||= 28 if $^O =~ /freebsd/; |
53 |
|
|
|
54 |
|
|
#TODO: WSAxxx, EDOM/ESPIPE |
55 |
|
|
|
56 |
|
|
i _AF_INET6 => $af_inet6; |
57 |
|
|
#i AF_UNIX => Socket::AF_UNIX (); |
58 |
|
|
#i SOCK_STREAM => Socket::SOCK_STREAM (); |
59 |
|
|
#i SOCK_DGRAM => Socket::SOCK_DGRAM (); |
60 |
|
|
#i SOL_SOCKET => Socket::SOL_SOCKET (); |
61 |
|
|
#i SO_REUSEADDR => Socket::SO_REUSEADDR (); |
62 |
|
|
#i SO_KEEPALIVE => Socket::SO_KEEPALIVE (); |
63 |
|
|
#i SO_OOBINLINE => Socket::SO_OOBINLINE (); |
64 |
|
|
#i IPPROTO_TCP => Socket::IPPROTO_TCP (); |
65 |
|
|
|
66 |
|
|
print "1;\n"; |
67 |
|
|
|
68 |
root |
1.3 |
close $fh; |
69 |
|
|
select $oldstdout; |
70 |
|
|
|
71 |
root |
1.1 |
rename "$ARGV[0]~", $ARGV[0]; |
72 |
root |
1.3 |
|
73 |
|
|
1 |